I experience process synchronization and have difficulty understanding the semaphore. So here are my doubts:
the source says that
"S semaphore is an integer variable that is accessed through standard atomic operations, that is, wait () and signal ().
He also provided a basic definition of wait ()
wait(Semaphore S) { while S<=0 ; //no operation S--; }
Signal Definition ()
signal(S) { S++; }
Let the initial value of the semaphore be equal to 1 and say that there are two parallel processes P0 and P1, which should not simultaneously perform the operations of their critical partition.
Now let's say that P0 is in the critical section, so Semaphore S should be set to 0, now let's say that P1 wants to enter its critical section so that it executes wait (), and in wait () it continuously sang, now to exit the loop should increase the value of the semaphore, but this may not be possible, because according to the source, wait () is an atomic operation and cannot be interrupted, and therefore, the process P0 cannot cause signal () in a uniprocessor system.
I want to know this understanding, which I am still true or not. and if it is correct, what is the signal P0 of the process () to receive when the process P1 is hit during the cycle?
source share