How is "bounded waiting" achieved in here?

  • Comp Sci
  • Thread starter shivajikobardan
  • Start date
  • Tags
    Synchronization
In summary, bounded waiting is achieved in the given code snippet by ensuring that each process gets a turn at the shared resource before other processes can access it, preventing any one process from being starved out.
  • #1
shivajikobardan
674
54
Homework Statement
How's bounded waiting achieved in here?
Relevant Equations
How's bounded waiting achieved in here?
Physics news on Phys.org
  • #4
You first ask about understanding bounded waiting and now you ask how to prove mutual exclusion. Does this mean you now understand why bounded waiting is obtained?

Proving stuff (depending on the formal framework you use) can be much more difficult and nitpicking than understanding, rather similar to math stuff. And, by the way, your code snippet is messed up, so please refer to the snippet in the wiki link I gave or something similar valid.
 
  • Haha
Likes shivajikobardan
  • #5
In the interests of sanity, let's try to answer the bounded waiting question only.

Your example is not quite correct, here is a better one although it too is not the way it would really be done.

Mutex:
P_i:
do {
     while(turn!=i);

     ## start of critical section

         turn=(i+1) mod n;

         ## where i is the proc-id and n is the # of processes wanting the resource

         ## do your critical code here

     ## end of critical section

     ## remainder section

 } while(1);

Bounded waiting means no consumer of a resource will be starved out of using shared resources by other consumers.

It’s like folks at a gun range where they all want to shoot but the range master designates who can make the next shot and ensures that each person gets a chance to shoot.

The people are the processes waiting on the resource, the range master is the algorithm that handles bounded waiting and the gun range is the shared resource.
 
Last edited:

FAQ: How is "bounded waiting" achieved in here?

What is "bounded waiting" in the context of concurrent programming?

Bounded waiting is a concept in concurrent programming that ensures that there is a limit on the number of times other processes can enter their critical sections after a process has made a request to enter its critical section and before that request is granted. This prevents indefinite postponement or starvation of any process.

How is "bounded waiting" related to mutual exclusion?

Bounded waiting is a condition that complements mutual exclusion. While mutual exclusion ensures that only one process can enter its critical section at a time, bounded waiting ensures that every process gets a fair chance to enter its critical section within a bounded number of attempts, thus preventing starvation.

What mechanisms are used to achieve bounded waiting?

Bounded waiting can be achieved using various synchronization mechanisms such as semaphores, monitors, and locks with specific protocols. These mechanisms ensure that there is a limit on how long a process must wait before it can enter its critical section, typically by maintaining a queue or using turn-based systems.

Can you provide an example of how bounded waiting is implemented?

An example of bounded waiting is the use of a ticket lock. In a ticket lock, each process receives a ticket number when it requests access to the critical section. The process can only enter the critical section when its ticket number matches the currently served number. This ensures that each process will eventually get its turn in a fair and bounded manner.

Are there any trade-offs when implementing bounded waiting?

Implementing bounded waiting can introduce complexity and overhead in the system. For instance, maintaining a queue or ticketing system requires additional memory and processing time. Moreover, ensuring bounded waiting may reduce the overall throughput of the system as processes might have to wait even if the critical section is free, just to maintain fairness.

Back
Top