(a) Draw the process state transition diagram of an OS in which (i) each…

PYQ GATE 2002

(a) Draw the process state transition diagram of an OS in which (i) each process is in one of the five states: created, ready, running, blocked (i.e. sleep or wait), or terminated, and (ii) only non-preemptive scheduling is used by the OS. Label the transitions appropriately.

(b) The functionality of atomic TEST-AND-SET assembly language instruction is given by the following C function.

int TEST-AND-SET (int *x)
{
    int y;
    A1:y=*x;
    A2:*x=1;
    A3:return y;
}

(i) Complete the following C functions for implementing code for entering and leaving critical sections based on the above TEST-AND-SET instruction.

int mutex=0;
void enter-cs()
{
    while (…………………………………);
}
void leave-cs()
{
    …………………………………..;
}

(ii) Is the above solution to the critical section problem deadlock free and starvation-free? (iii) For the above solution, show by an example that mutual exclusion is not ensured if TEST-AND-SET instruction is not atomic.

Sign up free to check your answer

Sign up free

Explore the full course: Operating System

Loading lesson…