1.4 Basic Operating System Concepts
基本的操作系统概念
Each computer system includes a basic set of PRograms called the operating system. The most important program in the set is called the kernel. It is loaded into RAM when the system boots and contains many critical procedures that are needed for the system to operate. The other programs are less crucial utilities; they can provide a wide variety of interactive experiences for the user—as well as doing all the jobs the user bought the computer for—but the essential shape and capabilities of the system are determined by the kernel. The kernel provides key facilities to everything else on the system and determines many of the characteristics of higher software. Hence, we often use the term "operating system" as a synonym for "kernel."
任何一个计算机系统都包含一个基本的程序集,又称为操作系统。在这个程序集中最重要的程序叫做kernel(内核)。当系统引导时,内核就被装进RAM,它还包含许多能够让系统运行起来的关键规程;其它的程序相对来说并不是非常的重要;它们能为用户提供各种各样的交互式体验----做这些工作也是用户购买计算机的原因;但是内核决定了系统的本质形态以及做这些工作的能力;内核不仅为计算机系统提供关键设备资源,而且也决定着高层软件的特征。因此,我们常用“操作系统“这个术语来代替”kernel(内核)“ ;
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 relative hardware components on behalf of the user program.
许多操作系统允许用户程序直接的利用硬件部件;(一个典型的例子是MS-DOS)相反,类Unix系统隐藏了来自于用户程序所涉及到的计算机物理组织的所有底层细节;但当一个程序想使用硬件资源时,它必须发送一个请求给操作系统;内核评估这个请求,如果相关的硬件部件支持用户程序,内核就分配资源;
To enforce this mechanism, modern operating systems rely on the availability of specific hardware features that forbid user programs to directly interact with low-level 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.
为了这种机制的实施,现在的操作系统依赖于指定硬件可选件的有效性,如禁止用户程序直接和底层硬件部件相结合或者是禁止用户程序任意的存取内存单元.特别提出CPU至少要有两种不同的执行模式:一种用户程序使用的非特权模式和一种内核使用的特权模式;Unix分别称它们为用户模式和内核模式;
In the rest of this chapter, we introduce the basic concepts that have motivated the design of Unix over the past two decades, as well as linux and other operating systems. While the concepts are probably familiar to you as a Linux user, these sections try to delve into them a bit more deeply than usual to explain the requirements they place on an operating system kernel. These broad considerations refer to virtually all Unix-like systems. The other chapters of this book will hopefully help you understand the Linux kernel internals.
在这一章的最后,我们介绍一些基本概念,这些概念在过去的二十年间推动了像Linux,Unix和其它一些操作系统的设计.作为一个Linux的用户,你也许相当熟悉这些概念,这些部分试图钻研一下这些概念,以便解释它们在一个操作系统内核上放置了那些需求;这些概念的考虑涉及到了所有的类Unix系统.而这本书的其它章希望能帮助你理解Linux内核的内部构件;
1.4.1 Multiuser Systems
多任务系统
A multiuser system is a computer that is able to concurrently and independently execute several applications belonging to two or more users. Concurrently means that applications can be active at the same time and contend for the various resources such as CPU, memory, hard disks, and so on. Independently means that each application can perform its task with no concern for what the applications of the other users are doing. Switching from one application to another, of course, slows down each of them and affects the response time seen by the users. Many of the complexities of modern operating system kernels, which we will examine in this book, are present to minimize the delays enforced on each program and to provide the user with responses that are as fast as possible.
一个多任务系统是一个能够同时并且独立的执行属于两个和多个用户的应用程序的计算机. 同时,意味着几个应用程序能在同一时间处于执行态,并且能够竞争诸如CPU,内存,硬磁盘等多种资源;独立意味着每一个应用程序能完成它的工作而无需考虑其它用户的应用程序正在做些什么;当然,从一个应用程序切换到另一个应用程序,会减慢它们的速度并且影响到达用户的响应时间.当代的操作系统内核是非常复杂的,它们尽可能的减少每一个应用程序的延迟以及为用户提供尽可能快的响应时间.我们将在这本书中考察这些知识;
Multiuser operating systems must include several features:
多任务操作系统必须包括的几个特征:
· An authentication mechanism for verifying the user's identity
认证机制,用来检验用户身份
· A protection mechanism against buggy user programs that could block other applications running in the system
保护机制,防止出错的用户程序阻碍在系统中其它应用程序的运行;
· A protection mechanism against malicious user programs that could interfere with or spy on the activity of other users
保护机制,阻止恶意的用户程序妨碍或者监视其它用户的活动
· An accounting mechanism that limits the amount of resource units assigned to each user
计数机制,限制分配给每个用户的资源单元数目
To ensure safe protection mechanisms, operating systems must use the hardware protection associated with the CPU privileged mode. Otherwise, a user program would be able to directly access the system circuitry and overcome the imposed bounds. Unix is a multiuser system that enforces the hardware protection of system resources.
为了保证能实现这些安全保护机制,操作系统必须使用和硬件保护关联的CPU特权模式.否则,用户程序将能够自己存取系统电路并且克服这些强加的限制;Unix是一个实施系统资源硬件保护的多任务系统;
新闻热点
疑难解答