View topic - Semaphore Locks?

Semaphore Locks?

anything that doesn't fit to other groups.

Semaphore Locks?

Postby oburak » Thu Sep 08, 2011 3:59 pm

We are using QNX 6.3.0 service pack 3. We have a binary semaphore that is accessed by several processes (about 15) to access a shared memory area. Processes have 7 different priorities (so some of them have same priorities). While reviewing the code, I found out that some functions access the shared memory area without locking/unlocking the semaphore. When I added proper locking of the semaphore and then accessing the shared memory area and then releasing the semaphore as is done with all the other functions, we end up with all the processes get hang waiting for the semaphore to unlock. There is no obvious locking and then not unlocking errors.
My question is, is there a known limitations about binary semaphores that I am not aware of?

Thanks for any help.

Kind Regards,
Active Member
Posts: 17
Joined: Tue Nov 24, 2009 2:39 pm

Re: Semaphore Locks?

Postby mario » Thu Sep 08, 2011 4:30 pm

You might want to use mutex as they respect priorities.

My first guess is that your code is missing an unlock somewhere. I find that wrapping mutex/semaphore in a C++ object makes it safer in that regard.
QNX Master
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest