Operating System Introduction

本文详细阐述了操作系统的作用,包括作为硬件和用户之间的桥梁,执行用户程序,管理硬件资源,以及在传统、移动、客户端/服务器、P2P、云计算和实时嵌入式等不同环境中的应用。还涉及了内核、用户模式、内核模式、中断处理、进程管理和内存管理等关键概念。
摘要由CSDN通过智能技术生成

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

1方便且高性能需求 2利用硬件管理用户程序的执行 3服务器共享资源 4移动设备用户界面 5设备中的嵌入式计算机

Operating-System Definition

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. 

 Once the operating-system kernel is executing, it

3. loads some other components of the operating system like the hardware drivers (including k ernel 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.

 计算机开机 执行存储在主板上的ROM的引导程序 1该程序会将操作系统内核加载到主内存中并让CPU执行内核 2当操作系统内核开始运行,加载操作系统其他组件,eg硬件驱动 系统进程 系统程序 3加载图形界面或者直接中断 并等待用户输入

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.
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返回继续执行原先的程序

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. u ser mode and kernel mode . This allows OS to protect itself and other system components.
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.
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.

 

双模式运行 即用户模式和内核模式 保护操作系统和系统组件
用户模式:程序访问分配给子集的内存 程序之间不会相互干扰
内核模式:程序访问整个内存 操作系统为程序分配内存  中断响应程序处于内核模式(中断被触发时,模式变为内核模式。当返回前一个程序时,模式又变回用户模式)
CPU内有寄存器指定使用的模式

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)
Secondary storage – extension of main memory that provides large nonvolatile storage capacity

 主存储器 CPU可以直接存取的唯一大型存储介质 随机存取 易失 DRAM形式随机存取存储器

第二存储器 主存储器的扩展 有大容量非易失存储空间

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
Non-volatile memory ( NVM ) devices– faster than hard disks, nonvolatile
Various technologies
Becoming more popular as capacity and performance increases, price drops

硬盘 HDD 硬金属或玻璃盘 表面磁性记录材料 分为磁道 在划分为扇区 硬盘控制器决定设备iyu计算机之间的交互

非易失存储器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 干预  每个数据块只产生一个中断,而不是每个字节产生一个中断

Resource Management  

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
•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

进程是执行中的程序 系统中的工作单位 程序是被动的 进程是主动的

进程:需要资源完成任务eg CPU、内存、I/O、文件和初始化数据 终止需要回收可重复使用的资源 按顺序执行指令,一次执行一条

单线程进程有一个程序计数器,指定下一条要执行指令的位置  多线程进程每个线程有一个程序计数器 在进程/线程之间多路复用 CPU 来实现并发性

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

Memory Management

To execute a program all (or part) of the instructions must be in memory
All  (or part) of the data that is needed by the program must be in memory
Memory management determines what is in memory and when
Optimizing CPU utilization and computer response to users
Memory management activities
Keeping track of which parts of memory are currently being used and by whom
Deciding which processes (or parts thereof) and data to move into and out of memory
Allocating and deallocating memory space as needed

 执行程序需要部分指令和所需部分数据在内存中 内存管理决定内存的内容和实践优化CPU利用老板和计算机响应 

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

Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache

I/O Subsystem 

One purpose of OS is to hide peculiarities of hardware devices from the user
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 的内存管理- 一般设备驱动程序接口 - 特定硬件设备的驱动程序

Computer System 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 无线或蜂窝数据网络进行连接

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

 用户服务器端 计算机服务器系统为客户机请求服务(如数据库)提供接口 - 文件服务器系统为客户机存储和检索文件提供接口

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 网络 - 向网络上的中央查找服务注册其服务,或 - 通过发现协议广播服务请求并响应服务请求 

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
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)
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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值