Semaphores version 2
Semaphore::P() {
s--;
if(s < 0) {
waitQ->Enqueue(currentThread);
currentThread->stop();
}
}
Semaphore::V() {
s++;
if(s <= 0) {
nextThread = waitQ->Dequeue();
start(nextThread);
}
}
Previous slide
Next slide
Back to first slide
View graphic version