Lecture 11 Deadlocks and Devices
Last Time CPSC Tyson Kendon Concurrency Some notes about Semaphores Spinlocks Classical Synchronization Problems Monitors Monitor Construction Condition Variables Using Monitors Java
This Time CPSC Tyson Kendon Deadlocks Resource Allocation Detecting Deadlocks Resolving Deadlocks Devices Hosts and Controllers I/O Drivers
Deadlocks CPSC Tyson Kendon Two or more processes are unable to proceed because each is waiting for another process (which is waiting) to proceed.
System Model CPSC Tyson Kendon Processes Resources Requests Request Use Release
Deadlock Characterization CPSC Tyson Kendon Mutual Exclusion - resources cannot be shared, a second request must be delayed 2.Hold and wait - A process must be holding a resource and waiting for another resource 3.No preemption - resources cannot be taken from a process once it has them 4.Circular waiting - For a set of processes {P 1,..., P n } then P 1 must wait for P 2, which must wait for P 3 … which must wait for P n, which must wait for P 1
Resource-Allocation Graphs CPSC Tyson Kendon 20166
Handling Deadlocks CPSC Tyson Kendon 20167
Preventing Deadlocks CPSC Tyson Kendon Prevent one of the four characterizations from holding.
Avoiding Deadlocks CPSC Tyson Kendon Decide (at runtime) which situations are safe and which will lead to Deadlocks.
Detecting Deadlocks CPSC Tyson Kendon Look at our processes and resources and determine if they are deadlocked.
Recovering From Deadlocks CPSC Tyson Kendon Look at our processes and resources restore them to a point where the system is free of deadlocks.
Devices and I/O CPSC Tyson Kendon
Devices and Hardware CPSC Tyson Kendon Host the CPU / Memory and OS, ”the computer” Controller the electronics and logic that operate the device, port or bus
Working with Controllers CPSC Tyson Kendon Registers Keep registers available to pass data can control between host and controller Memory Mapped I/O Map information from/for the controller directly into virtual memory
Controlling Controllers CPSC Tyson Kendon Polling OS Loops and waits for the device to work Interrupts Device does its work and interrupts the host Direct Memory Access Device moves a lot of memory then interrupts
Drivers CPSC Tyson Kendon Interface Define how a type of device should behave Driver Write the software to conform the device to the interface the OS expects
Device Characteristics aspectvariationexample Data-transfer modeCharacter block Terminal disk Access methodSequential random Modem DVD Transfer scheduleSynchronous asynchronous Tape keyboard sharingDedicated shareable Tape keyboard CPSC Tyson Kendon
Device Characteristics (2) CPSC Tyson Kendon Device speedLatency Seek time Transfer rate Delay between ops Electronic? - memory Physical? - disk Mechanical? – tape- robot I/O directionRead-only Write-only read-write DVD Graphics controller disk
Next Time CPSC Tyson Kendon File Systems and Disks How do we organize data on secondary storage to make sense and access it quickly Devices What considerations do we have to make about the OS to work with Devices Multiprocessor Environments