- View an OS from several vantage points
- Services it provides
- Interface available to users and programmers
- Components and their interconnections
- OS services for users
- User interface
- Program execution(essential)
- I/O operation
- File-system manipulation
- Communications
-
- Shared memory
- Message passing
-
- Error detection
-
- Ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs
- OS ensures efficient system operations:
- Resource allocation
- Accounting
- Protection
-
- ensuring that all access to system resources is controlled
- User operating-system interface
- Command Interpreter(shells): The main function of the command interpreter is to get and execute the next user-specified command
- Graphical user interfaces
- System calls
- Interface between a running program and the OS
- 通过陷入(trap)或异处理机构进行系统调用(通过子程序的入口地址表)
-
- Methods used to pass parameters betwwn a running program and the OS
-
- In registers
- Store the parameters in a table in memory, and the table address is passed as a parameter in a register
-
-
- Stack: push the parameters onto the stack by the program, and pop off the stack by OS
-
- System programs: system programs provide a convenient environment for program development and execution
- File management
- Status information
- File modification
- Programming language support
- Program loading and execution
- Communications
- Application programs
- Common system components
- Process management
-
- A process is a program in execution
- The operating system is responsible for the following activities in connection with process management
-
- Process creation and deletion
- Process suspension and resumption
- Provision of mechanisms for
-
- Process synchronization
- Process communication
- Providing mechanisms for deadlock handling
- Main memory management
-
- The operating system is responsible for the following activities in connections with memory management
-
- Keep track of which parts of memory are currently being used and by whom
- Decide which processes to load when memory space becomes available
- Allocate and deallocate memory space as needed
- Protection
- Secondary-storage management
-
- The operating system is responsible for the following activities in connections with disk management
-
- Free space management
- Storage allocation
- Disk scheduling
- I/O system management
- File management
-
- The operating system is responsible for the following activities in connections with file management
-
- File creation and deletion
- Directory creation and deletion
- Support of primitives for manipulating files and directories
- Mapping files onto secondary storage
- File backup on stable(nonvolatile) storage media
- Protection system
-
- Must:
-
- Distinguish between authorized and unauthorized usage
- Specify the controls to be imposed
- Provide a means of enforcement
- Networking
-
- Access to a shared resource allows
-
- Computation speed-up
- Increased data availability
- Enhanced reliability
- Command-Interpreter system
-
- Many commands are given to the operating system by control statements which deal with:
-
- process creation and management
- I/O handling
- secondary-storage management
- main-memory management
- file-system access
- protection
- networking
- System structure
- Simple approach
-
- MS-DOS
-
- Not divided into modules
- Interfaces and levels of functionality are not well separated
- UNIX
-
- System programs
- The kernel
- Layered approach: the bottom layer is the hardware, the highest layer is the user interface. Layers are selected such that each uses functions and services of only lower0level layers
-
- 分层的基本原则:
-
- 每一层都使用其底层所提供的功能和服务,以便于系统调试和验证。
- 困难
-
- 层次的划分和安排,要保证不出现双向依赖关系
- The first design used in the OS
-
- 优点
-
- 低层和高层可分别实现(便于扩充);
- 高层错误不会影响到低层,便于调试、利于功能的增删改;
- 调用关系清晰(高层对低层单向依赖),避免递归调用,有利于保证设计和实现的正确性
- 缺点
-
- 系统中所有进程的控制转移、通讯等任务全部交给系统的核心去管理,要花费一定的代价
- Microkernel
- 基于微内核结构的OS和传统OS相比的特点
-
- 内核精巧
- 面向多处理机和分布式系统
-
- 引入线程
- 基于客户/服务器体系结构
- 优点:
-
- 易于扩充,易于移植
- 提高系统的可靠性:
- 提供多种操作环境
- 便于实现分布计算:以同样的调用形式,在下层可通过核心中的网络传送到远方服务器上 (RPC, Remote Procedure Call)
- 缺点:
-
- 消息传递方式增加开销,使响应变慢
- Virtual machines
- The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.
- 实现方式: 分时,共享
- The resources of the physical computer are shared to create the vitual machines
-
- CPU scheduling can create the appearance that users have their own processor
- Spooling and a file system can provide virtual card reader and virtual line printers
- A normal user time-sharing terminal serves as the virtual machine operator's console
- System design goals
- User goals
-
- Operating system should be convenient to use, easy to learn, reliable, safe and fast
- System goals
-
- Operating system should be easy to design, implement and maintain, as well as flexible, reliable, error-free and efficient
- Mechanisms and policies
- The separation of policy from mechanism is a vital principle, it allows maximum flexibility if policy decisions are to be changed later
- System implementation
- Traditionally written in assembly language, now HLL
- OS written in HLL
-
- Can be written faster
- More compact
- Easier to understand and debug
- Easier to port(move to some other hardware)