What is the difference between user and kernel modes in operating systems?

后端 未结 7 1935
长发绾君心
长发绾君心 2020-12-02 04:31

What are the differences between User Mode and Kernel Mode, why and how do you activate either of them, and what are their use cases?

7条回答
  •  我在风中等你
    2020-12-02 04:56

    What

    Basically the difference between kernel and user modes is not OS dependent and is achieved only by restricting some instructions to be run only in kernel mode by means of hardware design. All other purposes like memory protection can be done only by that restriction.

    How

    It means that the processor lives in either the kernel mode or in the user mode. Using some mechanisms the architecture can guarantee that whenever it is switched to the kernel mode the OS code is fetched to be run.

    Why

    Having this hardware infrastructure these could be achieved in common OSes:

    • Protecting user programs from accessing whole the memory, to not let programs overwrite the OS for example,
    • preventing user programs from performing sensitive instructions such as those that change CPU memory pointer bounds, to not let programs break their memory bounds for example.

提交回复
热议问题