List and describe the 4 preconditions that have to be present for a deadlock to form.
Mutual Exclusion: Only one process may hold a protected resource at a time. No process may access a resource that is being held by a different process.
Hold and Wait: A process is allowed to hold a process while waiting to hold a process being held by a different process.
No Preemption: A process cannot be forced to release the resources it holds.
Circular Wait: A deadlock is a set of blocked process where each process is blocked waiting for a resource that is being held by another blocked process in the set.
What does it mean to ‘allow preemption’ of a process’s ownership of a held resource (e.g. the Bank Account example) in order to break a deadlock?
What is the problem with implementing the preemption of the resources held by a process involved in a deadlock set? Hint: Can we rollback a process’s state?
What is the only general solution to causing a process to release its ownership of the resources it holds / owns?
Preemption means for the OS to somehow cause a selected process in the deadlock set to release the resources it holds (has locked) allowing other processes in the deadlock set access to those resources and to make progress i.e. to break the deadlock.
The problem is that it is normally impossible to ‘roll back’ a process to the state it was in before it locked the contested resource. For example, the process may have modified local or static variables. The process might also have modified some shared / global resource such as a file or global data structure. These types of changes cannot be ‘undone’ and so preemption is impossible. Also know that DBMS allow the rollback of changes made to tables and so can rollback a transaction started by a process.
The only general solution to causing a process to release ownership of its resources is to terminate the process.
Describe the method presented in the book and slides of preventing deadlocks because of the “Circular Wait” precondition. Hint: Ordered Resource Locks
How would this method be applied to preventing the deadlock for the “transfer funds between two bank accounts” operation described in class? That is, an operation that locks two bank accounts with the goal of transferring funds from Account1 to Account2.
The method of avoiding ‘circular wait’ involves assigning a ordering / priority to the system’s resources that determine the order in which the resources must be requested. This method prevents processes from requesting resources in an order that creates a circular dependency.
The example had the transfer operation lock the resources in the numerical or alphabetical order of the bank account’s ID. The two processes would always attempt to lock accounts in the same order making deadlock impossible
Describe both the logical and physical views of a process image’s memory addresses.
What is the device that translates from logical to physical addressing?
Logical View: The logical view of the process image is the illusion that the image is installed in a contiguous range of memory addresses that starts at address zero and extend to N (the image size). The process logical address space is owned by the process and is separate from all other process images. That is, that every process has its own private 0-N address space.
Physical View: The physical view of the process image is the reality that all process images share common physical memory range of 0–M where M is the amount of system memory. Each process is installed into a memory partition at unique addresses in physical memory. Partitions can be relocated to new addresses, and with paged memory management can be placed in non-contiguous (non-adjacent) memory regions.
The translation from logical to physical addresses is primarily accomplished by the system’s Memory Management Unit hardware.
Consider a simple paging system with the following parameters:
* 2^32 bytes of physical memory address range.
* A page size of 2^10 bytes.
What are the two characteristics of simple memory paging that lead to, and the fundamental idea defines virtual memory? Hint: Three parts in slides.
The two characteristics of simple paging are:
1. Because of the indirection between logical and physical addresses made possible with the page table, a process’s pages can be located in any frame of memory and can be moved (relocated) from one frame to another.
2. The frames occupied by a process’s pages do not need to be contiguous i.e. they can be spread throughout physical memory.
And the fundamental idea in virtual memory is:
3. Not all of a process’s pages need to be resident in physical memory for the process to execute. Only those pages in the process’s working set need to be resident.
The resident set is the set of process pages that are resident in memory i.e. are contained in a memory frame.
A resident set that is too small will cause an increase in the number of page faults and so will cause the process to begin thrashing.
A resident set that is too large wastes memory (frames) by maintaining process pages in memory that are no longer being referenced by the process. This has the effect of reducing the overall number of processes that can be maintained in memory.
Describe the problem with fairness with Preemptive Round-Robin scheduling WRT I/O-bound processes vs. compute-bound processes.
RR scheduling allows a process to complete its quantum (time-slice) and then schedules the next process at the head of the queue. A compute-bound process will likely execute for its full quantum without blocking. However, an I/O-bound process is more likely not to use its entire quantum before being blocked (I/O) and rescheduled when the I/O operation completes. Thus because an I/O-bound process seldom finishes its quantum before blocking, it will receive less processor time than a compute-bound process.
Raid 1 is also known as “disk mirroring” where data is duplicated across (written to and read from) two disks.
1. Data on the logical RAID drive is protected from a single-disk failure.
2. A read request can be serviced by either of two disks and two read requests can be executed concurrently.
3. Even though both disks need to be updated for a write operation, the write can be executed concurrently on both disks.
Disadvantage: Because a block is mirrored on two disks, RAID1 uses only half the physical capacity of the RAID.
The advantage of RAID2-6 is that redundancy is obtained with only a single additional disk that maintains the stripe’s parity information. (unlike RAID1 which requires 2x the disks).
When RAID2-6 loses a data disk, the data must be reconstructed dynamically by reading from each of the remaining blocks in the missing block’s strip plus the parity block to reconstruct data from the missing disk. That is, N-1 block reads to reconstruct blocks from the missing disk.
Describe the purpose of the File Descriptor.
File descriptors are a resource created and managed by the operating system. File descriptors are a data structure created by system calls that create new files or open existing files. The file descriptor is used by system calls that manipulate the contents of a file i.e. read, write, seek, etc. The file descriptor maintains state information about the open file e.g. the stream index (position) of the next read or write operation on the open file.