If all processes lock the semaphore table before using it


To make it possible to implement semaphores on a computer with multiple CPUs that share a common memory, computer architects often provide a Test and Set Lock in- struction. TSL X tests the location X. If the contents are zero, they are set to 1 in a sin- gle, indivisible memory cycle, and the next instruction is skipped. If it is nonzero, the TSL acts like a no-op. Using TSL it is possible to write procedures lock and unlock with the following properties. lock(x) checks to see if x is locked. If not, it locks x and re- turns control. If x is already locked, it just waits until it becomes unlocked, then it locks x and returns control. unlock releases an existing lock. If all processes lock the semaphore table before using it, only one process at a time can fiddle with the variables and pointers, thus preventing races. Write lock and unlock in assembly language. (Make any reasonable assumptions you need.)

Solution Preview :

Prepared by a verified Expert
Assembly Language: If all processes lock the semaphore table before using it
Reference No:- TGS01154898

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)