Dead Lock:-
A Deadlock is a situation concerning a set of processes in which each process in the set waits for an event that must be caused by another process in the set. Each process is then waiting for an event that cannot occur.
Prevention in Dead Lock:-
1)Non-shareable Resources:-Wait-for relations will not exist in the system if all resources could be made shareable. This way paths in an RRAG would contain only allocation edges, so circular waits could not arise. Figure 8.6(a) illustrates the effect of employing this approach: the request edge (Pi, Rl) would be replaced by an allocation edge (Rl, Pi) because the resource unit of class Rl is shareable.
2)Preemption of Resources:-If resources are made preemptible, the kernel can ensure that some processes have all the resources they need, which would prevent circular paths in RRAG. Resource Rl can be preempted from its current holder and allocated to process Pi. However, non-pre-emptibility of resources can be circumvented only selectively. The page formatting approach of the THE system can be used to make printers preemptible, but, in general, sequential I/O devices cannot be preempted.
3)Hold-and-Wait:-To prevent the hold-and-wait condition, either a process that holds resources should not be permitted to make resource requests, or a process that gets blocked on a resource request should not be permitted to hold any resources. Thus, in Figure 8.6(c), either edge (Pi, Rl) would not arise, or edge (Rk, Pl) would not exist if (Pi, Rl) arises. In either case, RRAG paths involving more than one process could not arise, and so circular paths could not exist. A simple policy for implementing this approach is to allow a process to make only one resource request in its lifetime in which it asks for all the resources it needs.
4)Circular Wait:- A circular wait can result from the hold-and-wait condition, which is a consequence of the non-shareability and non-perceptibility conditions, so it does not arise if either of these conditions does not arise. Circular waits can be separately prevented by not allowing some processes to wait for some resources.
Deadlock Detection:-
1)If resources have a single instance:-In this case for Deadlock detection, we can run an algorithm to check for the cycle in the Resource Allocation Graph. The presence of a cycle in the graph is a sufficient condition for deadlock.
2) If there are multiple instances of resources:-Detection of the cycle is a necessary but not sufficient condition for deadlock detection, in this case, the system may or may not be in deadlock varies according to different situations.
Deadlock Avoidance Persistence:-
Deadlock avoidance can be done with Banker’s Algorithm.
Banker's Algorithm:- Bankers’ Algorithm is a resource allocation and deadlock avoidance algorithm which test all the request made by processes for resources, it checks for the safe state, and if after granting a request system remains in the safe state it allows the request and if there is no safe state it doesn’t allow the request made by the process.
I/O Devices:-The role of the operating system in computer I/O is to manage and control I/O operations and I/O devices. An I/O system is required to take an application I/O request and send it to the physical device, then take whatever response comes back from the device and send it to the application.
An I/O port typically consists of four registers, called the status, control, data-in, and data-out registers.
• The data-in register is read by the host to get input.
• The data-out register is written by the host to send output.
• The status register contains bits that can be read by the host. These bits
indicate states, such as whether the current command has been completed,
whether a byte is available to be read from the data-in register, and whether
a device error has occurred.
• The control register can be written by the host to start a command or to
change the mode of a device. For instance, a certain bit in the control
register of a serial port chooses between full-duplex and half-duplex
communication, another bit enables parity checking, a third bit sets the
word length to 7 or 8 bits, and other bits select one of the speeds supported
by the serial port.
Hard disk Drives:- A hard disk is a memory storage device. The basic interface for all modern drives is straightforward. The drive consists of a large number of sectors (512-byte blocks), each of which can be read or written. The sectors are numbered from 0 to n − 1 on a disk with n sectors. Thus, we can view the disk as an array of sectors; 0 to n − 1 is thus the address space of the drive.
Multi-sector operations are possible; indeed, many file systems will read or write 4KB at a time (or more). However, when updating the disk, the only guarantee drive manufacturers make is that a single 512-byte write is atomic (i.e., it will either complete in its entirety or it won’t complete at all); thus, if an untimely power loss occurs, only a portion of a larger write may complete (sometimes called a torn write).
Redundant Array of Inexpensive Disks(RAID):-We introduce the Redundant Array of Inexpensive Disks better known as RAID [P+88], a technique to use multiple disks in concert to build a faster, bigger, and more reliable disk system. The term was introduced in the late 1980s by a group of researchers at U.C. Berkeley (led by Professors David Patterson and Randy Katz and then student Garth Gibson); it was around this time that many different researchers simultaneously arrived upon the basic idea of using multiple disks to build the best storage system [BG88, K86,K88,PB86,SG86].
Externally, a RAID looks like a disk: a group of blocks one can read or write. Internally, the RAID is a complex beast, consisting of multiple disks, memory (both volatile and non-), and one or more processors to manage the system. A hardware RAID is very much like a computer system, specialized for the task of managing a group of disks.