Operating System Concepts 9th: Chapter 2 Operating-System Structures
  MeCJUetuLnDP 2024年03月29日 46 0

Operating-System Services

An operating system provides an environment for the execution of programs.

操作系统提供程序运行的环境,如下图。

System Calls

System calls provide an interface to the services made available by an operating
system.

系统调用是获取操作系统服务的接口。

以open为例,系统调用的过程

System calls can be grouped roughly into six major categories: process
control, file manipulation, device manipulation, information maintenance,
communications, and protection.

系统调用分为六大类:进程控制,文件操作,设备操作,信息维护,通信,保护。

Operating-System Structure

Simple Structure

Everything below the system-call interface and above the physical hardware
is the kernel. The kernel provides the file system, CPU scheduling, memory
management, and other operating-system functions through system calls. Taken
in sum, that is an enormous amount of functionality to be combined into one
level. This monolithic structure was difficult to implement and maintain. It
had a distinct performance advantage, however: there is very little overhead
in the system call interface or in communication within the kernel.

简单结构的操作系统中,所有系统调用层之下、物理硬件层之上的都被归为内核,包括文件系统,CPU调度,内存管理和其他操作系统功能,使得内核层很难实现和维护,但因为内核进程间通信开销很小,使得这种结构有很好的性能。传统UNIX采用的是这种结构。

Layered Approach

A system can be made modular in many ways. One method is the layered
approach, in which the operating system is broken into a number of layers
(levels).

分层结构将操作系统分为多个层次。

The main advantage of the layered approach is simplicity of construction
and debugging.The layers are selected so that each uses functions (operations)
and services of only lower-level layers.

分层结构方便调试。每个层次只能使用低层提供的服务,只要保证低层调试好了就可以保证高层使用服务时的正确性,高层调试时不用管其他层,降低了调试的难度。

Each layer is implemented only with operations provided by lower-level
layers. A layer does not need to know how these operations are implemented;
it needs to know only what these operations do.

每个层次都直接使用低层的服务,而不需要知道这些服务是怎么实现的,保证了封装性。

The major difficulty with the layered approach involves appropriately
defining the various layers.

分层结构的主要困难是怎么定义各层。

A final problem with layered implementations is that they tend to be less
efficient than other types.

分层结构性能较低。由于各层次之间需要一层一层地向下调用,所以开销比较大,性能较低。

Microkernels

the microkernel approach structures the operating system by removing all
nonessential components from the kernel and implementing them as system and
user-level programs.

微内核将非必要的部分从内核中移到系统程序和用户程序层里。

The main function of the microkernel is to provide communication between
the client program and the various services that are also running in user space.
Communication is provided through message passing,if the client program wishes
to access a file, it must interact with the file server. The client program and
service never interact directly. Rather, they communicate indirectly by exchanging
messages with the microkernel.

微内核主要需要实现的功能是用户进程与其他运行在用户空间的系统服务之间的通信,他们不能直接通信,所以需要通过内核传递消息。

One benefit of the microkernel approach is that it makes extending
the operating system easier. All new services are added to user space and
consequently do not require modification of the kernel. When the kernel does
have to be modified, the changes tend to be fewer, because the microkernel is
a smaller kernel.

微内核更易扩展。由于微内核的系统服务在用户空间实现,因此需要新的服务只需要将他们添加到用户空间即可。此外由于内核较小,要修改内核也更容易。

Unfortunately, the performance of microkernels can suffer due to increased
system-function overhead.

微内核性能低。由于微内核需要频繁在内核态与用户态间切换,所以性能开销较大。

Modules

The idea of the design is for the kernel to provide core services while
other services are implemented dynamically, as the kernel is running. Linking
services dynamically is preferable to adding new features directly to the kernel,
which would require recompiling the kernel every time a change was made.

模块化的内核只提供核心服务,其他服务则通过动态链接在内核运行时加载。这样当新加入一个功能时只需要动态链接即可,不需要重新编译整个内核。Linux,Windows,MacOS,Solaris等现代操作系统采用的就是这种方法。

The overall result resembles a layered system in that each kernel section
has defined, protected interfaces; but it is more flexible than a layered system,
because any module can call any other module.

和分层结构类似,模块化也将内核分了各个部分,并且提供了保护实现的接口,但模块化更灵活,因为各模块可以互相调用。

The approach is also similar to the microkernel approach in that the
primary module has only core functions and knowledge of how to load and
communicate with other modules; but it is more efficient, because modules
do not need to invoke message passing in order to communicate.

和微内核类似,模块化也只将核心功能留在内核,但模块化更高效,因为它的进程通信不需要借助内核进行消息传递。

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2024年03月29日 0

暂无评论

推荐阅读
  6S5BTxjoIEHI   2024年03月15日   74   0   0 读书区
MeCJUetuLnDP