All the processes coming in next are added to the ready queue with respect to their process number, not necessarily sequentially. A ready queue is maintained with respect to the process in the critical section. Unlock and Lock Algorithm uses TestAndSet to regulate the value of lock but it adds another value, waiting, for each process which checks whether or not a process has been waiting. and individual key initialized to false Swap Pseudocode – // Shared variable lock initialized to false However, again bounded waiting is not ensured for the very same reason.
Again, out of the critical section, lock is changed to false, so any process finding it gets t enter the critical section. So, again, when a process is in the critical section, no other process gets to enter it as the value of lock is true. Instead of directly setting lock to true in the swap function, key is set to true and then swapped with lock. Swap algorithm is a lot like the TestAndSet algorithm. Test and Set Pseudocode – //Shared variable lock initialized to false
Introduction of Process Synchronization.Hardware Synchronization Algorithms : Unlock and Lock, Test and Set, Swap.ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.