using atomic functions
the semaphore version[codebox]wait(s){
while (s<=0)
;
s–;
}
signal(s){
s++;
}[/codebox]
although INC and DEC can wrok atomically, but the wait() function is not totally atomic, am I right?
using atomic functions
the semaphore version[codebox]wait(s){
while (s<=0)
;
s–;
}
signal(s){
s++;
}[/codebox]
although INC and DEC can wrok atomically, but the wait() function is not totally atomic, am I right?