Chapter 1Introduction.ppt

上传人(卖家):hyngb9260 文档编号:6157083 上传时间:2023-06-04 格式:PPT 页数:92 大小:5.85MB
下载 相关 举报
Chapter 1Introduction.ppt_第1页
第1页 / 共92页
Chapter 1Introduction.ppt_第2页
第2页 / 共92页
Chapter 1Introduction.ppt_第3页
第3页 / 共92页
Chapter 1Introduction.ppt_第4页
第4页 / 共92页
Chapter 1Introduction.ppt_第5页
第5页 / 共92页
点击查看更多>>
资源描述

1、Principles of Operating SystemChapter 1Introduction2Contents1.1 What is an operating system(OS)?1.2 History of OS1.3 The OS zoo1.4 OS concept1.5 The functions of OS1.6 System calls1.7 OS structure3Operating system(OS)vThe job of OS:To provide user programs with a better,simpler,cleaner,model of the

2、computer To handle managing all the resources(one or more processors,some main memory,disks,printers,a keyboard,a mouse,a display,network interfaces,and various other input/output devices.)4vTwo modes of operation(运行模式运行模式)of computers:Kernel mode(内核态,也称管态、核心态内核态,也称管态、核心态)User mode(用户态用户态)vThe OS ru

3、ns in kernel mode,it can access to all the hardware and can execute any instruction the machine is capable of executing.vThe rest of the software runs in user mode,in which only a subset of the machine instructions is available.5Where the OS fits in61.1 What is an OS1.1.1 The OS as an extended machi

4、ne Top-down view1.1.2 The OS as a resource manager Bottom-up view71.1.1 The OS as an extended machinevThe OS provides abstractions(抽象抽象)to application programs.vGood abstractions turn a nearly impossible task into two manageable ones.The first one:define and implement the abstractions The second one

5、:use these abstractions to solve the problem at hand8vOne of the major tasks of the OS is to hide the hardware and present programs(and their programmers)with nice,clean,elegant,consistent,abstractions to work with instead.9OS turns ugly hardware into beautiful abstractions 101.1.2 The OS as a resou

6、rce managervFrom this view,OS is designed to manage all the pieces of a complex system.vThe job of OS is to provide for an orderly and controlled allocation of the processors,memories,and I/O devices among the various programs.11vResource management includes multiplexing resources in two different w

7、ays:time multiplexing(时分复用)(时分复用)For example:CPU,printer space multiplexing(空分复用)(空分复用)For example:main memory,disk12操作系统(操作系统(OS)的定义)的定义操作系统是控制和管理计算机软、硬件资源,操作系统是控制和管理计算机软、硬件资源,合理地组织计算机的工作流程,以及方便用户合理地组织计算机的工作流程,以及方便用户使用的程序集合使用的程序集合。本质本质操作系统是配置在计算机硬件上的第一层软件,操作系统是配置在计算机硬件上的第一层软件,是对硬件系统的第一次扩充。是对硬件系统的第一

8、次扩充。131.2 History of OSSince operating systems have closely tied to the architecture of the computers on which they run,we will look at successive generations of computers to see what their operating systems were like.141.2.1 The first generation:vacuum tubesIn this generation,all programming was do

9、ne in absolute machine language,or even worse yet,by wiring up electrical circuits by connecting thousands of cables to plugboards(插件板插件板)to control the machines basic functions.Programming languages were unknown,operating systems were unheard of.151.2.2 The second generation:Transistors(晶体管晶体管)and

10、Batch systemsvMainframe(大型机大型机)vTo run a job,a programmer would first write the program on paper(in FORTRAN or assembler),then punch it on cards(穿孔成卡片穿孔成卡片),then bring the card deck down to the input room and hand it to the operators and wait until the output was ready.vGiven the high cost of the eq

11、uipment,people quickly looked for ways to reduce the wasted time.The solution generally adopted was the batch system(批处理系统批处理系统).16An early batch systemAfter each job finished,the operating system automatically read the next job from the tape and began running it.17The structure of a typical input j

12、obTypical operating systems were FMS(FORTRAN Monitor System)and IBMSYS(IBMs OS for the 7094).181.2.3 The third generation:ICs and multiprogrammingvICs:Integrated circuits,集成电路集成电路vBy the early 1960s,most computer manufacturers had two distinct,incompatible product lines.(1)word-oriented,large-scale

13、scientific computers,e.g.7094(2)character-oriented,commercial computers,e.g.1401vDeveloping and maintaining two completely different product lines was an expensive proposition for the manufacturers.19vSolution:IBM System/360The 360 was a series of software-compatible machines ranging from 1401-sized

14、 to much more powerful than the 7094.Since all the machines had the same architecture(体系结构体系结构)and instruction set(指指令集令集),programs written for one machine could run on all the others,at least in theory.The operating system:OS/360vThe idea of a family of compatible computers(兼容机兼容机)was soon adopted

15、by all the other major manufactures.20Some key techniquesvMultiprogramming:多道程序设计多道程序设计vSPOOLing:Simultaneous Peripheral Operation On Line,同时的外部设备联机同时的外部设备联机操作操作21MultiprogrammingPartition memory into several pieces,with a different job in each partitions.While one job was waiting for I/O to complet

16、e,another job could be using the CPU.程序A程序B程序C调度程序程序A I/O请求程序A I/O完成程序B I/O请求程序B I/O完成程序C I/O完成程序C I/O请求程序A 再被调度程序B 再被调度t用户程序监控程序I/O操作I/O中断请求启动I/OI/O完成启动I/OI/O完成I/O中断请求结束中断结束中断t1t2t3t4t5t6t7t8(a)单道程序的运行情况单道程序的运行情况(b)多道程序的运行情况多道程序的运行情况23SPOOLingthe ability to read jobs from cards onto the disk as soo

17、n as they were brought to the computer room.Whenever a running job finished,the OS could load a new job from the disk into the now-empty partition and run it.With spooling,the 1401 were no longer needed.24Timesharing system(分时系统分时系统)v由于批处理系统对用户的响应时间长,因此用户由于批处理系统对用户的响应时间长,因此用户对响应时间的要求导致了对响应时间的要求导致了分时

18、系统分时系统的出现的出现vTimesharing system is a variant of multiprogramming,in which each user has an online terminal.vThe first general-purpose timesharing system:CTSS(Compatible Time Sharing System),developed by MIT25Timesharing system主机主机终终端端分时系统分时系统:在一台主机上连接:在一台主机上连接了多个带有显示器和键盘的终了多个带有显示器和键盘的终端,同时允许多个用户通过自端

19、,同时允许多个用户通过自己的终端,以交互方式使用计己的终端,以交互方式使用计算机,共享主机中的资源。算机,共享主机中的资源。26Timesharing systemvMULTICS-The designer of this system envisioned one huge machine providing computing power for everyone in the Boston area.vMULTICS introduced many seminal(有重大影有重大影响的响的)ideas into the computer literature(文献文献).27MULTIC

20、S 庞大的分时系统庞大的分时系统v1965年在年在ARPA的支持下,的支持下,MIT、贝尔实验室和通、贝尔实验室和通用电气公司决定开发一种用电气公司决定开发一种“公用计算服务系统公用计算服务系统”,希望能够同时支持整个波士顿所有的分时用户。希望能够同时支持整个波士顿所有的分时用户。该系统称作该系统称作MULTICS(MULTiplexed Information and Computing Service)vMULTICS的设计目标是:的设计目标是:便利的远程终端使用,大量终端通过电话线接入计算机便利的远程终端使用,大量终端通过电话线接入计算机主机主机 高可靠的大型文件系统;大容量的用户信息共

21、享;存储高可靠的大型文件系统;大容量的用户信息共享;存储和构造层次化信息结构的能力和构造层次化信息结构的能力28MULTICSvMULTICS的研制难度超出了所有人的预料,的研制难度超出了所有人的预料,1969年年4月贝尔实验室退出,通用电气公司也退出了,月贝尔实验室退出,通用电气公司也退出了,但最终,经过多年的努力,但最终,经过多年的努力,MULTICS成功地应用成功地应用v运行运行MULTICS的计算机系统在九十年代陆续被关的计算机系统在九十年代陆续被关闭闭vDespite its lack of commercial success,MULTICS had a huge influenc

22、e on subsequent OSs.vMULTICS引入了许多现代操作系统领域概念的雏引入了许多现代操作系统领域概念的雏形,对随后操作系统特别是形,对随后操作系统特别是UNIX的成功有着巨大的成功有着巨大的影响的影响 29小型计算机,电子游戏和小型计算机,电子游戏和UNIX的成功的成功v1969年,在贝尔退出年,在贝尔退出MULTICS研制项目后,研制项目后,Ken Thompson和和Dennis M.Ritchie 想申请经费买计想申请经费买计算机从事操作系统研究,但多次申请得不到批准算机从事操作系统研究,但多次申请得不到批准v因此他们在一台无人用的因此他们在一台无人用的PDP-7上,

23、重新摆弄原上,重新摆弄原先在先在MULTICS项目上设计的项目上设计的“空间旅行空间旅行”游戏游戏v为了使游戏能够在为了使游戏能够在PDP-7上顺利运行,他们陆续上顺利运行,他们陆续开发了浮点运算软件包、显示驱动软件,设计了开发了浮点运算软件包、显示驱动软件,设计了文件系统、实用程序、文件系统、实用程序、shell 和汇编程序和汇编程序v到了到了1970年,在一切完成后,给新系统起了个同年,在一切完成后,给新系统起了个同MULTICS发音相近的名字发音相近的名字UNIX,随后,随后,UNIX用用C语言全部重写,自此,语言全部重写,自此,UNIX诞生了诞生了30UNIXvTwo major ve

24、rsions of UNIX:System V:from AT&T BSD:from the University of California at Berkeley31MINIX,LinuxvMINIX:a small clone of UNIX,for education purposesvLinux:written by a Finnish student,Linus Torvalds 321.2.4 The fourth generation:Personal ComputersLSI(Large Sacle Integration,大规模集成电路大规模集成电路)vCP/MvMS-DO

25、SvMacintoshvWindowsvUNIX331.3 The OS zoo1.3.1 mainframe OS1.3.2 Server OS1.3.3 Multiprocessor OS1.3.4 Personal Computer OS1.3.5 Handheld Computer OS1.3.6 Embedded OS1.3.7 Real-time OS341.3.1 mainframe OSvThe OS for mainframes are heavily oriented toward processing many jobs at once,most of which nee

26、d prodigious(巨大的巨大的)amounts of I/O.vThey typically offer three kinds of services:Batch transaction processing(事务处理事务处理)timesharing351.3.2 Server OSvServer OS run on servers,which are either very large PC,workstations,or even mainframes.vThey serve multiple users at once over a network and allow the

27、users to share hardware and software resources.vTypical server OS:Solaris,FreeBSD,Linux,Windows Server 200 x361.3.3 Multiprocessor OSvAn increasingly common way to get major-league computing power is to connect multiple CPUs into a single system.vDepending on precisely how they are connected and wha

28、t is shared,these systems are called:Parallel computers,multicomputers,multiprocessors.371.3.4 Personal Computer OSvLinuxvFreeBSDvWindowsvMacintosh381.3.5 Handheld Computer OSvA handheld computer or PDA is a small computer that fits in a shirt pocket and performs a small number of functions,such as

29、an electronic address book and memo pad.vTwo of the most popular OS for handhelds are Symbian OS and Palm OS.391.3.6 Embedded OSvEmbedded(嵌入式嵌入式)system run on the computers that control devices that are not generally thought of as computers and which do not accept user-installed software.vTypical ex

30、amples:microwave ovens(微微波炉波炉),TV sets,cars,DVD recorders,cell phones,MP3 players 401.3.7 Real-time OSvReal-time(实时实时)OS are characterized by having time as a key parameter.vHard real-time system:the action absolutely must occur at a certain moment(or within a certain range)vSoftware real-time syste

31、m:in this system,missing an occasional deadline,while not desirable,is acceptable and does not cause any permanent damage.411.3.8 操作系统的三种基本类型操作系统的三种基本类型v批处理操作系统批处理操作系统 单道批处理系统单道批处理系统:由于第二代计算机的速度逐:由于第二代计算机的速度逐步提高,为了进一步解决人机矛盾,在系统中步提高,为了进一步解决人机矛盾,在系统中配置了监督程序,在它的控制下实现了作业的配置了监督程序,在它的控制下实现了作业的自动过渡,由此出现了作业

32、的成批处理,即单自动过渡,由此出现了作业的成批处理,即单道批处理系统。道批处理系统。多道批处理系统多道批处理系统:为了进一步提高资源的利用:为了进一步提高资源的利用率和系统吞吐量,引入了多道程序设计技术,率和系统吞吐量,引入了多道程序设计技术,由此而形成了多道批处理系统。由此而形成了多道批处理系统。v分时操作系统分时操作系统 在一台主机上连接了多个带有显示器和键盘的终端,同时允许多个用户通过自己的终端,以交互方式使用计算机,共享主机中的资源。v实时操作系统实时操作系统421.4 OS concepts1.4.1 processes1.4.2 address spaces1.4.3 Files1

33、.4.4 Input/Output431.4.1 ProcessesA key concept in all operating systems is the process.A process is basically a program in execution.vProcess table:in many OS,all the information about each process,other than the contents of its own address space,is stored in this table.44ProcessesvProcess tree:vIn

34、terprocess communication:Related processes that are cooperating to get some job done often need to communicate with one another and synchronize their activities.451.4.2 Address spacesAddress spaces:a list of memory locations from 0 to some maximum,which the process can read and write.In the simplest

35、 case,the maximum amount of address space a process has is less than the main memory.In this way,a process can fill up its address space and there will be enough room in main memory to hold it all.However,in more complicated case,?46vThe technique of Virtual memory:the OS keeps part of the address s

36、pace in main memory and part on disk and shuttles pieces back and forth between them as need.471.4.3 FilesvDirectoryvRoot directoryvWorking directoryvAbsolute path names:consists of the list of directories that must be traversed from the root directory to get to the file,with slashes(斜杠斜杠,/)separati

37、ng the components.vRelative path names:not begin with a slash are looked for.48A file system49File descriptorvFile descriptor(文件描述符文件描述符):Before a file can be read or written,it must be opened,at which time the permissions are checked.If the access is permitted,the system returns a small integer cal

38、led a file descriptor to use in subsequent operations.50Some important concepts in UNIX vThe mounted file system51Some important concepts in UNIXvSpecial file Block special file Character special file The special files are kept in the/dev directory.vPipe(管道管道):a sort of pseudofile(伪文件,伪文件,虚文件虚文件)tha

39、t can be used to connect two processes.521.4.4 Input/OutputvAll computers have physical devices for acquiring input and producing output.vEvery OS has an I/O subsystem for managing its I/O devices.vIn chapter 5,we will have a look at I/O software.531.5 操作系统的主要功能操作系统的主要功能54u 对处理机的分配和运行实施有效对处理机的分配和运行实

40、施有效管理。管理。u 在多道程序环境下,处理机的分配在多道程序环境下,处理机的分配和运行以进程为单位,因此对处理机和运行以进程为单位,因此对处理机的管理即的管理即对进程的管理对进程的管理。任务任务u 进程控制进程控制u 进程同步进程同步u 进程通信进程通信u 进程调度进程调度功能功能处理机管理处理机管理55u为多道程序的并发运行提供良好环境为多道程序的并发运行提供良好环境u便于用户使用存储器便于用户使用存储器u提高存储器的利用率提高存储器的利用率u为尽量多的用户提供足够大的空间为尽量多的用户提供足够大的空间任务任务u内存分配内存分配u内存保护内存保护u地址映射地址映射u内存扩充内存扩充功能功能

41、存储管理存储管理56u完成用户程序请求的完成用户程序请求的I/O操作操作u为用户程序分配为用户程序分配I/O设备设备u提高提高CPU和和I/O设备的利用率设备的利用率u改善人机界面改善人机界面任务任务u缓冲管理缓冲管理u设备分配设备分配u设备处理(设备驱动程序)设备处理(设备驱动程序)功能功能设备管理设备管理57u大量的信息以文件的形式放在外存,大量的信息以文件的形式放在外存,对信息的管理也就是对信息的管理也就是对文件的管理对文件的管理 任务任务u文件存储空间的管理文件存储空间的管理u目录管理目录管理u文件的读、写管理文件的读、写管理u文件的存取控制文件的存取控制功能功能文件管理文件管理58u

42、联机命令接口联机命令接口u脱机命令接口脱机命令接口u图形用户界面(命令接口的改版)图形用户界面(命令接口的改版)用户接口用户接口操作系统与用户之间的接口操作系统与用户之间的接口u也称系统调用也称系统调用程序接口程序接口591.6 System callsvWe have seen that OS has two main functions:Providing abstractions to user programs Managing the computers resourcesvThe interface between user programs and the OS is prima

43、rily about dealing with the abstractions.System calls60System callsvIn a sense,making a system call is like making a special kind of procedure call,only system calls enter the kernel and procedure calls do not.61Some of the most heavily used POSIX system calls(1)62Some of the most heavily used POSIX

44、 system calls(2)631.6.1 system calls for process managementvfork is the only way to create a new process in POSIX.vIt creates an exact duplicate of the original process,including all the file descriptors,registerseverything.vAfter the fork,the original process(the parent)and the copy(the child)go th

45、eir separate ways.64forkvThe fork call returns a value,which is zero in the child and equal to the childs process identifier or PID in the parent.vUsing the returned value,the two processes can see which one is the parent process and which one is the child process.65forkvwaitpid:waits until the chil

46、d terminates.It can wait for a specific child,or for any old child by setting the first parameter to-1.66创建进程的例子创建进程的例子例例1:例例2#include#include#include main()pid_t pid;/保存子进程的保存子进程的ID号号int status;/等待的退出状态等待的退出状态pid=fork();/创建新进程创建新进程if(pid=-1)perror(“Fork failed to creat a process”);exit(1);else if(p

47、id=0)/子进程代码子进程代码 if(execl(“/bin/ls”,“ls”,“-l”,NULL)0)perror(“Exec failed”);exit(1);else if(pid!=wait(&status)/父进程代码父进程代码perror(“A signal occurred before the child exited”);exit(0);68例例2的运行结果的运行结果691.6.2 system calls for file managementvopenvreadvwritevlseek:changes the value of the current position

48、pointer in the file,so that subsequent calls to read or write can begin anywhere in the file.vstat:keeps track of the file mode,size,time of last modification,and other information.701.6.3 system calls for directory managementvmkdir:create a new directoryvrmdir:remove an empty directoryvlink(name1,n

49、ame2):create a new entry,name2,point to name1vunlink:remove a directory entryvmountvumount71examplelink(“/usr/jim/memo”,“/usr/ast/note”);721.6.4 miscellaneous system callsvchdir(“/usr/ast/test”):changes the current working directoryvchmod(“file”,0644):change the mode of a filevkill:send signals731.6

50、.5 The windows Win32 APIvIn windows,the library calls and the actual system calls are highly decoupled.vMicrosoft has defined a set of procedures called the Win32 API(Application Program Interface)that programmers are expected to use to get OS services.74Win32 API751.7 OS structurevMonolithic system

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 办公、行业 > 各类PPT课件(模板)
版权提示 | 免责声明

1,本文(Chapter 1Introduction.ppt)为本站会员(hyngb9260)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!


侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|