How is "bounded waiting" achieved in here?

  • Context: Comp Sci 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Synchronization
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
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.
 
Reply
  • Haha
Likes   Reactions: 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: