Do the terms "user space" and "kernel space" refer to physical memory?

When we use the term user space, do we mean an area in physical memory that contains code and data from user processes, or do we mean the 3 GB of virtual memory that each process has?

And if we use the term kernel space, do we mean an area in physical memory that contains kernel code and data, or do we mean 1 GB of virtual memory that each process has?

+3


source to share


5 answers


The terms "kernel space" and "user space" do not specifically refer to virtual or physical memory. Conceptually, if you say "kernel space" refers to the 1 GB of virtual memory each process has, it is still the same as referring to kernel code and data residing in physical memory, since 1 GB of virtual memory is mapped to physical memory. containing the core of code and data.



We use the terms kernel space and user space to rather refer to those who have permission to access that part of memory. Kernel Space will refer to memory that only the kernel has access to, while User Space will refer to memory that both the corresponding user process and the kernel have access to.

+3


source


This is not really the case for address space.

User space: The processor is doing something in an unprivileged context.

Kernel Space: The processor is doing something in a privileged context.

In a privileged context, everything is allowed; in a non-privileged context, some processor functions are limited. This is implemented in hardware, so the processor must support at least two modes for Linux.



So, to switch from user space to kernel space, you need to switch context (with a system call).

You can allocate virtual memory ( vmalloc

) as well as physical memory ( kmalloc

) inside kernel space, so it is not directly related to memory.

In user space, you can allocate virtual memory ( vmalloc

= malloc

).

+1


source


"User space" and "kernel space" refer to logical address ranges .

Kernel space is identical for all processes, while user space is unique for each process. However, custom address spaces can pass mappings into physical memory.

In theory, two processes could have the same user space, but this does not happen in practice.

0


source


In terms of the process concept :

You could say that a process can run in "kernel space" or in "user space" rather than simultaneously. Usually, the process runs in "user space". If a process needs to access a protected resource, it must go into "kernel space" because only the kernel has the privilege of accessing the protected resource. For this we have to use a system call.

In terms of address space :

We can say that (virtual) memory can reside in the "kernel (address space)" or in the "user (address) space". In a 32-bit normal Linux system, the address range of the user [0,0xbfffffff]

address space, the kernel address space [0xc0000000, 0xffffffff]

.

0


source


You are right in part. System memory is divided into these two types of memory:

User space is the portion of system memory in which user processes run. This is in contrast to kernel space, which is the portion of memory in which the kernel executes and provides its services.

The contents of the memory, which consists of VLSI (very large scale) semiconductor chips, can be accessed (i.e. read and written) at an extremely high speed, but only temporarily

Kernel> is the memory that makes up the central core of a computer operating system. In fact, it is a process that controls all other processes and completely controls everything that happens in the system. This includes managing the system resources of HWs (control devices) and SWs (separate user processes within user space and preventing them from interfering with each other). Basically where the OS is running.

-1


source







All Articles