3. Banker's Algorithm
The resource-allocation graph algorithm is not applicable to a resource-allocation system with multiple instances of each resource type. The deadlock-avoidance algorithm that we describe next is applicable to such a system, but is less efficient than the resource- allocation graph scheme. This algorithm is commonly known as the banker's algorithm.
13.7.3 Deadlock Detection
If a system does not employ either a deadlock-prevention or a deadlock-avoidance algorithm, then a deadlock situation may occur.
• An algorithm that examines the state of the system to determine whether a deadlock has occurred
• An algorithm to recover from the deadlock
13.7.3.1 Single Instance of Each Resource Type
If all resources have only a single instance, then we can define a deadlock detection algorithm that uses a variant of the resource-allocation graph, called a wait-for graph. We obtain this graph from the resource-allocation graph by removing the nodes of type resource and collapsing the appropriate edges.
13.7.3.2 Several Instances of a Resource Type
The wait-for graph scheme is not applicable to a resource- allocation system with multiple instances of each resource type. The algorithm used are:
• Available: A vector of length m indicates the number of
available resources of each type.
• Allocation: An n x m matrix defines the number of resources of
each type currently allocated to each process.
• Request: An nxm matrix indicates the current request of each
process. If Request[i,j] = k, then process P, is requesting k more instances of resource.
13.7.3.3 Detection-Algorithm Usage
If deadlocks occur frequently, then the detection algorithm should be invoked frequently. Resources allocated to deadlocked processes will be idle until the deadlock can be broken.
13.7.4 Recovery from Deadlock
When a detection algorithm determines that a deadlock exists, several alternatives exist. One possibility is to inform the operator that a deadlock has spurred, and to let the operator deal with the deadlock manually. The other possibility is to let the system recover from the deadlock automatically.
There are two options for breaking a deadlock. One solution is simply to abort one or more processes to break the circular wait. The second option is to preempt some resources from one or more of the deadlocked processes.
13.7.4.1 Process Termination
To eliminate deadlocks by aborting a process, we use one of two methods. In both methods, the system reclaims all resources allocated to the terminated processes.
• Abort all deadlocked processes: This method clearly will
break the dead - lock cycle, but at a great expense, since these processes may have computed for a long time, and the results of these partial computations must be discarded, and probably must be recomputed
• Abort one process at a time until the deadlock cycle is eliminated: This method incurs considerable overhead, since
after each process is aborted a deadlock-detection algorithm must be invoked to determine whether a processes are still deadlocked.
13.7.4.2 Resource Preemption
To eliminate deadlocks using resource preemption, we successively preempt some resources from processes and give
these resources to other processes until he deadlock cycle is broken. The three issues are considered to recover from deadlock 1. Selecting a victim (to minimize cost)
2. Rollback (return to some safe state, restart process for that state)
3. Starvation (same process may always be picked as victim, include number of rollback in cost factor)
13.8
LET US SUM UP
• On media that uses constant linear velocity (CLV), the density of bits per track is uniform
• The ECC contains enough information, if only a few bits of data have been corrupted, to enable the controller to identify which bits have changed and calculate what their correct values should b
• AMaster Boot Record(MBR) is the first sector of a data
storage device that has been partitioned.
• AVolume Boot Record (VBR) is the first sector of a data
storage device that has not been partitioned, or the first sector of an individual partition on a data storage device that has been partitioned.
• A bad sector is asectoron a computer's disk driveorflash memory that cannot be used due to permanent damage (or an OS inability to successfully access it), such as physical damage to the disk surface (or sometimes sectors being stuck in a magnetic or digital state that cannot be reversed) or failed flash memory transistors.
• Swap-space management refers to the process where OS breaks the physical RAM that is structured with random access memory into some pitches of memory called pages.
• A variety of disk-organization techniques, collectively called redundant arrays of inexpensive disks (RAIDs) are commonly used to address the performance and reliability issues.
• The solution to the problem of reliability is to introduce redundancy; we store extra information that is not normally needed but that can be used in the event of failure of a disk to rebuild the lost information
• Whenever an equipment failure occurs during a write, the system must detect it, and return the system back to a consistent state
• In deadlock, processes never finish executing and system resources are tied up, preventing other jobs from ever starting
• If each resource type has several instances, then a cycle implies that a deadlock has occurred.
• Deadlock prevention is a set of methods for ensuring that at least one of the necessary cannot hold
• Deadlock avoidance requires the operating system to have, in advance, additional information concerning which resources a process will request and use during its lifetime
13.9 UNIT END QUESTIONS
1. Define boot block and bad blocks.
2. Describe various RAID levels with the help of diagrams.
3. What are deadlocks? What are the necessary conditions arised in a deadlock situation?
4. How to:
a) Detect a deadlock
b) Recover from a deadlock 5. Define a. Low-level formatting b. Swap Space c. RAID d. Mirroring
14
I/O SYSTEMS
Unit Structure
14.0 Objectives 14.1 Introduction
14.2 Application I/O Interface
14.2.1 Block and Character Devices 14.2.2 Network Devices
14.2.3 Clocks and timers
14.2.4 Blocking and non-blocking I/O
14.3 Transforming I/O Requests to Hardware Operations 14.4 Streams
14.5 Performance 14.6 Let Us Sum Up 14.7 Unit End Questions
14.0 OBJECTIVES
After reading this unit you will be able to:
• Discuss structuring techniques and interfaces for the operating system that enable I/0 devices to be treated in a standard, uniform way.
• Explain how an application can open a file on a disk without knowing what kind of disk it is and how new disks and other devices can be added to a computer without disruption of the operating system
14.1 INTRODUCTION
Management of I/O devices is a very important part of the operating system - so important and so varied that entire I/O subsystems are devoted to its operation. (Consider the range of devices on a modern computer, from mice, keyboards, disk drives, display adapters, USB devices, network connections, audio I/O, printers, special devices for the handicapped, and many special- purpose peripherals)
I/O Subsystems must contend with two trends:
(1) The gravitation towards standard interfaces for a wide range of devices, making it easier to add newly developed devices to existing systems, and
(2) The development of entirely new types of devices, for which the existing standard interfaces are not always easy to apply.
Device drivers are modules that can be plugged into an OS to handle a particular device or category of similar devices.
14.2
APPLICATION I/O INTERFACE
I/O system calls encapsulate device behaviors in generic classes. Device-driver layer hides differences among I/O controllers from kernel. Devices vary in many dimensions:
• Character-stream or block
• Sequential or random-access
• Sharable or dedicated
• Speed of operation
• Read-write, read only, or write only