Q32
MCQ2 marks, −0.67Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location , increments it by the value , and returns the old value of . It is used in the pseudocode shown below to implement a busy-wait lock. is an unsigned integer shared variable initialized to . The value of corresponds to lock being available, while any non-zero value corresponds to the lock being not available. AcquireLock(L){ while (Fetch_And_Add(L,1)) L = 1; } ReleaseLock(L){ L = 0; } This implementation
Sign in to save attempts.
Loading…