《现代操作系统》- 1.1 什么是操作系统

We all have experience with an operating system such as Windows, Linux, OS X, or FreeBSD, but appearance can be deceiving!

The program that users interact with is actually not part of the operating system.

It is usually called the shell when it is text-based.

                             the GUI (Graphical User Interface) when it uses icons.

【以上内容总结】我们以为我们是在和操作系统打交道,而实际上作为用户,我们是在和shell以及GUI打交道(这俩并不是操作系统)

两种模式

Most computers have two modes of operation:kernel mode & user mode.

The difference between the two modes plays a crucial role in how operating systems work.

1. Kernel mode

The operating system(the most fundamental piece of software)runs in kernel mode. In this mode, the operating system has complete access to all the hardware and can execute any instruction the machine is capable of executing.

2. User mode

The rest of the software runs in user mode, in which only a subset of the machine instructions is available. Those instructions that affect control of the machine or do I/O are forbidden to user-mode.

The user interface program, shell or GUI, is the lowest level of user-mode software and allows users to start other programs such as a Web browser, email reader or music player.

【以上内容总结】明确两个概念:kernel mode 和 user mode。kernel mode就是OS所在的地方,其他所有的软件都在user mode里。前面提到的shell和GUI,是位于user mode里的最底层,它们让用户能够运行其他软件。

1.1.1 操作系统就像是机器的延伸

The architecture(instruction set, memory organization, I/O, and bus structure)of most computers at the machine-language level is primitive and awkward to program, especially for input/output. To make this point more concrete, consider modern SATA (Serial ATA) hard disks used on most computers. No sane programmer would want to deal with this disk at the hard ware level. Instead, a piece of software, called a disk driver, deals with the hard ware and provides an interface to read and write disk blocks, without getting into the details. Operating systems contain many drivers for controlling I/O devices. But even this level is much too low for most applications. For this reason, all operating systems provide yet another layer of abstraction for using disks: files. Using this abstraction, programs can create, write, and read files, without having to deal with the messy details of how the hardware actually works.

【以上内容总结】

计算机硬件编程的复杂性:计算机在底层(机器语言层面)的体系结构(包括指令集、内存组织、输入输出和总线结构)非常原始且难以编程。尤其是涉及到输入输出操作时,这种编程会变得非常复杂和不方便。

SATA 硬盘的例子及驱动程序的作用:SATA(Serial ATA)是现代计算机中使用的一种硬盘接口标准,但如果程序员直接在硬件层面操作硬盘,工作量和复杂性是非常巨大的。由于直接操作硬件太复杂,没有人愿意在这种底层进行编程,为了解决这个问题,有一类软件叫做驱动程序(例如硬盘驱动程序),它负责与硬件交互。

驱动程序提供了一个更简单的接口,程序员可以通过这个接口进行读写磁盘块等操作,而无需了解底层的复杂细节。操作系统中包含了许多这样的驱动程序,用于控制各种输入输出设备(例如硬盘、打印机、显示器等)。

But even this level is much too low for most applications. For this reason, all operating systems provide yet another layer of abstraction for using disks: files. Using this abstraction, programs can create, write, and read files, without having to deal with the messy details of how the hardware actually works. This abstraction is the key to managing all this complexity.

The job of the operating system is to create good abstractions and then implement and manage the abstract objects thus created. In this book, we will talk a lot about abstractions. They are one of the keys to understanding operating systems.

【以上内容总结】

进一步解释操作系统如何通过抽象层来简化对复杂硬件的使用,并强调抽象的重要性。

尽管驱动程序已经简化了硬件操作,但对于大多数应用程序来说,这仍然不够简便。因此,所有操作系统都会提供另一层抽象,用于管理磁盘:文件。通过文件抽象,程序可以创建、写入和读取文件,而无需处理硬件的复杂细节。例如,用户可以直接处理照片、电子邮件、歌曲或网页,而不需要知道这些数据是如何存储在SATA(或其他)磁盘上的。

操作系统的职责之一就是创建和管理这些抽象,以便用户和应用程序可以方便地使用硬件,而不需要处理底层的复杂细节。理解这些抽象是学习和理解操作系统的重要部分。

It should be noted that the operating system’s real customers are the application programs (via the application programmers, of course). They are the ones who deal directly with the operating system and its abstractions. In contrast, end users deal with the abstractions provided by the user interface, either a command-line shell or a graphical interface. While the abstractions at the user interface may be similar to the ones provided by the operating system, this is not always the case.

【以上内容总结】真正和OS及其抽象层打交道的是写应用程序的程序员,终端用户只是和UI(用户界面)的抽象层打交道,这两个抽象层不是一回事。

1.1.2 操作系统就像是资源管理者

The concept of an operating system as primarily providing abstractions to application programs is a top-down view. In the bottom-up view, the job of the operating system is to provide for an orderly and controlled allocation of the processors, memories, and I/O devices among the various programs wanting them.

In short, this view of the operating system holds that its primary task is to keep track of which programs are using which resource, to grant resource requests, to account for usage, and to mediate conflicting requests from different programs and users.

Resource management:Time multiplex & Space multiplex

Time multiplex:When a resource is time multiplexed, different programs or users take turns using it. Determining how the resource is time multiplexed—who goes next and for how long—is the task of the operating system.

Space multiplex:Each one gets part of the resource instead of the customers taking turns. For example, main memory is normally divided up among several running programs, so each one can be resident at the same time (for example, in order to take turns using the CPU). Of course, this raises issues of fairness, protection, and so on, and it is up to the operating system to solve them.

Another resource that is space multiplexed is the disk. In many systems a single disk can hold files from many users at the same time. Allocating disk space and keeping track of who is using which disk blocks is a typical operating system task.

【以上内容总结】

从bottom-up的角度看,OS就是资源管理器,它有Time multiplex(时间复用) & Space multiplex(空间复用)两种方式管理资源。Time multiplex是去决策不同的程序如何轮流使用资源,Space multiplex是在多种程序同时使用资源时,OS去决定如何分配资源。

  • 22
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值