4

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

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

3

5 Answers 5

4

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

We use the terms 'Kernel space' and 'User space' to rather refer to who has the permission to access which part of the memory. 'Kernel Space' would refer to the memory to which just the kernel has access to, while 'User space' would be referring to the memory both the corresponding user process and kernel have access to.

2

It does not really refer to address space at all.

User Space: The processor executes something in a unpriviledged context.

Kernel Space: The processor executes something in a priviledged context.

In the priviledged context everything is allowed, in the unpriviledged 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 the context (with a system call).

You can allocate virtual memory (vmalloc) as well as physical memory (kmalloc) inside kernel space, so it is not related to memory directly.

In user space you can only allocate virtual memory (vmalloc = malloc).

0

"User space" and "kernel space" refer to ranges of logical addresses.

The kernel space is identical for all processes, whereas the user space is unique to each process. However, it is possible for user address spaces to share mappings to physical memory.

In theory, two processes could have identical user spaces, but that does not happen in practice.

0

In terms of the process concept:

We can say that a process can run in the 'kernel space' or in the 'user space', not both concurrently. Normally a process runs in the 'user space'. If the process needs to access a protected resource, it should jump into the 'kernel space' because only the kernel has the privilege to access a protected resource. To do this we have to use a system call.

In terms of the address space:

We can say that a (virtual) memory can be in the 'kernel (address) space' or in the 'user (address) space'. In a 32bit normal linux system, the user address space range is [0,0xbfffffff], the kernel address space is [0xc0000000, 0xffffffff].

-1

You are correct in part. System Memory is divided in these two types of memory :

User Space is a portion of the system memory in which user processes run. This contrasts with kernel space, which is that portion of memory in which the kernel executes and provides its services.

The contents of memory, which consists of dedicated RAM (random access memory) VLSI (very large scale integrated circuit) semiconductor chips, can be accessed (i.e., read and written to) at extremely high speeds but are retained only temporarily

Kernel Space is a memory that constitutes the central core of a computer operating system. It is in-fact a process, that controls all other processes, and it has complete control over everything that occurs on the system. This includes managing system resources of HW (managing devices) and SW (individual user processes, within user space and preventing them from interfering with each other. It's basically where the OS runs on.

1
  • 3
    This IMHO doesn't really answer the question "Does the terms “user space” and “kernel space” refer to physical memory?" Jun 14, 2017 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.