Professional Documents
Culture Documents
MAWEDEK KARIOKI
Q1
(a) Explain the term “deadlock” as used in operating systems deadlock is a
state in which each member of a group is waiting for another member, including itself, to
take action, such as sending a message or more commonly releasing a lock. In a
multiprogramming environment, several processes may compete for a finite number of
resources. A process requests resources; if the resources are not available at that time, the
process enters a wait state. It may happen that waiting processes will never again change
state, because the resources they have requested are held by other waiting processes. This
situation is called deadlock.
(b) List and explain the four conditions necessary for a deadlock to occur.
1.Mutual exclusion: At least one resource must be held in a non-sharable mode; that is,
only one process at a time can use the resource. If another process requests that
resource, the requesting process must be delayed until the resource has been released.
The mutual-exclusion condition must hold for non-sharable resources. For example, a
printer cannot be simultaneously shared by several processes. Sharable resources, on
the other hand, do not require mutually exclusive access, and thus cannot be involved
in a deadlock.
2.Hold and wait: a process is currently holding at least one resource and requesting
additional resources which are being held by other processes.
There must exist a process that is holding at least one resource and is waiting to
acquire additional resources that are currently being held by other processes. 3.No
preemption: Resources cannot be preempted; that is, a resource can be released only
voluntarily by the process holding it, after that process, has completed its task.
If a process that is holding some resources requests another resource that cannot be
immediately allocated to it, then all resources currently being held are preempted. That
is these resources are implicitly released. The preempted resources are added to the
list of resources for which the process is waiting process will be restarted only when it
can regain its old resources, as well as the new ones that it is requesting.
4.Circular wait: There must exist a set {P0, P1, ..., Pn} of waiting processes such that
P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held
by P2, …., Pn-1 is waiting for a resource that is held by Pn, and Pn is waiting for a
resource that is held by P0.
(c) Discuss the techniques used by operating systems to: -
I)Detect a deadlocked condition Under the deadlock detection, deadlocks are allowed to occur.
Then the state of the system is examined to detect that a deadlock has occurred and subsequently it is
corrected. An algorithm is employed that tracks resource allocation and process states, it rolls back
and restarts one or more of the processes in order to remove the detected deadlock. 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.
Q2
(a) Discuss the following file organization methods used by operating systems: -
(i) Serial method
Serial method is where data records are stored one after the other with no regard to the order. This is
usually an unprocessed file. Serial files are read by starting at the beginning and reading through
every record until you find the one that you want. The records are in no particular order so you need
to start of the beginning to make sure you don't miss a record. Magnetic Tape and disks can be used
to store serial files.
The disk is a direct access device which gives us the reliability to random access of any file block. In
the file, there is a collection of physical blocks and the records of that blocks.
E.g. Databases are often of this type since they allow query processing that involves immediate access
to large amounts of information. All reservation systems fall into this category.
Any item can be retrieved almost immediately, provided its position in the file is known. (there is a
delay in calculating the address and then moving the (correct area).
iv)Indexed sequential method is a modification of the direct access method. it is combination of
both the sequential access as well as direct access. The main idea of this method is to first access the
file directly and then it accesses sequentially. In this access method, it is necessary for maintaining an
index. The index is nothing but a pointer to a block. The direct access of the index is made to access a
record in a file. The information which is obtained from this access is used to access the file.
Sometimes the indexes are very big, so to maintain all these hierarchies of indexes are built in which
one direct access of an index leads to information of another index access.