东南大学操作系统课件(汪芸老师版)
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
22
OS Design and Implementation(1)
• Important principle to separate Policy: What will be done? from Mechanism: How to do it?
23
Simple Structure(2)
• MS-DOS – written to provide the most functionality in the least space
4
System Calls
• Programming interface to the services provided by the OS • Typically written in a high-level language (C or C++)
5
Example of System Calls
21
OS Design and Implementation
• User goals and System goals
-- User goals : convenient to use, easy to learn, reliable, safe, and fast -- System : easy to design, implement, and maintain, as well as flexible, reliable, errorfree, and efficient
Chapter 2: Operating-System Structures
Services supported by Operating Systems
2
Operating System Services
User interface Program execution - to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) I/O operations File-system manipulation Communications Error detection
15
MS-DOS execution
(a) At system startup (b) running a program
16
FreeBSD Running Multiple Programs
17
Dtrace in Solaris 10
18
System Programs • System programs provide a convenient environment for program development and execution. They can be divided into:
– – – – – – – File manipulation Status information File modification Programming language support Program loading and execution Communications Application programs
– Not divided into modules – Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated
24
MS-DOS Layer Structure
11
Standard C Library Example • C program invoking printf() library call, which calls write() system call
12
System Call Parameter Passing
• Three general methods used to pass parameters to the OS
26
Layered Operating System
27
UNIX System Structure
28
Modules(4)
• Most modern operating systems
– Uses object-oriented approach – Each core component is separate – Each talks to the others over known interfaces – Each is loadable as needed within the kernel
• Similar to layers but with more flexible
29
Solaris Modular Approach
30
Mac OS X Structure
31
Microkernel System Structure(5)
• Moves as much from the kernel into “user” space • Communication takes place between user modules using message passing
19
Operating System Structures
20
OS Design and Implementation
• Internal structure of different Operating Systems can vary widely • Start by defining goals and specifications • Affected by choice of hardware, type of system
34
Virtual Machines
• The resources of the physical computer are shared to create the virtual machines
– CPU scheduling can create the appearance that users have their own processor – Spooling and a file system can provide virtual card readers and virtual line printers – A normal user time-sharing terminal serves as the virtual machine operator’s console
-- Simplest: pass the parameters in registers -- Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register -- Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system
7
Example of Standard API
8
System Call Implementation
• Typically, a number associated with each system call
– System-call interface maintains a table indexed according to these numbers
13
Parameter Passing via Table
14
Types of System Calls
• • • • •
Process control File management Device management Information maintenance Communications
• Detriments:
– Performance overhead of user space to kernel space communication
33
Virtual Machines • Layered approach to its logical conclusion • Identical interface to the underlying bare hardware • Each process executes on its own processor with its own (virtual) memory
32
Microkernel System Structure • Benefits:
– Easier to extend a microkernel – Easier to port the operating system to new architectures – More reliable (less code is running in kernel mode) – More secure
3
Operating System Services
• Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing – Resource allocation – Accounting - To keep track of which users use how much and what kinds of computer resources – Protection and security
• The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values
9
API /System Call /OS Relationship
10
System Call Implementation
• The caller need know nothing about how the system call is implemented
– Just needs to obey API and understand what OS will do as a result call – Most details of OS interface hidden from programmer by API
• System call sequence to copy the contents of one file to another file
6
System Calls • Mostly accessed by programs via a highlevel Application Program Interface (API) rather than direct system call use • Three most common APIs -- Win32 API for Windows -- POSIX API for POSIX-based systems -- Java API for the Java virtual machine (JVM)
ຫໍສະໝຸດ Baidu25
Layered Approach(3)
• 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. • Use functions (operations) and services of lower-level layers