User space and kernel space

(Redirected fromUser space)

A modern computeroperating systemusually usesvirtual memoryto provide separate address spaces or separate regions of a single address space, calleduser space and kernel space.[1][a]Primarily, this separation serves to providememory protectionand hardware protection from malicious or errant software behaviour.

Kernel space is strictly reserved for running a privilegedoperating system kernel,kernel extensions, and mostdevice drivers.In contrast, user space is the memory area whereapplication softwareand some drivers execute, typically one address space per process.

Overview

edit

The termuser space(oruserland) refers to all code that runs outside the operating system's kernel.[2]User space usually refers to the various programs andlibrariesthat the operating system uses to interact with the kernel: software that performsinput/output,manipulatesfile systemobjects,application software,etc.

Each user spaceprocessnormally runs in its ownvirtual memoryspace, and, unless explicitly allowed, cannot access the memory of other processes. This is the basis formemory protectionin today's mainstream operating systems, and a building block forprivilege separation.A separate user mode can also be used to build efficient virtual machines – seePopek and Goldberg virtualization requirements.With enough privileges, processes can request the kernel to map part of another process's memory space to its own, as is the case fordebuggers.Programs can also requestshared memoryregions with other processes, although other techniques are also available to allowinter-process communication.

Various layers within Linux, also showing separation between theuserlandandkernel space
User mode User applications bash,LibreOffice,GIMP,Blender,0 A.D.,Mozilla Firefox,...
System components init daemon:
OpenRC,runit,systemd...
System daemons:
polkitd,smbd,sshd,udevd...
Window manager:
X11,Wayland,SurfaceFlinger(Android)
Graphics:
Mesa,AMD Catalyst,...
Other libraries:
GTK,Qt,EFL,SDL,SFML,FLTK,GNUstep,...
C standard library fopen,execv,malloc,memcpy,localtime,pthread_create... (up to 2000subroutines)
glibcaims to be fast,muslaims to be lightweight,uClibctargets embedded systems,bionicwas written forAndroid,etc. All aim to bePOSIX/SUS-compatible.
Kernel mode Linux kernel stat,splice,dup,read,open,ioctl,write,mmap,close,exit,etc. (about 380 system calls)
The Linux kernelSystem Call Interface(SCI), aims to bePOSIX/SUS-compatible[3]
Process schedulingsubsystem IPCsubsystem Memory managementsubsystem Virtual filessubsystem Networking subsystem
Other components:ALSA,DRI,evdev,klibc,LVM,device mapper,Linux Network Scheduler,Netfilter
Linux Security Modules:SELinux,TOMOYO,AppArmor,Smack
Hardware (CPU,main memory,data storage devices,etc.)

Implementation

edit

The most common way of implementing auser modeseparate fromkernel modeinvolves operating systemprotection rings. Protection rings, in turn, are implemented usingCPU modes. Typically, kernel space programs run inkernel mode,also calledsupervisor mode; normal applications in user space run in user mode.

Some operating systems aresingle address space operating systems—they have a single address space for all user-mode code. (The kernel-mode code may be in the same address space, or it may be in a second address space). Other operating systems have a per-process address space, with a separate address space for each user-mode process.

Another approach taken in experimental operating systems is to have a singleaddress spacefor all software, and rely on a programming language's semantics to make sure that arbitrary memory cannot be accessed – applications cannot acquire anyreferencesto the objects that they are not allowed to access.[4][5]This approach has been implemented inJXOS,Unununium as well as Microsoft'sSingularityresearch project.

See also

edit

Notes

edit
  1. ^Older operating systems, such asDOSandWindows 3.1x,do not use this architecture.

References

edit
  1. ^"Address space".Address space options for 32bit systems.
  2. ^"userland, n."TheJargon File.Eric S. Raymond.Retrieved2016-08-14.
  3. ^"Admin Guide README".Kernel.org git repositories.
  4. ^"Unununium System Introduction".Archived fromthe originalon 2001-12-15.Retrieved2016-08-14.
  5. ^"uuu/docs/system_introduction/uuu_intro.tex".UUU System Introduction Guide.2001-06-01.Retrieved2016-08-14.
edit