GateQuestiononTestAndSetInstruction|Gate questions discussion part5

Опубликовано: 25 Октябрь 2024
на канале: TechGuiders
265
4

GateQuestiononTestAndSetInstruction

The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
while(test-and-set(X));
}
void leave_CS(X)
{
X = 0;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0.
a)The above solution to CS problem is deadlock-free
b)The solution is starvation free
c)The processes enter CS in FIFO order
d)More than one process can enter CS at the same time





#gatequestionsonprocesssynchronization
#operatingsystem
#gatequestionsoperatingsystem
#testandsetinstruction
#swapinstruction
#swapandtestandsetinstruction