[linux-kernel] What is the difference between the kernel space and the user space?

The maximum size of address space depends on the length of the address register on the CPU.

On systems with 32-bit address registers, the maximum size of address space is 232 bytes, or 4 GiB. Similarly, on 64-bit systems, 264 bytes can be addressed.

Such address space is called virtual memory or virtual address space. It is not actually related to physical RAM size.

On Linux platforms, virtual address space is divided into kernel space and user space.

An architecture-specific constant called task size limit, or TASK_SIZE, marks the position where the split occurs:

  • the address range from 0 up to TASK_SIZE-1 is allotted to user space;

  • the remainder from TASK_SIZE up to 232-1 (or 264-1) is allotted to kernel space.

On a particular 32-bit system for example, 3 GiB could be occupied for user space and 1 GiB for kernel space.

Each application/program in a Unix-like operating system is a process; each of those has a unique identifier called Process Identifier (or simply Process ID, i.e. PID). Linux provides two mechanisms for creating a process: 1. the fork() system call, or 2. the exec() call.

A kernel thread is a lightweight process and also a program under execution. A single process may consist of several threads sharing the same data and resources but taking different paths through the program code. Linux provides a clone() system call to generate threads.

Example uses of kernel threads are: data synchronization of RAM, helping the scheduler to distribute processes among CPUs, etc.

Examples related to linux-kernel

How to fix: fatal error: openssl/opensslv.h: No such file or directory in RedHat 7 How do I delete virtual interface in Linux? Image vs zImage vs uImage iptables v1.4.14: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) IOCTL Linux device driver How to solve "Kernel panic - not syncing - Attempted to kill init" -- without erasing any user data What is ":-!!" in C code? What is the difference between the kernel space and the user space? What does "make oldconfig" do exactly in the Linux kernel makefile? "FATAL: Module not found error" using modprobe

Examples related to operating-system

Context.startForegroundService() did not then call Service.startForeground() Fork() function in C python: get directory two levels up Find Process Name by its Process ID Best way to find os name and version in Unix/Linux platform How to run a program without an operating system? How to make parent wait for all child processes to finish? Get operating system info Running windows shell commands with python What are the differences between virtual memory and physical memory?

Examples related to kernel

How do I convert dmesg timestamp to custom date format? What is the difference between the kernel space and the user space? What is difference between monolithic and micro kernel? What is the difference between the operating system and the kernel? What is the difference between Trap and Interrupt? "FATAL: Module not found error" using modprobe Interpreting segfault messages What is an OS kernel ? How does it differ from an operating system? Linux Process States What is __gxx_personality_v0 for?

Examples related to terminology

The differences between initialize, define, declare a variable What is the difference between a web API and a web service? What does "opt" mean (as in the "opt" directory)? Is it an abbreviation? What's the name for hyphen-separated case? What is Bit Masking? What is ADT? (Abstract Data Type) What exactly are iterator, iterable, and iteration? What is a web service endpoint? What is the difference between Cloud, Grid and Cluster? How to explain callbacks in plain english? How are they different from calling one function from another function?