中科大操作系统原理与实现课件2_OS structure.pdf
《中科大操作系统原理与实现课件2_OS structure.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件2_OS structure.pdf(79页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、.操作系统原理与设计第2章 OS structures陈香兰中国科学技术大学计算机学院2009年09月01日.提纲操作系统的组成、服务、特征System componentsOS ServicesSystem Callsystem programs操作系统的特征操作系统的抽象模型和体系结构进程模型线程模型操作系统的体系结构虚拟机小结和作业.Outline操作系统的组成、服务、特征System componentsOS ServicesSystem Callsystem programs操作系统的特征操作系统的抽象模型和体系结构进程模型线程模型操作系统的体系结构虚拟机小结和作业.System c
2、omponentsIProcess ManagementIMain Memory ManagementISecondary-Storage ManagementII/O System ManagementIFile ManagementIProtection SystemINetworkingICommand-Interpreter System.处理器管理多道环境下,处理器的运行及分配都以进程(process)为单位,因此处理器管理可归结为进程管理(process management)。一、进程控制I创建/撤消进程;挂起恢复进程I迁移进程的状态I一般由进程控制原语完成二、进程同步I为使多个
3、进程有条不紊地运行,应建立同步机制。I包括进程互斥/同步,次序协调;死锁避免、预防、检测和消除.三、进程通信I源于进程合作,如:输入进程、计算进程、打印进程相互间有信息传递I类型:I直接:PA发msg,PB收msgI间接:PA发msg到中间实体(如mailbox),PB从中间实体收msg四、作业与进程调度I作业调度:为作业分配必要资源,调入内存建立进程,并使之进入就绪队列。I进程调度:从就绪队列中选出进程,分配CPU,使之运行。I调度算法:FCFS、优先权等.存储管理(Main Memory Management)IMM is a large array of words or bytes,e
4、ach with its ownaddressIA repository of quickly accessible data shared by CPU andI/O devicesIA volatile storage deviceIMaybe the most architecture-specified component of OSIActivitiesIKeeping track of memory usageIDeciding which processes to loadIAllocating and deallocating memory space.目的:方便用户使用,且提
5、高存贮器利用率一、内存分配I静态分配:I动态分配:作业在内存中可移动需内存分配的数据结构及内存分配和回收功能二、内存保护I例:设置上、下界寄存器,每条指令进行越界检查(一般是硬件实现)三、地址映射I地址范围地址I逻辑空间逻辑地址(相对地址)I物理空间物理地址(绝对地址)四、内存扩充I利用虚存技术,从逻辑上扩充内存容量I系统应有:请求调入/置换功能以支持虚存技术.File managementIA fileIa collection of related information defined by its creator.Commonly,programs&dataIA logical sto
6、rage unitIActivitiesIFile creation and deletionIDirectory creation and deletionISupport of primitives for manipulating files and directoriesIMapping files onto secondary storageIFile backup on stable(nonvolatile)storage media.文件管理的功能任务:方便用户,提供安全性一、文件存贮空间的管理I例:文件系统根据文件长度自动分配连续或离散的扇区,并提供“一句柄”表示该文件。二、目
7、录管理I使用户按名存取,提高速度。三、文件的读、写管理和存取控制(即保护).I/O managementII/O subsystemITo hide the peculiarities of specific hardware devices from theuserIMaybe the most complicate component and has largest line ofcode(LOC)IVarious deviceIConsists ofIBuffering,caching,and spoolingIA general device-driver interfaceIDriv
8、ers for specific hardware device.设备管理功能任务:提高I/O利用率和速度,方便用户一、缓冲管理缓冲区:用来解决CPUI/O矛盾,如:CPU快则应多创建缓冲区。二、设备分配包括:设备,设备控制器,I/O通信的分配和回收三、设备处理I指控制设备进行实际的操作,包括读、写等以及向CPU发中断。I设备处理/驱动程序应能根据用户的I/O请求,自动地构成通道程序。.四、设备独立性和虚拟设备I独立性,即program与设备无关性,使program易于重定向,增加了可移植性。I虚拟设备.Second storage managementIUsually disks used
9、to store data that does not fit in mainmemory or data that must be kept for a“long”period oftime.IProper management is of central importanceIEntire speed of computer operation hinges on disk subsystemand its algorithmsIActivitiesIFree-space managementIStorage allocationIDisk schedulingISome storage
10、need not be fastITertiary storage includes optical storage,magnetic tapeIStill must be managedIVaries between WORM(write-once,read-many-times)and RW(read-write).Command-interpreter systemIThe interface between the user and the OS In the kernel or asa special programITo get the next command statement
11、 and execute itIExample:IControl-card interpreterICommand-line interpreter(DOS)IShell(UNIX)IGUI.用户接口一、命令接口I由一组“命令”集组成,分为联机和脱机用户接口I联机用户接口由一组键盘操作命令及命令解释程序所组成I脱机(批处理用户接口)用JCL写作业说明书二、程序接口I系统调用I高级语言的库函数,如C库三、图形接口I如 win的copy文件,采用“拖”来完成,生动,不需记忆.Protection and Security systemIProtection any mechanism for co
12、ntrolling access ofprocesses or users to resources defined by the OSISecurity defense of the system against internal and externalattacksIHuge range,including denial-of-service,worms,viruses,identity theft,theft of serviceISystems generally first distinguish among users,to determinewho can do whatIUs
13、er identities(user IDs,security IDs)Iassociated with all files,processes of that user to determineaccess controlIGroup identifier(group ID)IPrivilege escalation allows user to change to effective ID withmore rights.Outline操作系统的组成、服务、特征System componentsOS ServicesSystem Callsystem programs操作系统的特征操作系统
14、的抽象模型和体系结构进程模型线程模型操作系统的体系结构虚拟机小结和作业.操作系统提供的服务.操作系统的各种功能,最终要封装成“服务”的形式提供给用户I装载并运行程序I提供各种I/O操作I提供文件系统及文件操作I提供通信服务I提供差错检测服务I对资源的分配进行管理I对资源的使用进行统计(记账)I对系统进行保护.操作系统提供服务的最基本方式系统调用I系统调用的类型I进程控制类I文件操作类I设备管理类I通信类,例如消息传送机制I信息维护类,例如日期信息、系统信息等.Outline操作系统的组成、服务、特征System componentsOS ServicesSystem Callsystem pr
15、ograms操作系统的特征操作系统的抽象模型和体系结构进程模型线程模型操作系统的体系结构虚拟机小结和作业.System CallsIProgramming interface to the services provided by the OSITypically written in a high-level language(C or C+)IMostly accessed by programs via a high-level ApplicationProgram Interface(API)rather than direct system call useIThree most c
16、ommon APIs areIWin32 API for Windows,IPOSIX API for POSIX-based systems(including virtuallyall versions of UNIX,Linux,and Mac OS X),Iand Java API for the Java virtual machine(JVM)IWhy use APIs rather than system calls?.Example of System CallsISystem call sequence to copy the contents of one file toa
17、nother file.Example of Standard API.IConsider the ReadFile()functionIWin32 APIa function for reading from a fileIA description of the parameters passed to ReadFile()IHANDLE filethe file to be readILPVOID buffera buffer where the data will be read into andwritten fromIDWORD bytesToReadthe number of b
18、ytes to be read intothe bufferILPDWORD bytesReadthe number of bytes read during thelast readILPOVERLAPPED ovlindicates if overlapped I/O is beingused.System Call ImplementationITypically,a number associated with each system callISystem-call interface maintains a table indexed according tothese numbe
19、rsIThe system call interface invokes intended system call in OSkernel and returns status of the system call and any returnvaluesIThe caller need know NOTHING about how the system callis implementedIJust needs to obey API and understand what OS will do as aresult callIMost details of OS interface hid
20、den from programmer by APIIManaged by run-time support library(set of functions builtinto libraries included with compiler).API System Call OS Relationship.Standard C Library ExampleIC program invoking printf()library call,which calls write()system call.System Call Parameter PassingIOften,more infor
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中科大操作系统原理与实现课件2_OS structure 中科大 操作系统 原理 实现 课件 _OS
限制150内