1 / 63

Operating System Organization

Operating System Organization. 3. Goals. Learn how an operating system is organized Understand the responsibilities of an OS efficiency security correctness Learn about the parts of an OS (the managers) device manager memory manager process manager file manager

tyson
Download Presentation

Operating System Organization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems: A Modern Perspective, Chapter 3

  2. Operating SystemOrganization 3 Operating Systems: A Modern Perspective, Chapter 3

  3. Goals • Learn how an operating system is organized • Understand the responsibilities of an OS • efficiency • security • correctness • Learn about the parts of an OS (the managers) • device manager • memory manager • process manager • file manager • Learn about OS design approaches • microkernels • Understand some themes of OS implementation • modes • system calls/traps • Examine the organization of some modern OSes Operating Systems: A Modern Perspective, Chapter 3

  4. Purpose of an OS Coordinate Use of the Abstractions Processes The Abstractions Create the Abstractions Operating Systems: A Modern Perspective, Chapter 3

  5. OS Requirements 1. Provide resource abstractions • Process abstraction of CPU/memory use • Address space • Thread abstraction of CPU within address space • Resource abstraction • “Anything a process can request that can block the process if it is unavailable” • NT uses “object abstraction” to reference resources • File abstraction of secondary storage use Operating Systems: A Modern Perspective, Chapter 3

  6. DOS -- Resource Abstraction Only Program Program Libraries Program OS Services ROM Routines Processor(s) Main Memory Devices Operating Systems: A Modern Perspective, Chapter 3

  7. OS Requirements (cont) 1. Provide resource abstractions 2. Manage resource sharing • Time/space-multiplexing • Exclusive use of a resource • Isolation • Managed sharing Operating Systems: A Modern Perspective, Chapter 3

  8. Process Process Process Program Program Program State State State Abstraction & Sharing Libraries • OS Services • Abstraction • Manage sharing ROM Routines Processor(s) Main Memory Devices Operating Systems: A Modern Perspective, Chapter 3

  9. OS Design Constraints • Performance • Protection and security • Correctness • Maintainability • Commercial factors • Standards and open systems Operating Systems: A Modern Perspective, Chapter 3

  10. Performance • The OS is an overhead function should not use too much of machine’s resources • does not provide a solution • rather provides an environment in which a solution is implemented. • Minimum functionality is to implement abstractions • Additional function must be traded off against performance • DOS: one process • UNIX: low level file system, not graphical environment Operating Systems: A Modern Perspective, Chapter 3

  11. Protection & Security • Multiprogramming resource sharing • Processes need exclusive control over resources • OS must ensure processes do not interfere with other processes • OS must allow specific sharing of resources • Security policy: Sharing strategy chosen by computer’s owner • Protection mechanism: Tool to implement a family of security policies • OS enforces a policy • processes must be prevented from changing the policy Operating Systems: A Modern Perspective, Chapter 3

  12. Correctness & Maintainability • Security depends on correct operation of software trusted vs untrusted software • kernel code must be trusted • application programs, system software, etc. are untrusted • must have barriers between trusted software (kernel) and untrusted software (user programs) Operating Systems: A Modern Perspective, Chapter 3

  13. Correctness & Maintainability • Maintainability relates to ability of software to be changed • If either is sufficiently important, can limit the function of the OS • Guiding a manned spaceship • Managing a nuclear reactor Operating Systems: A Modern Perspective, Chapter 3

  14. Traditional OS Functions • To provide abstractions and manage those abstractions, split OS into 4 areas: • Device management • process, thread, and resource management • Memory management • File management Operating Systems: A Modern Perspective, Chapter 3

  15. Device Management • Device Management is the way that an OS handles generic devices • disks, tapes, terminals, printers treated in same general manner • Processor and RAM handled separately Operating Systems: A Modern Perspective, Chapter 3

  16. Device Management • Two parts to a device manager • device-dependent part (device driver) • implement unique aspects of device • e.g., device driver for keyboard must sense keystrokes • independent part • defines a general software environment in which the device driver operates • includes system call interface • includes mechanism to forward calls to correct driver • independent part is small part of device manager Operating Systems: A Modern Perspective, Chapter 3

  17. Device Management • Two parts to a device manager • makes it easier to add a device to a computer • independent part can work with wide range of devices • does not have to be rewritten for each device • e.g., one independent part for all postscript printers Operating Systems: A Modern Perspective, Chapter 3

  18. Device Management Device-Independent Part Device-Dependent Part Device-Dependent Part Device-Dependent Part … Device Device Device Operating Systems: A Modern Perspective, Chapter 3

  19. Process, Thread, and Resource Management • Process and Thread are basic units of computation • Resources are elements of the computing environment needed by a process so that its threads can execute. • The process manager implements the abstract machine: • the hardware processor resource • the thread resource • the memory resource (shared with memory manager) • physical resources • abstract resources such as messages Operating Systems: A Modern Perspective, Chapter 3

  20. Process, Thread, and Resource Management • Process, Thread, and Resource Manager (called the “process manager”) responsibilities: • Enforce isolation of resource access among processes • Allows sharing of resources among processes Operating Systems: A Modern Perspective, Chapter 3

  21. Process, Thread, and Resource Management Thread Abstraction Process Abstraction Generic Resource Manager Multiprogramming Other … Primary Memory Abstract Resources Processor Operating Systems: A Modern Perspective, Chapter 3

  22. Memory Management • Memory manager cooperates with the process manager to administer the allocation and use of primary memory • Allocates memory to competing processes according to specified policy • enforces resource isolation (memory protection) • allows sharing of memory • implements virtual memory (RAM + disk) • modern OS allow threads on one machine to access memory on another machine over a network. Operating Systems: A Modern Perspective, Chapter 3

  23. Memory Management Isolation & Sharing Virtual Memory Block Allocation Process Manager Primary Memory Storage Devices Operating Systems: A Modern Perspective, Chapter 3

  24. File Management • File manager implements the file abstraction on persistent storage devices like disks • different file abstractions provided • byte streams, records, etc. • modern OS allows file system to be distributed a network of machines • process can read/write to files stored on local system or other machines on the network Operating Systems: A Modern Perspective, Chapter 3

  25. OS implementation mechanisms • Processor modes. • Mode bit to distinguish between user and system • Kernels. • critical part of the OS. • designed as trusted software module. • Method of invoking system service. • how user processes request services from OS • System calls or message passing to a system process Operating Systems: A Modern Perspective, Chapter 3

  26. Processor Modes • Mode bit: Supervisor or User mode • Supervisor mode • Can execute all machine instructions • Can reference all memory locations • trusted code (kernel) operates in this mode • instructions in this mode called supervisor, privileged, or protected instructions • examples: I/O • user program cannot perform • must call kernel to perform I/O Operating Systems: A Modern Perspective, Chapter 3

  27. Processor Modes • Mode bit: Supervisor or User mode • User mode • Can only execute a subset of instructions • Can only reference a subset of memory locations Operating Systems: A Modern Perspective, Chapter 3

  28. Mode Bit Example • Resource access only done via supervisor mode • processor uses a hardware register to identify an object that is only accessible to the running process. • When process A uses the processor, the register points to A’s object. • When process B uses the processor, register points to B’s object. • Register can only be changed with a privileged instruction. Operating Systems: A Modern Perspective, Chapter 3

  29. Exclusive Access to a Resource Processor Process A Process B A’s Protected Object Supervisor Program Operating Systems: A Modern Perspective, Chapter 3

  30. Processor Modes • use mode bit to define areas of memory used when processor is in supervisor mode • when mode bit is in supervisor mode (kernel software executing) can access all memory • when mode bit is in user mode (application software executing) can access only user memory space Operating Systems: A Modern Perspective, Chapter 3

  31. Supervisor and User Memory User Space User Process Supervisor Process Supervisor Space Operating Systems: A Modern Perspective, Chapter 3

  32. Kernels • The part of the OS critical to correct operation (trusted software) • Executes in supervisor mode • The trap instruction is used to switch from user to supervisor mode, entering the OS Operating Systems: A Modern Perspective, Chapter 3

  33. trap instruction • Must ensure that when processor is in supervisor mode will only execute OS code • Mode bit is set by the user mode hardware instruction (called a trap) • changes mode bit to supervisor mode • simultaneously jumps to OS code • similar to a hardware interrupt • Trap calls are expensive Operating Systems: A Modern Perspective, Chapter 3

  34. trap instruction • Two techniques of requesting kernel service • System call • Message passing Operating Systems: A Modern Perspective, Chapter 3

  35. trap instruction • System Call • Use trap instruction • parameter indicates the service • actually a reference into the trap table • OS provides a library of “stub’ functions with names that are same as the system call Operating Systems: A Modern Perspective, Chapter 3

  36. send(…, A, …); receive(…, B, …); send/receive receive(…A, …); … send(…, B, …); Procedure Call and Message Passing Operating Systems call(…); trap return; Operating Systems: A Modern Perspective, Chapter 3

  37. System Call example • fork( ) system call has a stub function named fork( ) in the library • has the correct number and type of parameters • Each stub function contains a trap instruction to actual OS function • trap switches to supervisor mode • then branches via a jump table (called the trap table) to OS code • return from trap restores user mode Operating Systems: A Modern Perspective, Chapter 3

  38. System Call Using the trap Instruction … fork(); … Trap Table Kernel fork() { … trap N_SYS_FORK() … } sys_fork() sys_fork() { /* system function */ … return; } Operating Systems: A Modern Perspective, Chapter 3

  39. Message Passing • User process constructs a message A that requests a service • Uses an OS send( ) system call to pass message to kernel • send( ) function delivers message to a kernel process that implements the service • kernel process must be started or resumed before can receive message • start/resume sets mode to supervisor • send( ) effectively executes a trap • When kernel is finished, returns result • user process waits for result with a message receive( ) Operating Systems: A Modern Perspective, Chapter 3

  40. send(…, A, …); receive(…, B, …); send/receive receive(…A, …); … send(…, B, …); Procedure Call and Message Passing Operating Systems call(…); trap return; Operating Systems: A Modern Perspective, Chapter 3

  41. Comparison • System call interface more efficient • message requires implicit trap, message formation, message copying • system call just requires trap Operating Systems: A Modern Perspective, Chapter 3

  42. OS process • In system call model there is not a specific OS process • user process switches to supervisor mode then back • never create an explicit OS process • Exceptions: daemons • examples: printer daemon, network daemon • operate in user mode • exist to implement OS-like functionality Operating Systems: A Modern Perspective, Chapter 3

  43. A Thread Performing a System Call User Space Kernel Space Thread fork(); sys_fork() { } Operating Systems: A Modern Perspective, Chapter 3

  44. OS organization • Four functions of an OS • Process, Thread, Resource Manager • Memory Manager • File Manager • Device Manager • Each maintains data structures • other managers must read and write these DS Operating Systems: A Modern Perspective, Chapter 3

  45. File Manager Memory Manager Device Manager Basic Operating System Organization Process, Thread & Resource Manager Processor(s) Main Memory Devices Operating Systems: A Modern Perspective, Chapter 3

  46. OS organization • Examples: • Memory manager controls RAM • For VM, MM must coordinate with PM when it schedules processor (when to load into memory) • Must also coordinate with FM (to store on disk) • File manager controls disks • More efficient to buffer, I.e., FM reads from a storage device before it is requested • must coordinate with MM Operating Systems: A Modern Perspective, Chapter 3

  47. OS organization • Examples: • File manager controls disks • Must coordinate with DM to write to disk • Device manager • interrupts require coordination with PM Operating Systems: A Modern Perspective, Chapter 3

  48. Design Criteria • Software engineering suggests that each module should be separate • Efficiency suggests that there be no modules • UNIX: the 4 modules are combined into a single monolithic software module (the kernel) • functions in one module can directly call functions in another module • problem: changing a line in the PM can break code in the MM, etc. Operating Systems: A Modern Perspective, Chapter 3

  49. Design Criteria • Microkernel approach. • only implement necessary code in a microkernel • thread scheduling, hardware device management, fundamental protection mechanisms • rest of OS implemented as user function • remainder of process, memory, file, and device management functions Operating Systems: A Modern Perspective, Chapter 3

  50. Design Criteria • Microkernel approach. • problem: user space OS functions have to make may system calls • system calls are very inefficient • can microkernels be made fast enough so that extra performance cost is insignificant? • answer is still being researched Operating Systems: A Modern Perspective, Chapter 3

More Related