Operating Systems Structure Monolithic systems basic structure: A main program that invokes the requested service procedure. A set of service procedures that carry out the system calls. A set of utility procedures that help the service procedures.
Microkernels Figure 1-26. Structure of the MINIX 3 system.
Client-Server Model Figure 1-27. The client-server model over a network.
Virtual Machines Figure 1-29. (a) A type 1 hypervisor. (b) A type 2 hypervisor.
The Classical Thread Model (1) Figure 2-11. (a) Three processes each with one thread. (b) One process with three threads.
POSIX Threads (1) Figure 2-14. Some of the Pthreads function calls.
Mutexes Figure 2-29. Implementation of mutex lock and mutex unlock.
Scheduling in Interactive Systems Round-robin scheduling Priority scheduling Multiple queues Shortest process next Guaranteed scheduling Lottery scheduling Fair-share scheduling
Round-Robin Scheduling Figure 2-41. Round-robin scheduling. (a) The list of runnable processes. (b) The list of runnable processes after B uses up its quantum.
Page Replacement Algorithms Optimal page replacement algorithm Not recently used page replacement First-In, First-Out page replacement Second chance page replacement Clock page replacement Least recently used page replacement Working set page replacement WSClock page replacement
Optimal Page Replacement Sequence of Pages: 1 2 3 4 1 2 5 1 2 3 4 5
FIFO Page Replacement Algorithm Sequence of Pages: 1 2 3 4 1 2 5 1 2 3 4 5
File Systems (2) Think of a disk as a linear sequence of fixed-size blocks and supporting reading and writing of blocks. Questions that quickly arise: How do you find information? How do you keep one user from reading another s data? How do you know which blocks are free?
File Operations The most common system calls relating to files: Create Delete Open Close Read Write Append Seek Get Attributes Set Attributes Rename
Directory Operations System calls for managing directories: Create Delete Opendir Closedir Readdir Rename Link Unlink
File System Layout Figure 4-9. A possible file system layout.
I-nodes Figure 4-13. An example i-node.
Keeping Track of Free Blocks Figure 4-22. (a) Storing the free list on a linked list. (b) A bitmap.
The UNIX V7 File System (2) Figure 4-34. A UNIX i-node.
I/O Devices Figure 5-1. Some typical device, network, and bus data rates.
Introduction To Deadlocks Deadlock can be defined formally as follows: A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.
Conditions for Resource Deadlocks 1. Mutual exclusion condition 2. Hold and wait condition. 3. No preemption condition. 4. Circular wait condition.
Resource Acquisition (2) Figure 6-2. (a) Deadlock-free code.
Resource Acquisition (3) Figure 6-2. (b) Code with a potential deadlock.
Deadlock Detection with Multiple Resources of Each Type (1) Figure 6-6. The four data structures needed by the deadlock detection algorithm.
Deadlock Detection with Multiple Resources of Each Type (2) Deadlock detection algorithm: 1. Look for an unmarked process, P i, for which the i-th row of R is less than or equal to A. 2. If such a process is found, add the i-th row of C to A, mark the process, and go back to step 1. 3. If no such process exists, the algorithm terminates.
Deadlock Detection with Multiple Resources of Each Type (3) Figure 6-7. An example for the deadlock detection algorithm.
The Banker s Algorithm for Multiple Resources (1) Algorithm for checking to see if a state is safe: 1. Look for row, R, whose unmet resource needs all A. If no such row exists, system will eventually deadlock since no process can run to completion 2. Assume process of row chosen requests all resources it needs and finishes. Mark process as terminated, add all its resources to the A vector. 3. Repeat steps 1 and 2 until either all processes marked terminated (initial state was safe) or no process left whose resource needs can be met (there is a deadlock).
The Banker s Algorithm for Multiple Resources (2) Figure 6-12. The banker s algorithm with multiple resources.