官术网_书友最值得收藏!

Kernel and user space

Modern operating systems not only prevent one process from accessing another but also prevent processes from accidentally accessing or manipulating kernel data and services (as the kernel is shared by all the processes).

Operating systems achieve this protection by segmenting the whole memory into two logical halves, the user and kernel space. This bifurcation ensures that all processes that are assigned address spaces are mapped to the user space section of memory and kernel data and services run in kernel space. The kernel achieves this protection in coordination with the hardware. While an application process is executing instructions from its code segment, the CPU is operating in user mode. When a process intends to invoke a kernel service, it needs to switch the CPU into privileged mode (kernel mode), which is achieved through special functions called APIs (application programming interfaces). These APIs enable user processes to switch into the kernel space using special CPU instructions and then execute the required services through system calls. On completion of the requested service, the kernel executes another mode switch, this time back from kernel mode to user mode, using another set of CPU instructions.

System calls are the kernel's interfaces to expose its services to application processes; they are also called kernel entry points. As system calls are implemented in kernel space, the respective handlers are provided through APIs in the user space. API abstraction also makes it easier and convenient to invoke related system calls.

The following figure depicts a virtualized memory view:

主站蜘蛛池模板: 贵溪市| 乌兰察布市| 海淀区| 东明县| 弋阳县| 定州市| 马山县| 延吉市| 磴口县| 公安县| 宁都县| 淮滨县| 屏东市| 垫江县| 信阳市| 镇安县| 海安县| 永修县| 尉犁县| 临颍县| 温宿县| 孝昌县| 祁阳县| 柯坪县| 习水县| 噶尔县| 伊通| 东乌珠穆沁旗| 武威市| 东山县| 大余县| 和静县| 简阳市| 十堰市| 武陟县| 瑞丽市| 东兰县| 九江县| 广西| 云龙县| 茌平县|