Homework 6 2019529628047 MOHAMMED ANVAR Version 0 |
|
đ¤ Author: by wx287_oz26ft8z0hrxg4bfxzjnbg_sik8g 2022-02-17 15:11:47 |
Problem: Whenever a process is constantly checking value while waiting (see while(s==0)) and wasting CPU cycles, we can take the following train of thought to avoid this situation:
P(Semaphore s)
{
s=s-1;
if(s<0){
block();
}
}
V(Semaphore s)
{
s=s+1;
if(s >=0){
wakeup(p);
}
}