📜  用户模式和内核模式的区别

📅  最后修改于: 2022-05-13 01:56:11.396000             🧑  作者: Mango

用户模式和内核模式的区别

用户模式:当程序在操作系统上启动时,比方说 windows,然后它以用户模式启动程序。当用户模式程序请求运行时,windows 会为其创建一个进程和虚拟地址空间(该进程的地址空间)。用户模式程序的特权较少,即不允许用户模式应用程序直接访问系统资源。例如,如果用户模式下的应用程序想要访问系统资源,它必须首先使用系统调用通过操作系统内核。

内核模式:内核是所有其他操作系统组件所依赖的核心程序,它用于访问硬件组件并调度计算机系统上应该运行哪些进程以及何时运行,它还管理应用软件和硬件的交互.因此,它是特权最高的程序,与其他程序不同,它可以直接与硬件交互。当在用户模式下运行的程序需要硬件访问(例如网络摄像头)时,首先它必须使用系统调用通过内核,为了执行这些请求,CPU 在执行时从用户模式切换到内核模式。在最终完成进程执行后,CPU 再次切换回用户模式。

用户与内核模式

用户与内核模式

内核模式和用户模式的区别:

Criteria

Kernel Mode

User Mode

Kernel-mode vs User modeIn kernel mode, the program has direct and unrestricted access to system resources.In user mode, the application program executes and starts out.
InterruptionsIn Kernel mode, the whole operating system might go down if an interrupt occursIn user mode, a single process fails if an interrupt occurs.  
ModesKernel mode is also known as the master mode, privileged mode, or system mode.User mode is also known as the unprivileged mode, restricted mode, or slave mode.
Virtual address spaceIn kernel mode, all processes share a single virtual address space.In user mode, all processes get separate virtual address space.
Level of privilegeIn kernel mode, the applications have more privileges as compared to user mode.While in user mode the applications have fewer privileges.
RestrictionsAs kernel mode can access both the user programs as well as the kernel programs there are no restrictions.While user mode needs to access kernel programs as it cannot directly access them.
Mode bit valueThe mode bit of kernel-mode is 0.While; the mode bit of user-mode is 1.