Operating Systems Principles Introduction

Describe the general organization of a computer system and the role of interrupts
Describe the components in a modern, multiprocessor computer system
Illustrate the transition from user mode to kernel mode
Discuss how operating systems are used in various computing environments
Provide examples of free and open-source operating systems- 描述计算机系统的一般组织结构和中断的作用 - 描述现代多处理器计算机系统的组件 - 说明从用户模式到内核模式的过渡 - 讨论操作系统如何用于各种计算环境 - 提供免费和开源操作系统的示例
What is an Operating System? • A program that acts as an intermediary between a user of a computer and the computer hardware • Operating system goals: • Execute user programs and make solving user problems easier • Make the computer system convenient to use • Use the computer hardware in an efficient manner 操作系统- 在计算机用户和计算机硬件之间起中介作用的程序 - 操作系统的目标: - 执行用户程序,让用户更容易解决问题 - 让计算机系统使用更方便 - 高效使用计算机硬件
Computer System Structure • Computer system can be divided into four components: • Hardware – provides basic computing resources • CPU, memory, I/O devices • Operating system • Controls and coordinates use of hardware among various applications and users • Application programs – define the ways in which the system resources are used to solve the computing problems of the users • Word processors, compilers, web browsers, database systems, video games • Users • People, machines, other computers计算机系统可分为四个部分: - 硬件 - 提供基本计算资源 - 中央处理器、内存、输入/输出设备 - 操作系统 - 控制和协调各种应用程序和用户对硬件的使用 - 应用程序 - 确定使用系统资源解决用户计算问题的方式 - 文字处理器、编译器、网络浏览器、数据库系统、视频游戏 - 用户 - 人、机器、其他计算机

 What Operating-Systems Do • Depends on the point of view • Users want convenience, ease of use and good performance • Don’t care about resource utilization • But shared computer such as mainframe or minicomputer must keep all users happy • Operating system is a resource allocator and control program making efficient use of HW and managing execution of user programs • Users of dedicated systems such as workstations have dedicated resources but frequently use shared resources from servers • Mobile devices like smartphones and tablets are resource poor, optimized for usability and battery life • Mobile user interfaces such as touch screens, voice recognition • Some computers have little or no user interface, such as embedded computers in devices and automobiles • Run primarily without user intervention操作系统的作用 - 取决于观点 - 用户需要方便、易用和良好的性能 - 不关心资源利用率 - 但共享计算机(如大型机或微型机)必须让所有用户满意 - 操作系统是资源分配器和控制程序,可有效利用硬件并管理用户程序的执行 - 专用系统(如工作站)的用户拥有专用资源,但经常使用服务器的共享资源 - 智能手机和平板电脑等移动设备资源贫乏、 移动用户界面,如触摸屏、语音识别 - 有些计算机几乎没有或根本没有用户界面,如设备和汽车中的嵌入式计算机 - 主要在没有用户干预的情况下运行

Defining Operating-Systems • Term OS covers many roles • Because of myriad designs and uses of OSes • Present in toasters through ships, spacecraft, game machines, TVs and industrial control systems • Born when fixed use computers for military became more general purpose and needed resource management and program control

Operating-System Definition • No universally accepted definition • “Everything a vendor ships when you order an operating system” is a good approximation (but varies wildly). • “The one program running at all times on the computer” is the kernel, part of the operating system • Everything else is either • A system program (ships with the operating system, but not part of the kernel) , or • An application program, all programs not associated with the operating system • Today’s OSes for general purpose and mobile computing also include middleware – a set of software frameworks that provide additional services to application developers such as databases, multimedia, graphics 计算机上始终运行的一个程序 "是内核,操作系统的一部分 - 其他所有程序要么是 - 系统程序(随操作系统一起提供,但不是内核的一部分),要么是 - 应用程序,与操作系统无关的所有程序 - 如今的通用和移动计算操作系统还包括中间件 - 一套软件框架,为应用程序开发人员提供额外服务,如数据库、多媒体、图形等

What Happens When a Computer is Powered Up? When computer is powered up, a bootstrap program executes. Bootstrap program is usually stored in a ROM/EEPROM on the motherboard, and the bootstrap program 1. loads the operating-system kernel into the main memory 2. lets the CPU executes the kernel. 计算机启动时,会执行引导程序。 引导程序通常存储在主板上的 ROM/EEPROM 中,引导程序 1.将操作系统内核加载到主内存中 2.让 CPU 执行内核。Some systems may adopt complex power-up processes e.g. bootstrap program loads a bootloader program, and the bootloader program can do more jobs before loading the kernel 有些系统可能会采用复杂的开机过程,例如引导程序会加载引导加载程序,引导加载程序在加载内核之前可以完成更多工作。

What Happens When a Computer is Powered Up? (Cont.) Once the operating-system kernel is executing, it 3. loads some other components of the operating system like the hardware drivers (including kernel interrupt-driver), system daemons (i.e. services provided outside of the kernel), and system programs 4. loads graphic interface program to provide user a graphic interface, or just stop (stay at a command line environment) 5. waits for user input.操作系统内核执行后,3.会加载操作系统的其他组件,如硬件驱动程序(包括内核中断驱动程序)、系统守护进程(即内核外提供的服务)和系统程序 4. 加载图形界面程序,为用户提供图形界面,或直接停止(停留在命令行环境) 5. 等待用户输入。

Interrupts Interrupts provide a mechanism to stop what the CPU is doing and immediately transfer execution to a fixed location. • All the user inputs, hardware/software errors, and other exceptions trigger interrupts.中断提供了一种机制,可以停止 CPU 正在进行的工作,并立即将执行转移到一个固定位置。 - 所有用户输入、硬件/软件错误和其他异常都会触发中断。 • When a CPU receives an interrupt, the CPU stops what it is doing, and transfers to the interrupt response program to react with the interrupt e.g. to respond to user input. • When the interrupt response program is complete, the CPU goes back to continue the previous program.当 CPU 收到中断时,CPU 会停止正在进行的工作,并转到中断响应程序对中断做出反应,例如响应用户输入。 - 中断响应程序完成后,CPU 返回继续执行前一个程序

Interrupt Types • Hardware interrupt by one of the devices: • User input • Hardware error 中断类型 - 由某个设备发出的硬件中断: - 用户输入 - 硬件错误•• Software interrupt (exception or trap): Software error (e.g., division by zero) • Request for operating system service – system call • Other process problems include infinite loop, processes modifying each other or the operating system软件中断(异常或陷阱): - 软件错误(如除以零) - 请求操作系统服务 - 系统调用 - 其他进程问题包括无限循环、进程相互修改或操作系统

Multitasking (Timesharing) One of the most important aspects of operating systems is the ability to run multiple programs (a program in execution is termed a process). Timesharing is to achieve this. The idea is: the CPU executes multiple processes by switching among them, but the switches occur frequently, so the user feels that multiple programs are running at the same time.多任务(分时运行 操作系统最重要的功能之一是运行多个程序(执行中的程序称为进程)的能力。) 分时运行就是为了实现这一目标。其原理是:CPU 通过在多个进程间切换来执行多个进程,但切换的频率很高,因此用户会感觉到多个程序在同时运行。Dual-mode Operation • Modern CPUs supports Dual-mode operation i.e. user mode and kernel mode. This allows OS to protect itself and other system components. 双模式运行 - 现代 CPU 支持双模式运行,即用户模式和内核模式。这允许操作系统保护自身和其他系统组件。• In user mode, a program can only access the memory allocated to itself. In kernel mode, a program can access the whole memory including the memory allocated to other programs. 在用户模式下,程序只能访问分配给自己的内存。在内核模式下,程序可以访问整个内存,包括分配给其他程序的内存。 • In a CPU, there is mode bit (a register), specifying which mode is using.在 CPU 中,有一个模式位(寄存器),用于指定正在使用的模式。

Dual-mode Operation (Cont.) • Operating-system is working in kernel mode, so it can allocate memory to programs.操作系统在内核模式下运行,因此可以为程序分配内存。 • User programs are in user mode, so programs do not interfere with each other. • Interrupt response programs are in kernel mode, so when an interrupt is triggered, the mode is changed to kernel. When come back to the previous program, the mode changes back to user.用户程序处于用户模式,因此程序不会相互干扰。 - 中断响应程序处于内核模式,因此当中断被触发时,模式将变为内核模式。当回到前一个程序时,模式又变回用户模式。Storage Structure • Main memory – only large storage media that the CPU can access directly • Random access • Typically volatile • Typically random-access memory in the form of Dynamic Random-access Memory (DRAM) 主存储器 - CPU 可直接存取的唯一大型存储介质 - 随机存取 - 通常为易失性存储器 - 通常为动态随机存取存储器 (DRAM) 形式的随机存取存储器 - • Secondary storage – extension of main memory that provides large nonvolatile storage capacity二级存储 - 主存储器的扩展,提供大型非易失性存储容量

Storage Structure (Cont.) • Hard Disk Drives (HDD) – rigid metal or glass platters covered with magnetic recording material • Disk surface is logically divided into tracks, which are subdivided into sectors • The disk controller determines the logical interaction between the device and the computer 硬盘驱动器 (HDD) - 硬质金属或玻璃盘,表面覆盖磁性记录材料 - 磁盘表面在逻辑上被划分为磁道,磁道又被划分为扇区 - 磁盘控制器决定设备与计算机之间的逻辑交互 • Non-volatile memory (NVM) devices– faster than hard disks, nonvolatile • Various technologies • Becoming more popular as capacity and performance increases, price drops非易失性存储器 (NVM) 设备 - 速度比硬盘快,非易失性 - 各种技术 - 随着容量和性能的提高以及价格的下降,越来越受欢迎

Storage Hierarchy • Storage systems organized in hierarchy • Speed • Cost • Volatility存储层次结构 - 按层次结构组织的存储系统 - 速度 - 成本 - 波动性 • Caching – copying information into faster storage system; main memory can be viewed as a cache for secondary storage缓存 - 将信息复制到速度更快的存储系统中;主存储器可视为二级存储的缓存 • Device Driver for each device controller to manage I/O • Provides uniform interface between controller and kernel 每个设备控制器的设备驱动程序,用于管理 I/O - 提供控制器与内核之间的统一接口Direct Memory Access Structure • Used for high-speed I/O devices able to transmit information at close to memory speeds • Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention • Only one interrupt is generated per block, rather than the one interrupt per byte直接内存访问结构 - 用于高速 I/O 设备,能以接近内存的速度传输信息 - 设备控制器将数据块从缓冲存储器直接传输到主存储器,无需 CPU 干预 - 每个数据块只产生一个中断,而不是每个字节产生一个中断

Process Management • A process is a program in execution. It is a unit of work within the system. Program is a passive entity; process is an active entity. 流程管理 - 流程是执行中的程序。它是系统中的一个工作单位。程序是被动的实体,进程是主动的实体。• Process needs resources to accomplish its task e.g. CPU, memory, I/O, files, and Initialization data • Process termination requires reclaim of any reusable resources • Single-threaded process has one program counter specifying location of next instruction to execute • Process executes instructions sequentially, one at a time, until completion • Multi-threaded process has one program counter per thread - 进程需要资源来完成任务,如 CPU、内存、I/O、文件和初始化数据 - 进程终止需要回收任何可重复使用的资源 - 单线程进程有一个程序计数器,指定下一条要执行指令的位置 - 进程按顺序执行指令,一次执行一条,直至完成 - 多线程进程每个线程有一个程序计数器 -• Typically system has many processes, some user, some operating system running concurrently on one or more CPUs • Concurrency by multiplexing the CPUs among the processes / threads通常系统有许多进程,有些是用户进程,有些是在一个或多个 CPU 上并发运行的操作系统进程 - 通过在进程/线程之间复用 CPU 来实现并发性

Process Management Activities The operating-system is responsible for the following activities in connection with process management: • Creating and deleting both user and system processes • Suspending and resuming processes • Providing mechanisms for process synchronization • Providing mechanisms for process communication • Providing mechanisms for deadlock handling进程管理活动 操作系统负责以下与进程管理相关的活动: - 创建和删除用户进程和系统进程 - 暂停和恢复进程 - 提供进程同步机制 - 提供进程通信机制 - 提供死锁处理机制

File-system Management • OS provides uniform, logical view of information storage • Abstracts physical properties to logical storage unit - file • Each medium is controlled by device (i.e., disk drive, tape drive) • Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random) 操作系统为信息存储提供统一的逻辑视图 - 将物理属性抽象为逻辑存储单元 - 文件 - 每种介质由设备(如磁盘驱动器、磁带驱动器)控制 - 不同的属性包括访问速度、容量、数据传输速率、访问方法(顺序或随机) • File-System management • Files usually organized into directories • Access control on most systems to determine who can access what • OS activities include • Creating and deleting files and directories • Primitives to manipulate files and directories • Mapping files onto secondary storage • Backup files onto stable (non-volatile) storage media文件系统管理 - 文件通常组织成目录 - 大多数情况下都有访问控制 文件系统管理 - 文件通常组织成目录 - 在大多数系统中进行访问控制,以确定谁可以访问什么 - 操作系统活动包括 - 创建和删除文件和目录 - 操作文件和目录的基本方法 - 将文件映射到二级存储 - 将文件备份到稳定(非易失)存储介质上

Mass-Storage Management • Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time • Proper management is of central importance • Entire speed of computer operation hinges on disk subsystem and its algorithms大容量存储管理 - 通常磁盘用于存储主存储器无法容纳的数据或必须 "长期 "保存的数据 - 正确的管理至关重要 - 计算机的整个运行速度取决于磁盘子系统及其算法 • OS activities • Mounting and unmounting • Free-space management • Storage allocation • Disk scheduling • Partitioning • Protection 操作系统活动 - 安装和卸载 - 可用空间管理 - 存储分配 - 磁盘调度 - 分区 - 保护

Caching • Important principle, performed at many levels in a computer (in hardware, operating system, software) • Information in use copied from slower to faster storage temporarily 缓存 - 重要原则,在计算机的多个层面(硬件、操作系统、软件)执行 - 使用中的信息从较慢的存储暂时复制到较快的存储• Faster storage (cache) checked first to determine if information is there • If it is, information used directly from the cache (fast) • If not, data copied to cache and used there • Cache smaller than storage being cached • Cache management important design problem • Cache size and replacement policy首先检查较快的存储(缓存)以确定信息是否存在 - 如果存在,直接从缓存使用信息(快速) - 如果不存在,数据复制到缓存并在缓存中使用 - 缓存小于被缓存的存储 - 缓存管理是重要的设计问题 - 缓存大小和替换策略

各类存储特点

Migration of data “A” from Disk to Register • Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy将数据 "A "从磁盘迁移到寄存器 - 多任务环境必须注意使用最新值,无论其存储在存储层次结构的哪个位置• Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache • Distributed environment situation even more complex • Several copies of a datum can exist • Various solutions covered in Chapter 19多处理器环境必须在硬件中提供缓存一致性,以便所有 CPU 的缓存中都有最新的值 - 分布式环境的情况更加复杂 - 一个数据可能存在多个副本

I/O Subsystem • One purpose of OS is to hide peculiarities of hardware devices from the userI/O 子系统 - 操作系统的目的之一是向用户隐藏硬件设备的特殊性 • I/O subsystem responsible for • Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs) • General device-driver interface • Drivers for specific hardware devices I/O 子系统负责 - I/O 的内存管理,包括缓冲(传输数据时暂时存储数据)、缓存(将部分数据存储在速度更快的存储器中以提高性能)、线轴(一个作业的输出与其他作业的输入重叠) - 一般设备驱动程序接口 - 特定硬件设备的驱动程序

Computing Environments • Traditional • Mobile • Client Server • Peer-to-Peer • Cloud computing • Real-time Embedded

Traditional • Stand-alone general-purpose machines • But blurred as most systems interconnect with others (i.e., the Internet) • Portals provide web access to internal systems • Network computers (thin clients) are like Web terminals • Mobile computers interconnect via wireless networks • Networking becoming ubiquitous – even home systems use firewalls to protect home computers from Internet attacks传统 - 独立的通用机器 - 但随着大多数系统与其他系统互联(如互联网)而变得模糊 - 门户网站提供对内部系统的网络访问 - 网络计算机(瘦客户机)就像网络终端 - 移动计算机通过无线网络互联 - 网络变得无处不在 - 甚至家庭系统也使用防火墙来保护家庭计算机免受互联网攻击

Mobile • Handheld smartphones, tablets, etc. • What is the functional difference between them and a “traditional” laptop? • Extra feature – more OS features (GPS, gyroscope) • Allows new types of apps like augmented reality • Use IEEE 802.11 wireless, or cellular data networks for connectivity • Leaders are Apple iOS and Google Android移动 - 手持智能手机、平板电脑等。 - 它们与 "传统 "笔记本电脑在功能上有什么区别? - 额外功能 - 更多操作系统功能(GPS、陀螺仪) - 允许使用增强现实等新型应用程序 - 使用 IEEE 802.11 无线网络或蜂窝数据网络进行连接 - 领先的是苹果 iOS 和谷歌安卓系统

Client Server • Client-Server Computing • Dumb terminals supplanted by smart PCs • Many systems now servers, responding to requests generated by clients • Compute-server system provides an interface to client to request services (i.e., database) • File-server system provides interface for clients to store and retrieve files客户服务器 - 客户服务器计算 - 智能 PC 取代了笨重的终端机 - 许多系统现在都是服务器,响应客户机发出的请求 - 计算机服务器系统为客户机请求服务(如数据库)提供接口 - 文件服务器系统为客户机存储和检索文件提供接口Peer-to-Peer • Peer-to-Peer Another model of distributed system • P2P does not distinguish clients and servers • Instead all nodes are considered peers • May each act as client, server or both • Node must join P2P network • Registers its service with central lookup service on network, or • Broadcast request for service and respond to requests for service via discovery protocol • Examples include Napster and Gnutella, Voice over IP (VoIP) such as Skype点对点 - 分布式系统的另一种模式 - P2P 不区分客户机和服务器 - 相反,所有节点都被视为对等节点 - 每个节点都可以充当客户机、服务器或两者兼而有之 - 节点必须加入 P2P 网络 - 向网络上的中央查找服务注册其服务,或 - 通过发现协议广播服务请求并响应服务请求 - 例如 Napster 和 Gnutella、Skype 等 IP 语音 (VoIP) 系统

Cloud Computing • Delivers computing, storage, even apps as a service across a network • Logical extension of virtualization because it uses virtualization as the base for its functionality. • Amazon EC2 has thousands of servers, millions of virtual machines, petabytes of storage available across the Internet, pay based on usage云计算 - 通过网络提供计算、存储甚至应用程序服务 - 虚拟化的逻辑延伸,因为它使用虚拟化作为其功能的基础。 - 亚马逊 EC2 拥有数千台服务器、数百万台虚拟机、PB 级存储空间,可在互联网上使用,按使用量付费。

Cloud Computing (Cont.) • Many types • Public cloud – available via Internet to anyone willing to pay • Private cloud – run by a company for the company’s own use • Hybrid cloud – includes both public and private cloud components • Software as a Service (SaaS) – one or more applications available via the Internet (i.e., word processor) • Platform as a Service (PaaS) – software stack ready for application use via the Internet (i.e., a database server) • Infrastructure as a Service (IaaS) – servers or storage available over Internet (i.e., storage available for backup use) 多种类型 - 公共云--通过互联网提供给任何愿意付费的人 - 私有云--由公司运行,供公司自己使用 - 混合云--包括公共云和私有云两个部分 - 软件即服务(SaaS)--通过互联网提供一个或多个应用程序(如文字处理器) - 平台即服务(PaaS)--通过互联网提供可用于应用程序的软件栈(如数据库服务器) - 基础设施即服务(IaaS)--通过互联网提供服务器或存储空间(如可用于备份的存储空间)

Cloud Computing (Cont.) • Cloud computing environments composed of traditional OSes, plus VMMs, plus cloud management tools • Internet connectivity requires security like firewalls • Load balancers spread traffic across multiple applications 云计算环境由传统操作系统、VMM 和云管理工具组成 - 互联网连接需要防火墙等安全措施 - 负载平衡器将流量分散到多个应用程序中

Real-Time Embedded Systems • Real-time embedded systems most prevalent form of computers • Vary considerable, special purpose, limited purpose OS, real-time OS • Use expanding • Many other special computing environments as well • Some have OSes, some perform tasks without an OS • Real-time OS has well-defined fixed time constraints • Processing must be done within constraint • Correct operation only if constraints met实时嵌入式系统 - 实时嵌入式系统是最普遍的计算机形式 - 种类繁多,有特殊用途、有限用途操作系统、实时操作系统 - 使用范围不断扩大 - 还有许多其他特殊计算环境 - 有些有操作系统,有些在没有操作系统的情况下执行任务 - 实时操作系统有明确定义的固定时间限制 - 必须在限制范围内进行处理 - 只有满足限制条件才能正确运行

Key points An operating-system is a set of interrelated system software programs that host and control computer operations, utilize and run hardware and software resources, and provide common services to organize user interaction. • Operating-system executes in kernel mode, but user programs execute in user mode. • The CPU executes multiple processes by switching among them, but the switches occur frequently.操作系统是一组相互关联的系统软件程序,用于主持和控制计算机操作、利用和运行硬件和软件资源,以及提供组织用户交互的通用服务。 - 操作系统在内核模式下执行,但用户程序在用户模式下执行。 - 中央处理器通过在多个进程间切换来执行多个进程,但切换频繁。

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-24 09:42:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-24 09:42:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-24 09:42:03       87 阅读
  4. Python语言-面向对象

    2024-03-24 09:42:03       96 阅读

热门阅读

  1. 24计算机考研调剂 | 江西理工大学

    2024-03-24 09:42:03       42 阅读
  2. 日志收集监控告警平台的选型思考

    2024-03-24 09:42:03       38 阅读
  3. Github 2024-03-24 开源项目日报Top10

    2024-03-24 09:42:03       39 阅读
  4. 数据库第一次作业

    2024-03-24 09:42:03       36 阅读
  5. Ubuntu添加硬盘

    2024-03-24 09:42:03       41 阅读
  6. SQL Server 的日志文件占满硬盘时处理方法

    2024-03-24 09:42:03       34 阅读