# GATE1999-20-a

1.9k views

A certain processor provides a 'test and set' instruction that is used as follows:

  TSET register, flag

This instruction atomically copies flag to register and sets flag to $1$. Give pseudo-code for implementing the entry and exit code to a critical region using this instruction.

edited
0
option B shows the disadvantages of using sleep() and wait() calls as wakeups can't be saved for the future use. And thus we go for the semaphores.
0
why did you removed part b
1

The question is incomplete. Please do complete it...

https://www.geeksforgeeks.org/gate-gate-cs-1999-question-68/

1. TSET $R1$, flag
2. CMP $R1, \#0$
3. JNZ Step$1$
4. $[CS]$