操作系统 Lecture 2操作系统概述(英文)

Chapter 2 OPERATING SYSTEM OVERVIEW

2.1 Operating System Objectives and Functions

An OS is a program that controls the execution of application programs, and acts as an interface between applications and the computer hardware.

  1. Convenience
  2. Efficiency
  3. Ability to evolve

The operating System as a User/Computer Interface

The most important collection of system programs comprises the OS. The OS masks the details of the hardware from the programmer, and provides the programmer with a convenient interface for using the system.

Briefly, the OS typically provides services in the following areas:

  1. Program development
  2. Program execution
  3. Access to I/O devices
  4. Controlled access to files
  5. System access
  6. Error detection and response
  7. Accounting
  8. Instruction set architecture (ISA): The ISA defines the repertoire of machine language instructions that a computer can follow.
  9. Application binary interface (ABI): The ABI defines a standard for binary portability across programs.
  10. Application programming interface (API): The API gives a program access to the hardware resources and services available in a system through the user ISA suspplemented with high-level language (HLL) library calls.
    [An ABI defines how data structures or computational routines are accessed in machin code, which is a low-level, hardware-dependent format; in contrast, an API defines this access in source code, which is a relatively high-level, relatively hardware-independent.]
    在这里插入图片描述

The Operating System as Resource Manager

The OS is responsible ofr controlling the use of a computer’s resources, such as I/O, main and secondary memory, and processor execution time.

  • The OS functions in the same way as ordinary computer software.
  • The OS frequently relinquishes(放弃) control, and must depend on the processor to allow it to regain control.

在这里插入图片描述

2.2 The Evolution of Operating Systems

  • Serial Processing 串行处理
  • Simple Batch Systems 简单批处理系统
  • Multiprogrammed Batch Systems 多道程序批处理系统
  • Time-Sharing Systems 分时系统

A user program executes in a user mode, in which certain areas of memory are protected from the user’s use, and in which certain instructions may not be executed.
The monitor executes in a system mode, or what has come to be called kernel mode, in which privileged instructions may be executed, and in which protected areas of memory may be accessed.

Multiprogrammed Batch Systems

在这里插入图片描述

Even with the automatic job sequencing provided ny a simple batch OS, the processor is often idle. The problem is I/O devices are slow comoared to the processor.

There must be enough memory to hold the OS (resident monitor) and one user program.
When one job needs to wait for I/O, the processor can switch to the other job.
Furthermore, we might expand memory to hold three, four, or more programs and switch among all of them.
The approach is known as multiprogramming, or multitasking.
It is the central theme of modern operating systems.

The most notable additional feature that is useful for multiprogramming is the hardware that supports I/O interrupts and DMA (direct memory access).
With interrupt-driven I/O or DMA, the processor can issue an I/O command for one job and proceed with the execution of another job while the I/O is carried out by the device controller.
When the I/O operation is complete, the processor is interrupted and control is passed to an interrupt-handling program in the OS.
The OS will then pass control to another job after the interrupt is handled.

Time-Sharing Systems

Processor time is shared among multiple users.--------Time sharing
Multiple users simultaneously access the system through terminals, with the OS interleaving the execution of each user program in a short burst or quantum of computation.

Compatible Time-Sharing System (CTSS)

At each clock interrupt, the OS regained control and could assign the processor to another user. ---------- Time slicing

Thus, at regular time intervals, the current user would be preempted and another user loaded in.

To preserve the old user program status ofr later resumption, the old user programs and data were written out to disk before the new user programs and data were read in. 在读取新程序和数据前,旧程序将会被写入磁盘。
Subsequently, the old user program code and data were restored in main memory when that program was next given a turn. 旧程序和数据读回(恢复)主内存。

2.3 Major Achievements

The Process

  • A program in execution.
  • An instance of a program running on a computer.
  • The entity that can be assigned to and executed on a processor.
  • A unit of actibity characterized by a single sequential thread of execution, a current state, and an associated set of system resources.

Multiprogramming/Multitasking was designed to keep the processor and I/O devices, including storage devices, simultaneously busy to achieve maximum efficiency.

The key mechanism is this: In response to signals indicating the completion of I/O transactions, the processor is switched among the various programs residing in main memory.

Programming errors whose effects could be observed only when certain relatively rare sequences of actions occurred.
Four main causes:

  1. Improper synchronization 同步不当
  2. Failed mutual exclusion 失败的互斥(?)
  3. Nondeterminate program operation 不确定性的程式运作
  4. Deadlocks 死结

A process as consisting of three components:
1. An executable program
2. The associated data needed by the program (variables, work space, buffers, etc.)
3. The execution context of the program

Execution context/Process state: the internal data by which the OS is able to supervise and control the process.
The context includes all of the information the OS needs to manage the process, and the processor needs to execute the process properly.
The context includes the contents of the various processor registers, such as the program counter and data registers. It also includes information of use to the OS, such as the priority of the process and whether the process is waiting for the completion of a particular I/O event.

在这里插入图片描述
A block of memory is allocated to each process that contains the program, data, and context information. Each process is recorded in a process list built and maintained by the OS. The process list contains one entry for each process, which includes a pointer to the location of the block of memory that contains the process. The remainder of the execution context is tored elsewhere, perhaps with the process itself or frequently in a separate region of memory. The program counter points to the next instruction in that process to be executed . The base and limit registers define the region in memory occupied by the process: The base register is the starting address of the region of memory, and the limit is the size of the region.

process switch: save & restore

The entire state of the process at any instant is contained in its context.

new features —> expanding the context

A single process —> broken up into multiple, concurrent threads

Memory Management

Five principal storage management responsibilities:

  1. Process isolation 进程隔离
  2. Automatic allocation and management 自动配置与管理
  3. Support of modular programming 模组化程式设计的支持
  4. Protection and access control 保护与存取控制
  5. Long-term storage 长期的储存空间

Virtual memory is a facility that allows programs to address memory from a logical point of view, without regrad to the amount of main memory physically available.
Virtual memory was conceived to meet the requirement of having multiple user jobs concurrently reside in main memory, so there would not be a hiatus(中断) between the execution of successor processes while one process was written out to secondary store and the successor process was read in.

在这里插入图片描述
Paging systems
Allow processes to be comprised if a number of fixed-size blocks, called pages.

2.4 Developments Leading to Modern Operating Systems

  • Microkernel architecture
  • Multithreading
  • Symmetric multiprocessing
  • Distributed operating systems
  • Object-oriented design

monolithic kernel 宏内核 —> single process (all elements sharing the same address space)

microkernel 微内核

  1. address space management
  2. interprocess communication (IPC)
  3. basic scheduling

Other OS services are provided by processes, sometimes called servers, that run in user mode and are treated like any other aoolication by the microkernel.

Multithreading is a technique in which a process executing an application, is divided into threads that can run concurrently.

Thread: A dispatchable unit of work. It includes a processor context (which includes the program counter and stack pointer) and its own data area for a stack (to enable subroutine branching), A thread executes sequentially and is interruptible so the processor can turn to another thread.

Process: A collection of one or more threads and associated system resources (such as memory containing both code and data, open files, and devices).

14.1 Virtual Machine Concepts

hardware virtualization

Virtualization technology enables a single PC or sever to simultaneously run multiple OSs or multiple sessions of a single OS.

The host OS can support a number of virtual machines(VMs), each of that has the characteristics of a particular OS and, in some versions of virtualization, the characterictics of a particular hardware platform.

Virtual machine monitor (VMM)

2.6 OS Design Considerations for Multiprocessor and Multicore

Symmetric Multiprocessor OS Considerations

A multiprocessor OS must provide all the functionality of a multiprogramming system, plus additional features to accommodate multiple processors.

Key design issues:

  • Simultaneous concurrent processes or threads
  • Scheduling
  • Synchronization
  • Memory management: A physical page can no longer be accessed with its old contents before the page is put to a new use.
  • Reliability and fault tolerance

2.8 Traditional Unix Systems

system calls

User programs can invoke OS services either directly, or through library programs.

在这里插入图片描述
The system call interface is the boundary with the user and allows higher-level software to gain access to specific kernel functions.

System is divided into two main parts: one concerned with process control, and the other concerned with file management and I/O.

The process control subsystem is responsible for memory management, the scheduling and dispatching of processes, and the synchronization and interprocess communication of processes.

The file system exchanges data between memory and external devices.

2.10 Linux

Modular Structure

Linux is structured as a collection of modules, a number of which can be automatically loaded and unloaded on demand. These relatively independent blocks are referred to as loadable modules.

A module is an object file whose code can be linked to and unlinked from the kernel at runtime.

A module implements some specific function, such as a file system, a device driver, or some other feature of the kernel’s upper layer.

A module is executed in kernel mode on behalf of the current process.

Two characteristics:

  • Dynamic linking
  • Stackable module(可被上层当做底层reference,也可被下层当做client)

Kernel Components

All of the components execute on the processor.

在这里插入图片描述
The principal kernel components are the following:

  • Signals: The kernel uses signals to call into a process.
  • System calls: The system call is the means by which a process requests a specific kernel service.
  • Processes and scheduler: Creates, manages, and schedules processes.
  • Virtual memory: Allocates and manage virtual memory for processes.
  • File systems: Provide a global, hierarchical namespace for files, directories, and other file-related objects and provide file system functions.
  • Character device drivers
  • Block device drivers:
  • Network device drivers
  • Traps and faults
  • Physical memory: Manages the pool of page frames in real memory and allocates pages for virtual memory.
  • Interrupts: Handle interrupts from peripheral devices.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值