operatingsystem《操作系统》ch02operatingsystemstructures42精选课件_第1页
operatingsystem《操作系统》ch02operatingsystemstructures42精选课件_第2页
operatingsystem《操作系统》ch02operatingsystemstructures42精选课件_第3页
operatingsystem《操作系统》ch02operatingsystemstructures42精选课件_第4页
operatingsystem《操作系统》ch02operatingsystemstructures42精选课件_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Chapter 2: Operating-System Structures第1页,共41页。Chapter ObjectivesView OS from:ServicesInterfacesComponents and InterconnectionsTo describe the services an operating system provides to users, processes, and other systemsTo discuss the various ways of structuring an operating systemTo explain how oper

2、ating systems are installed and customized and how they boot第2页,共41页。Content OverviewOperating System ServicesUser Operating System InterfaceSystem CallsTypes of System CallsSystem ProgramsOperating System Design and ImplementationOperating System StructureVirtual MachinesOperating System Generation

3、System Boot第3页,共41页。2.1 Operating System ServicesOne set of operating-system services provides functions that are helpful to the user:User interface - Almost all operating systems have a user interface (UI)Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch programming interfaceP

4、rogram execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)I/O operations - A running program may require I/O, which may involve a file or an I/O device. File-system manipulation - The file system i

5、s of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.第4页,共41页。Operating System Services (Cont.)One set of operating-system services provides functions that are helpful to the user

6、 (Cont):Communications Processes may exchange information, on the same computer or between computers over a networkCommunications may be via shared memory or through message passing (packets moved by the OS)Error detection OS needs to be constantly aware of possible errorsMay occur in the CPU and me

7、mory hardware, in I/O devices, in user programFor each type of error, OS should take the appropriate action to ensure correct and consistent computingDebugging facilities can greatly enhance the users and programmers abilities to efficiently use the system第5页,共41页。Operating System Services (Cont.)An

8、other set of OS functions exists for ensuring the efficient operation of the system itself via resource sharingResource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of themMany types of resources - Some (such as CPU cycles,mainmemory, an

9、d file storage) may have special allocation code, others (such as I/O devices) may have general request and release code. Accounting - To keep track of which users use how much and what kinds of computer resourcesProtection and security - The owners of information stored in a multiuser or networked

10、computer system may want to control use of that information, concurrent processes should not interfere with each otherProtection involves ensuring that all access to system resources is controlledSecurity of the system from outsiders requires user authentication, extends to defending external I/O de

11、vices from invalid access attemptsIf a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.第6页,共41页。2.2 User Operating System InterfaceCLI(Command Line Interface) allows direct command entrySometimes implemented in kernel,

12、 sometimes by systems programSometimes multiple flavors implemented shellsPrimarily fetches a command from user and executes itSometimes commands built-in, sometimes just names of programsIf the latter, adding new features doesnt require shell modification第7页,共41页。User Operating System Interface - G

13、UIUser-friendly desktop metaphor interfaceUsually mouse, keyboard, and monitorIcons represent files, programs, actions, etcVarious mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder)Invented at Xerox PA

14、RC 1970sMany systems now include both CLI and GUI interfacesMicrosoft Windows is GUI with CLI “command” shellApple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells availableSolaris is CLI with optional GUI interfaces (Java Desktop, KDE)第8页,共41页。2.3 System CallsProgramming inte

15、rface to the services provided by the OSTypically written in a high-level language (C or C+)Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call useThree most common APIs are :Win32 API for Windows, POSIX API for POSIX-based systems (includi

16、ng virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM)第9页,共41页。Example of System CallsSystem call sequence to copy the contents of one file to another file Why use APIs rather than system calls? Program portability/convenience/第10页,共41页。Example of St

17、andard APIConsider the ReadFile() function in the Win32 APIa function for reading from a fileA description of the parameters passed to ReadFile()HANDLE file the file to be readLPVOID buffer a buffer where the data will be read into and written fromDWORD bytesToRead the number of bytes to be read int

18、o the bufferLPDWORD bytesRead the number of bytes read during the last readLPOVERLAPPED ovl indicates if overlapped I/O is being used第11页,共41页。System Call ImplementationTypically, a number associated with each system callSystem-call interface maintains a table indexed according to these numbersThe s

19、ystem call interface invokes intended system call in OS kernel and returns status of the system call and any return valuesThe caller need know nothing about how the system call is implementedJust needs to obey API and understand what OS will do as a result callMost details of OS interface hidden fro

20、m programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)第12页,共41页。API System Call OS Relationship第13页,共41页。Standard C Library ExampleC program invoking printf() library call, which calls write() system call第14页,共41页。System Call Parameter

21、PassingOften, more information is required than simply identity of desired system callExact type and amount of information vary according to OS and callThree general methods used to pass parameters to the OSSimplest: pass the parameters in registers In some cases, may be more parameters than registe

22、rsParameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This approach taken by Linux and SolarisParameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system Block and stack methods do not limit the

23、number or length of parameters being passed第15页,共41页。Parameter Passing via TableX: address of table第16页,共41页。2.4 Types of System CallsProcess control end, abort/ load, execute/create process, terminate process/ get process attributes, set process attributes/wait for time/wait event, signal event/all

24、ocate and free memoryFile management create file, delete file/open, close/read, write, reposition/get file attributes, set file attributesDevice management request device, release device/ read, write, reposition/ get device attributes, set device attributes/logically attach or detach devicesInformat

25、ion maintenance get time or date, set time or date/ get system data, set system data/ get process, file, or device attributes/ set process, file, or device attributesCommunications create, delete communication connection/send, receive messages/transfer status information/attach or detach remote devi

26、ces第17页,共41页。Examples of Windows and Unix System Calls第18页,共41页。*Process control: MS-DOS execution(a) At system startup (b) running a program第19页,共41页。*FreeBSD Running Multiple Programs第20页,共41页。2.5 System ProgramsProvide a convenient environment for program development and executionSome of them are

27、 simply user interfaces to system calls; others are considerably more complexFile management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directoriesStatus informationSome ask the system for info - date, time, amount of available memory, disk space, number of

28、 usersOthers provide detailed performance, logging, and debugging informationTypically, these programs format and print the output to the terminal or other output devicesSome systems implement a registry - used to store and retrieve configuration information第21页,共41页。System Programs (contd)File modi

29、ficationText editors to create and modify filesSpecial commands to search contents of files or perform transformations of the textProgramming-language support - Compilers, assemblers, debuggers and interpreters sometimes providedProgram loading and execution- Absolute loaders, relocatable loaders, l

30、inkage editors, and overlay-loaders, debugging systems for higher-level and machine languageCommunications - Provide the mechanism for creating virtual connections among processes, users, and computer systemsAllow users to send messages to one anothers screens, browse web pages, send electronic-mail

31、 messages, log in remotely, transfer files from one machine to another第22页,共41页。2.6 Operating System Design and ImplementationDesign and Implementation of OS not “solvable”, but some approaches have proven successfulInternal structure of different Operating Systems can vary widelyStart by defining g

32、oals and specifications Affected by choice of hardware, type of systemUser goals and System goalsUser goals operating system should be convenient to use, easy to learn, reliable, safe, and fastSystem goals operating system should be easy to design, implement, and maintain, as well as flexible, relia

33、ble, error-free, and efficient第23页,共41页。Operating System Design and Implementation (Cont.)Important principle to separatePolicy: What will be done? Mechanism: How to do it?Mechanisms determine how to do something, policies decide what will be doneSuch as the timer construct is a Mechanism, and how l

34、ong the timer is to be set is Policy.The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed laterImplementation Traditionally, operating systems have been written in assembly language. Now, however, they are most com

35、monly written in higher-level languages such as C or C+.第24页,共41页。2.7 Operating-System StructureSimple Structure MS-DOS written to provide the most functionality in the least spaceNot divided into modulesAlthough MS-DOS has some structure, its interfaces and levels of functionality are not well sepa

36、ratedDifficult to implement and maintain.第25页,共41页。Layered ApproachThe operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.With modularity, layers are selected such t

37、hat each uses functions (operations) and services of only lower-level layersSimplicity of construction and debuggingIt is difficult to define the various layersLess efficient第26页,共41页。UNIXUNIX limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS

38、consists of two separable partsSystems programsThe kernelConsists of everything below the system-call interface and above the physical hardwareProvides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level第27页,共41页。UNIX Sy

39、stem Structure第28页,共41页。Microkernel System Structure Moves as much nonessential parts from the kernel into “user” space, provide minimal process and memory management.Communication takes place between user modules using message passingBenefits:Easier to extend a microkernelEasier to port the operati

40、ng system to new architecturesMore reliable (less code is running in kernel mode)More secureDetriments:Performance overhead of user space to kernel space communicationExamples Mach True64 Unix QNX第29页,共41页。ModulesMost modern operating systems implement module kernel Uses object-oriented approachEach

41、 core component is separateEach talks to the others over known interfacesEach is loadable as needed within the kernelAllows the kernel to provide core services yet also allows certain features to be implemented dynamically.Overall, similar to layers but with more flexible第30页,共41页。Solaris Modular Ap

42、proach第31页,共41页。Mac OS X hybrid structure第32页,共41页。2.8 Virtual MachinesThe fundamental idea behind a virtual machine is to abstract the hardware of a single computer into several different execution environments, thereby creating the illusion that each separate execution environment is running its o

43、wn private computer.A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardwareA virtual machine provides an interface identical to the underlying bare hardwareThe operating system creates the illusion of

44、 multiple processes, each executing on its own processor with its own (virtual) memory第33页,共41页。Virtual Machines (Cont.)The resources of the physical computer are shared to create the virtual machinesCPU scheduling can create the appearance that users have their own processorSpooling and a file syst

45、em can provide virtual card readers and virtual line printersA normal user time-sharing terminal serves as the virtual machine operators console第34页,共41页。Virtual Machines (Cont.) (a) Nonvirtual machine (b) virtual machineNon-virtual MachineVirtual Machine第35页,共41页。Virtual Machines (Cont.)The virtual-machine con

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论