Operating System Organization
Create the Abstractions Purpose of an OS Coordinate Use of the Abstractions Processes The Abstractions Create the Abstractions
Process –What are involved ? All of the information needed to keep track of a process when switching is kept in a data package called a process control block.
The process control block typically contains: An ID number that identifies the process Pointers to the locations in the program and its data where processing last occurred Register contents States of various flags and switches
More … Pointers to the upper and lower bounds of the memory required for the process A list of files opened by the process The priority of the process The status of all I/O devices needed by the process
Thrashing This process swapping happens without direct user interference, and each process gets enough CPU cycles to accomplish its task in a reasonable amount of time. Trouble can come, though, if the user tries to have too many processes functioning at the same time. The operating system itself requires some CPU cycles to perform the saving and swapping of all the registers, queues and stacks of the application processes.
Thrashing If enough processes are started, and if the operating system hasn't been carefully designed, the system can begin to use the vast majority of its available CPU cycles to swap between processes rather than run processes. When this happens, it's called thrashing, and it usually requires some sort of direct user intervention to stop processes and bring order back to the system.
Thrashing When referring to a computer, "thrashing" or "disk thrashing" is a term used to describe when the hard disk drive is being overworked by moving information between the system memory and virtual memory excessively. Thrashing is often caused when the system does not have enough memory, the system swap file is not properly configured, and/or to much is running on the computer and it has low system resources.
Thrashing When thrashing occurs a user will notice the computer hard disk drive always working - a decrease in system performance. Thrashing is bad on a hard disk drive because of the amount of work the hard disk drive has to do and if is left unfixed will likely cause an early failure of the hard disk drive.
Resolve hard disk drive thrashing Increase the amount of RAM in the computer. Decrease the amount of programs being ran on the computer. Adjust the size of the swap file.
Swap Files A file stored on the computer hard disk drive that is used as a temporary location to store information that is not currently being used by the computer RAM. By using a swap file a computer has the ability to use more memory then what is physically installed in the computer. However, users who are low on hard disk space may notice that the computer runs slower because of the inability of the swap file to grow in size.
Swap Files OS Swap File Name Windows 95 / 98 / ME WIN386.SWP Windows NT / 2000 / XP PAGEFILE.SYS
OS Requirements 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
DOS -- Resource Abstraction Only Program Program Libraries Program OS Services ROM Routines Processor(s) Main Memory Devices
OS Requirements (cont) Provide resource abstractions Manage resource sharing Time/space-multiplexing Exclusive use of a resource Isolation Managed sharing
Abstraction & Sharing Libraries OS Services Abstraction Manage sharing Program State Process Program State Process Libraries Program State Process OS Services Abstraction Manage sharing ROM Routines Processor(s) Main Memory Devices
OS Design Constraints Performance Protection and security Correctness Maintainability Commercial factors Standards and open systems
Performance The OS is an overhead function should not use too much of machine’s resources Minimum functionality is to implement abstractions Additional function must be traded off against performance DOS: one process UNIX: low level file system
Protection & Security Multiprogramming resource sharing Therefore, need software-controlled resource isolation Security policy: Sharing strategy chosen by computer’s owner Protection mechanism: Tool to implement a family of security policies
Correctness & Maintainability Security depends on correct operation of software trusted vs untrusted software 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
Device Management … Device-Independent Part Device-Dependent Part
Process, Thread, and Resource Management Abstraction Process Abstraction Generic Resource Manager Multiprogramming Other … Primary Memory Abstract Resources Processor
Memory Management Process Manager Isolation & Sharing Virtual Memory Block Allocation Process Manager Primary Memory Storage Devices
Exclusive Access to a Resource Processor Process A Process B A’s Protected Object Supervisor Program
Processor Modes Mode bit: Supervisor or User mode Supervisor mode Can execute all machine instructions Can reference all memory locations User mode Can only execute a subset of instructions Can only reference a subset of memory locations
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
Supervisor and User Memory Space User Process Supervisor Process Supervisor Space
Procedure Call and Message Passing Operating Systems send(…, A, …); receive(…, B, …); receive(…A, …); … send(…, B, …); send/receive call(…); trap return;
System Call Using the trap Instruction … fork(); Trap Table Kernel fork() { … trap N_SYS_FORK() } sys_fork() sys_fork() { /* system function */ … return; }
A Thread Performing a System Call User Space Kernel Space Thread fork(); sys_fork() { }
Basic Operating System Organization File Manager Process, Thread & Resource Manager Memory Manager Device Manager Processor(s) Main Memory Devices
OS System Call Interface The UNIX Architecture Interactive User Libraries Commands Application Programs … OS System Call Interface Trap Table Device Driver Monolithic Kernel Module Process Management Memory Management File Management Device Mgmt Infrastructure Device Driver … Driver Interface Device Driver
Microkernel Organization Process Process Libraries Process User Supervisor Server Server Server Device Drivers Microkernel Processor(s) Main Memory Devices
Windows NT Organization Process Process T T Process T T T T Libraries T T T Process Management Memory Management File Management Device Mgmt Infrastructure Subsystem Subsystem Subsystem User Supervisor I/O Subsystem NT Executive NT Kernel Hardware Abstraction Layer Processor(s) Main Memory Devices
Hardware Abstraction Layer Monitoring the Kernel Process Process T Task Manager T Process T T T T Libraries T T T pview pstat Subsystem Subsystem Subsystem User Supervisor I/O Subsystem NT Executive NT Kernel Hardware Abstraction Layer Processor(s) Main Memory Devices