Comp Sci How is "bounded waiting" achieved in here?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Synchronization
AI Thread Summary
Bounded waiting ensures that no process is indefinitely denied access to a shared resource, preventing starvation. The discussion highlights how this is achieved through a modified version of Peterson's algorithm, where a turn variable is used to manage access among processes. The analogy of a gun range illustrates this concept, with the range master representing the algorithm that allocates resource access fairly. The conversation also touches on the complexities of proving mutual exclusion and the importance of accurate code snippets for understanding. Ultimately, the focus remains on clarifying how bounded waiting is maintained in concurrent programming scenarios.
shivajikobardan
Messages
637
Reaction score
54
Homework Statement
How's bounded waiting achieved in here?
Relevant Equations
How's bounded waiting achieved in here?
Physics news on Phys.org
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
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.

[CODE lang="python" title="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);
[/CODE]

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:
Back
Top