Open In App

Busy Waiting in OS

Last Updated : 12 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Waiting in the operating system consists of two approaches namely Busy Waiting and Sleep Waiting. Busy waiting is defined as the process where the process or task continuously the processor and waits for the condition to be satisfied. Whereas Sleep waiting is defined as a process where the task or process does not consume the processor when it is waiting for its condition to be satisfied. The below article covers in detail busy waiting.

What is Busy Waiting?

Busy Waiting is defined as a process synchronization technique where the process waits and continuously keeps on checking for the condition to be satisfied before going ahead with its execution. Busy Waiting is also known as busy looping or spinning. The condition that is to be checked is the entry condition to be true such as availability of a resource or lock in the computer system.

Consider a scenario where a resource is required by the process for execution of a specific program. The resource is being used by another process and is unavailable at that moment. Therefore the process needs to wait for the resource to become available.

Demonstration of Busy Waiting

This process of busy waiting concerning the scenario is demonstrated below:

Step 1: Process 1 makes use of a shared resource

g1

As shown in the above diagram, process 1 makes use of a shared resource. It releases the resource only once it has completed its task or any other high-priority process arises.

Step 2: Process 2 needs the shared resource that is already being used by process 1

g2

As shown in above diagram the process 2 needs the shared resource, but the resource is already in used by the process 1. Therefore it needs to wait until the resource is free.

Step 3: Process 2 enters into busy waiting state until its get access to the shared resource

g3

As shown in above diagram, the process 2 goes in busy waiting state that makes use of the processor and continuously checks for the shared resource to get allocated.

Need of Busy Waiting

Busy waiting is required in operating system for achieving mutual exclusion. Mutual exclusion is used for preventing the processes from accessing the shared resources simultaneously. In operating system the critical section is defined as a program code in which concurrent access is avoided. In the critical section of processes they are granted with exclusive control for accessing it’s resources without any interference from the other available processes in mutual exclusion.

Limitations of Busy Waiting

Below are the limitations of Busy Waiting:

  • Busy waiting keeps CPU busy at all the time until it’s condition gets satisfied.
  • The synchronisation mechanism that makes use of busy waiting suffers from the problem of priority inversion.
  • In critical section the low priority processes gets executed.
  • The system remains idle when process is in busy waiting state.
  • Busy waiting consumes more power.

FAQs on Busy Waiting

Q.1. Does busy waiting leads to deadlock?

Answer:

Busy waiting does not lead to deadlocks but incorrect implementation of the synchronization mechanisms and improper use such as spin locks can lead towards deadlock.

Q.2. Name the techniques that can be used as an alternatives for waiting?

Answer:

Techniques such as sleep or blocking are used as an alternative for waiting where the process relinquishes the CPU and is only scheduled to run when the condition for which it is waiting becomes true.

Q.3. Is it efficient to Use busy waiting in distributed system?

Answer:

No, it is actually problematic to use busy waiting in distributed systems because of the variabilities in network conditions and communication delays. In distributed systems methods such as distributed locking and message passing are majorly being used.

Q.4. What is the difference between busy waiting and blocking?

Answer:

In busy waiting the process continuously checks for a condition and consumes the CPU cycle continuously whereas in blocking a process does not use CPU by remaining inactive until it gets the desired condition.

Q.5. Does the process of busy waiting affects the system responsiveness?

Answer:

Continuous process of busy waiting can easily degrade the responsiveness of the system as it utilizes the CPU and even causes the delay for handling the interactions of the user.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads