Linux semaphore, can a process block itself?

As far as I can see at the moment you should.

As far as I can see at the moment you should: Initialize the semaphore to 1 (su. Val) Call semop with sb. Sem_op set to 0 (i.E.

Wait for counter to drop to zero). Drop the count in the other process (sem_op = -1). Because you initialized the semaphore with 0 and called to decrement it by one (semaphores never go below zero), your wait call will succeed and your process won't block.

Does that help? Perhaps this may give additional insight: linuxdevcenter.com/pub/a/linux/2007/05/2....

Thanks! It works! But I'm still confused why initialize su.

Val to 0 can block another process. In the other way, how could a process block itself. I'm a newbie in *nix.

Thanks again for your help, and the web docs. – chinfoo Dec 16 '10 at 9:42 1 This is because if process initializes a semaphore with 0 it enters the critical section at the same time; so others have to wait. If you are wirting green (new) code in your project, maybe you should consider using POSIX semaphores instead (as depicted in the linked article), because the code is a lot easier to maintain (more self-explanatory).

– ofi Dec 16 '10 at 10:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions