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:

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • STEM Academic Advising
Replies
6
Views
1K
  • STEM Academic Advising
Replies
1
Views
615
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
757
  • Mechanical Engineering
Replies
28
Views
2K
  • Topology and Analysis
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
4K
Replies
5
Views
740
Back
Top