Awesome q2a theme
0 votes
7 views

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.

AcquireLock(L){
   while (Fetch_And_Add(L,1)) 
      L = 1;
}

ReleaseLock(L){ 
   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 ?

ago in Operating System by (6 points) | 7 views

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users 2020 Aug 03 - 09
  1. Ashutosh07091999

    18 Points

  2. Mellophi

    13 Points

  3. prashastinama

    6 Points

  4. manas_kulkarni

    4 Points

  5. srestha

    2 Points

  6. Unnayan kumar

    1 Points

  7. aryashah2k

    1 Points

  8. Jhaiyam

    1 Points

  9. prabhat0987

    1 Points

  10. Kushagra गुप्ता

    1 Points

Weekly Top User (excluding moderators) will get free access to GATE Overflow Test Series for GATE 2021
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Aug 2020
  1. Ashutosh07091999

    21 Points

  2. Mellophi

    19 Points

  3. Unnayan kumar

    8 Points

  4. Sourav Kar

    7 Points

  5. anurag_yo

    7 Points

  6. Shaik Masthan

    7 Points

  7. prashastinama

    6 Points

  8. sureshthiyam

    6 Points

  9. manas_kulkarni

    6 Points

  10. srestha

    4 Points

7,688 questions
1,815 answers
11,053 comments
95,077 users