Showing posts with label deadlock. Show all posts
Showing posts with label deadlock. Show all posts

Saturday, December 12, 2015

deadlock



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.