2
$\begingroup$

Why the busy waiting is not eliminated even after we put the current process into the process list and "block()"ed it? So even if the process is in waiting state we still call it "busy waiting"?

I'm reading Operating System Concepts, Silberschatz, 9th ed., pages 215~217.

highlighted part

sema1

sema2

$\endgroup$

1 Answer 1

3
$\begingroup$

So even if the process is in waiting state we still call it "busy waiting"?

In the book, they are calling the mechanism as Busy Wait not because of the processes waiting in queue but rather for the fact that when multiple processes are trying to execute Wait() or signal() operation concurrently, they will have to busy wait.
Note that the variable "value" in the code of Wait() and signal() is a shared variable and hence critical section. Two processes should not be allowed to modify this variable concurrently. For synchronisation, we prefer the busy wait(spin lock) over non busy wait synchronisation mechanism because the code of Wait() or Signal() is pretty small and so processes which are waiting to execute "Wait()" will not have to spend much time waiting. Moreover, if you choose non busy waiting synchronisation mechanism in situation when the length of critical section is small(as it is here) then context switch overhead will waste more CPU time compared to the CPU time wasted in busy wait. So what we have done is that we limited the busy waiting only to the critical section of Wait() and signal() operation. Earlier busy waiting was present in critical section of our application program.

$\endgroup$
2
  • $\begingroup$ Hey, you helps a lot, although I almost forgot I asked this question. $\endgroup$
    – Ning
    Sep 8, 2020 at 17:03
  • $\begingroup$ Hi ! Hopefully it cleared your query, if it was not already cleared. $\endgroup$
    – Ayush
    Sep 8, 2020 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.