semaphores

What do these lines of code mean (each separately). It is said that here we set the semaphore to -1 (occupy it) before the critical part, but what happens on each line.
1
2
3
4
sb[0].sem_num = 0;
sb[0].sem_flg = SEM_UNDO;
sb[0].sem_op = -1;
semop(semid,sb,1);
Last edited on
Take a look at this:

https://www.tutorialspoint.com/unix_system_calls/semop.htm

That should answer your question.
Registered users can post here. Sign in or register to post.