Monday, April 7, 2014

What is Deadlock in operating system?

[UGC NET Computer science]
Resources are allocated to the process on non-shareable basis is
[Paper II June 2012]
(A) mutual exclusion
(B) hold and wait
(C) no pre-emption
(D) circular wait

Answer is A and Conceptually explanation of the above question is given below.



What is Deadlock?
The processes may block each other. Nobody can use the resource. Deadlock can only occur if the processes need more than one resource at the same time.

When Deadlock may arise?
     Deadlock may arise if the following four conditions hold simultaneously:
1. Mutual exclusion. : - Non-sharable resources are used. Only one process can use the resource at any given instant of time.
2. Hold and wait. : - A process holds at least one resource and requests another resource that is held by another process.
3. No preemption. : - Resources that a process holds, can only be voluntarily released by the process itself. The operating system must not de-allocate resources once they have been allocated; they must be released by the holding process voluntarily.
4. Circular wait. : - A circular chain of processes exist, in which each process holds a resource requested by the next process in the chain. Process such that P1 is waiting for a resource held by process P2, process P2 is waiting for a resource held by process P3 and so on until process Pn is waiting for a resource held by process P1.  This is a circular wait.

What is Mutual Exclusion?
Mutual exclusion (often abbreviated to mutex). It is the one of the situation which can cause for deadlock when non sharable devices or resources are accessed by more than one task or processes. Non sharable means only one person or process can access that device or resource.
When more than one process wants the same resource, then Race condition may occur. Race Condition means more than one processes or task are trying to access the same resource.  
Mutual Exclusion make sure at most one process may enter a critical section.

What is a critical section?
It is the program section accessing shared resource(s), only one process can be in this section at a time.
Data errors or inconsistencies may occur when shared resources or devices are access and modified at the same time by more than one resource.
Sections of a program that might cause these problems are called critical section.
A critical section will terminate in fixed given time and a process, thread or task will have to wait for a fixed time to enter.
     When failure to control the access to a critical section is called a race condition because success or failure depends on the ability of one process to exit the critical section before another process enters the critical section.

What is Concurrent programming?
Concurrent programming is a form of computing in which several computations are executing during overlapping time periods concurrently  instead of sequentially.

No comments:

Post a Comment