1,586 views
0 votes
0 votes
Up(Semaphore S)
{
    if (Suspended list() is empty)
        S.value=1;
    else
   {
        Select a process from the suspended list and WakeUp()
    }
}

4 Answers

0 votes
0 votes
A Process can be suspended by calling wait() , waitpid() , sleep() ...  In Up function we are finding whether a process is in suspended state if so  wake up it and execute it Wake up it means making a process to be in ready state to execute
0 votes
0 votes
PLEASE DON"T Downvote on this as My concept of Semaphoe is not good ....I will take up an example to explain wake up and sleep calls..suppose there are 2 friends and one of them tells the other to wake him up now the other can do it only once so  he went to wake him up by knocking on his door and he didn't check whtr the other person was in the room or not ..suppose he was not in the room and after that the person went to sleep and now the other person who went to wake his friend want to sleep and he will think that his friend will wake him up but his friend also went to sleep at the same time ..now there is a DEADLOCK ..both people will think that the other would wake them up ..so there was a need of Semaphore that is one of the reason it was invented(I think maybe I am wrong do correct me)  ..so when the semaphore value is 1 that means one process will use the value  and enter into critical section ..
0 votes
0 votes
This is an example of blocking semaphore. Semaphores in general are having two types- Busy waiting(Spin Lock) & Blocking.

Busy waiting semaphores halt the cpu because it runs in an indefinite loop until a signal terminate it whereas blocking semaphores blocks the execution of the process itself and move on. the idea is maintain a queue of all incoming processes. In P(S), check whether queue is empty or not, if not pop one process from queue and call the same process. do not call V(S).

This is exactly we are doing here. if are list is not empty, take one process from list and call this method again.
0 votes
0 votes
as per Galvin, WakeUp() is a system call to move process from waiting Q to ready Q. This happens if counting semaphore value <=0 until >0

Related questions

0 votes
0 votes
1 answer
2
piyushkr asked Dec 31, 2015
321 views
n^(1/(2^(log2log2n)))
2 votes
2 votes
1 answer
4