Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location XX, increments it by the value ii, and returns the old value of XX. It is used in the pseudocode shown below to implement a busy-wait lock. LL is an unsigned integer shared variable initialized to 00. The value of 00 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
L = 1;
L = 0;
Hello everyone , i got answer of this question.But i want to ask a question that where is CRITICAL SECTION PART ? AFTER THE FIRST BLOCK ? THAT IS AFTER WHILE LOOP ? if yes then there may also a case arise when after critical section work completion ,process can get preempted ( that is it get preempted before changing the lock value to 0 ).that mean there are chances of preemption before ReleaseLock function but after completion of critical section .so there are chances that our lock is free but a process will never be able to acquire lock untill preempted process get resumed and perform its Release lock function .AM I RIGHT ?