GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
197 views
Does semaphore solution fulfill the condition of bounded wait for more than 2 processes

I know we can implement the waiting list in such a way that makes it satisfy bounded wait but what is the standard?
asked in Operating System by Loyal (3.2k points) 5 47 98 | 197 views
What is the meaning of standard??
standard--- he wants to know general convention which is assumed.

1 Answer

0 votes

It may break bounded waiting condition theoretically as you'll see below. Practically, it depends heavily on which scheduling algorithm is used.

The classic implementation of wait() and signal() primitive is as:

//primitive
wait(semaphore* S)
{
    S->value--;
    if (S->value < 0)
    {
        add this process to S->list;
        block();
    }
}

//primitive
signal(semaphore* S)
{
    S->value++;
    if (S->value <= 0)
    {
        remove a process P from S->list;
        wakeup(P);
    }
}

When a process calls the wait() and fails the "if" test, it will put itself into a waiting list. If more than one processe are blocked on the same semaphore, they're all put into this list(or they are somehow linked together as you can imagine). When another process leaves critical section and calls signal(), one process in the waiting list will be chosen to wake up, ready to compete for CPU again. However, it's the scheduler who decides which process to pick from the waiting list. If the scheduling is implemented in a LIFO(last in first out) manner for instance, it's possible that some process are starved. If the list is implemented in the FIFO manner then it will fulfil bounded wait.

answered by Veteran (11.5k points) 7 63 148

Related questions

+1 vote
3 answers
1
0 votes
1 answer
2
asked in Operating System by monty Active (1.2k points) 3 22 46 | 138 views


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23398 Points

  2. Bikram

    17078 Points

  3. Habibkhan

    8264 Points

  4. srestha

    6296 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4978 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4348 Points

  9. sushmita

    3966 Points

  10. Rishi yadav

    3804 Points


Recent Badges

Famous Question im.raj
Verified Human gk
Notable Question Sanjay Sharma
Popular Question Pravin Paikrao
Notable Question Sanjay Sharma
Notable Question Vineeta
Popular Question rahul sharma 5
Famous Question rahuldb
Great Question jothee
Notable Question Vaishali Trivedi
27,324 questions
35,176 answers
84,111 comments
33,280 users