1.Define entry
section and exit section.
The critical section problem is to
design a protocol that the processes can use to cooperate. Each process must
request permission to enter its critical section. The section of the code
implementing this request is the entry section. The critical section is
followed by an exit section. The remaining code is the remainder section.
2.Give two hardware
instructions and their definitions which can be used for implementing mutual exclusion.
• TestAndSet
boolean
TestAndSet (boolean &target)
{
boolean
rv = target; target = true; return rv;
}
• Swap
void Swap
(boolean &a, boolean &b)
{
boolean
temp = a; a = b;
b = temp;
}
3.What is
semaphores?
A semaphore 'S' is a synchronization
tool which is an integer value that, apart from initialization, is accessed
only through two standard atomic operations; wait and signal.Semaphores can be
used to deal with the n-process critical section problem. It can be also used
to solve various Synchronization problems.
4.Define busy
waiting and spinlock.
When a process is in its critical
section, any other process that tries to enter its critical section must loop
continuously in the entry code. This is called as busy waiting and this type of
semaphore is also called a spinlock,because the process while waiting for the
lock.
5.Define
deadlock.
A process requests resources; if the
resources are not available at that time, the process enters a wait state.
Waiting processes may never again change state, because the resources they have
requested are held by other waiting processes. This situation is called a
deadlock.
6.What is the
sequence in which resources may be utilized?
Under normal mode of operation, a
process may utilize a resource in the following sequence:
•
Request: If the request cannot be
granted immediately,then the requesting process must wait until it can acquire
the resource.
•
Use:
The process can operate on the resource.
•
Release:
The process releases the resource.
7.What are
conditions under which a deadlock situation may arise?
A deadlock situation can arise if the following four
conditions hold simultaneously in a system:
a. Mutual exclusion
b. Hold and wait
c. No pre-emption
8.What is a
resource-allocation graph?
Deadlocks can be described more
precisely in terms of a directed graph called a system resource allocation
graph. This graph consists of a set of vertices V and a set of edges E. The set
of vertices V is partitioned into two different types of nodes; P the set
consisting of all active processes in the system and R the set consisting of
all resource types in the system.
9.Define
request edge and assignment edge.
A directed edge from
process Pi to resource type Rj is denoted by Pià Rj; it signifies that process
Pi requested an instance of resource type Rj and is currently waiting for that
resource. A directed edge from resource type Rj to process Pi is denoted by
Rjà Pi, it signifies that an instance of resource type has been allocated to a
process Pi. A directed edge Pià Rj is called a request edge. A directed edge
Rjà Pi is called an assignment edge.
10.What are the
methods for handling deadlocks?
The deadlock problem can be dealt with
in one of the three ways:
a.
Use a protocol to prevent or avoid
deadlocks, ensuring that the system will never enter a deadlock state.
b. Allow the system
to enter the deadlock state, detect it and then recover.
c.
Ignore
the problem all together, and pretend that deadlocks never occur in the system.
No comments:
Post a Comment