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.

Saturday, March 29, 2014

What is Macro & Macro Processor in System Software and Compiler?

Macro & Macro Expansion
*******

  • Macro works same as subroutine or a function which is used repeatedly whenever we required. Macro definition paced at starting of the program and Macro definition is started using word MACRO and end with word MEND.
  • Each macro should have a unique name.
  • Below is an example of Macro.
           MACRO ----> From here macro has started.        
             INCR &X,&Y ----> This is the declaration of prototype statement of Macro.
             LOAD  &X   ___
             ADD    &Y          |------>
             STORE &X   ___|------> This is the Macro definition. 
        MEND                
  • Now we can use INCR macro in assembly langunage, the assembler will automatically place the LOAD, ADD & STORE opcode with its operand.
  • e.g.
         INCR A,B ---> this statement will do three things instead of INCR A,B
                                  LOAD A 
                                  ADD B
                                  STORE A   
  • The above statement is called Macro Expansion.