经典书籍翻译——深入理解Linux内核19

The operating system must fulfill two main objectives:
• Interact with the hardware components, servicing all low-level programmable elements included in the hardware platform.
• Provide an execution environment to the applications that run on the computer system (the so-called user programs).
Some operating systems allow all user programs to directly play with the hardware components (a typical example is MS-DOS). In contrast, a Unix-like operating system hides all low-level details concerning the physical organization of the computer from applications run by the user. When a program wants to use a hardware resource, it must issue a request to the operating system. The kernel evaluates the request and, if it chooses to grant the resource, interacts with the proper hardware components on behalf of the user program.
To enforce this mechanism, modern operating systems rely on the availability of specific hardware features that forbid user programs to directly interact with lowlevel hardware components or to access arbitrary memory locations. In particular, the hardware introduces at least two different execution modes for the CPU: a nonprivileged mode for user programs and a privileged mode for the kernel. Unix calls these User Mode and Kernel Mode, respectively.

操作系统必须实现两个主要目标:
1.与硬件组件实现交互,为硬件平台中所有底层可编程元件提供服务。
2.为运行在计算机系统中的程序(所谓的用户程序)提供一个执行环境。
有些操作系统允许所有的用户程序直接操作硬件组件(典型的例子就是MS-DOS);相反,类Unix操作系统隐藏了用户运行的程序中有物理设备中所有的底层细节。当一个程序想用底层资源的时候,它必须向操作系统发出请求,操作系统评估该请求,如果内核允许访问该硬件资源,那么该用户程序就可以通过相应的硬件组件进行交互。
为了强化这种机制,现代操作系统依赖于特定硬件功能的实现,这些功能进制用户程序直接与底层硬件交互或者任意访问内存地址。典型场景是,硬件引入至少两种不同的CPU运行模式:用户程序运行的非特权模式和内核运行的特权模式,Unix将其称为用户态和内核态。

猜你喜欢

转载自blog.csdn.net/m0_37546257/article/details/121410781
今日推荐