View topic - deadlock in semaphore
deadlock in semaphore
8 posts
• Page 1 of 1
deadlock in semaphore
hi friends .... i am having two processes which are accessing same hardware resource, but the condition i require is the resource must be accessed by one process at a time. for that purpose i am using semaphores, here the problem what i am facing is if any process got killed without doing sem post then those two processes are remain in sem wait state only ........ can any one please suggest me how to avoid this situation
- raohansikarao
- Active Member
- Posts: 34
- Joined: Thu Feb 25, 2010 4:25 am
Raohansikarao,
The easiest solution is to add a signal handler to your application and do the sem_post() in the signal handler. Make sure to register to catch all the signals that can indicate a process is terminating abnormally.
Then when your process gets killed it will do the sem_post.
The other more complex option is to use the High Availablity functions built into QNX (search for HA in the documentation).
Tim
The easiest solution is to add a signal handler to your application and do the sem_post() in the signal handler. Make sure to register to catch all the signals that can indicate a process is terminating abnormally.
Then when your process gets killed it will do the sem_post.
The other more complex option is to use the High Availablity functions built into QNX (search for HA in the documentation).
Tim
- Tim
- Senior Member
- Posts: 1471
- Joined: Wed Mar 10, 2004 12:28 am
This is really basic to QNX.
Write a resource manager. It's really easy. I built a template a few years ago which just requires filling in some blank areas. I'll make it available if anyone asks.
The circumstances where this would be unacceptable overhead are rare. In those cases you might want to put a mutex in some shared memory.
Write a resource manager. It's really easy. I built a template a few years ago which just requires filling in some blank areas. I'll make it available if anyone asks.
The circumstances where this would be unacceptable overhead are rare. In those cases you might want to put a mutex in some shared memory.
- maschoen
- QNX Master
- Posts: 2715
- Joined: Wed Jun 25, 2003 5:18 pm
can u please post your template ........ as a newbie to qnx it is very helpful to me to know how to write a resource manager, thanks in advance
- raohansikarao
- Active Member
- Posts: 34
- Joined: Thu Feb 25, 2010 4:25 am
my actual requirement is, i have two processes with two different timers one process is running for every 50 ms and another process is running for 10 ms , both processes are accessing same resource which is to be avoid by using semaphore .... but the problem i am getting is given above post .......... so i have to synchronize these two processes with out deadlock condition (here 10ms process is very important so that it has not to wait so much long time like 300 ms and above)
- raohansikarao
- Active Member
- Posts: 34
- Joined: Thu Feb 25, 2010 4:25 am
Resource Manager Template Code
I'm uploading the code here which you are free to use. You will put the code that accesses the resource in user.c. You also will want to modify the admin.h parameters to only allow one thread.
- Attachments
-
admin.zip
- (6.07 KiB) Downloaded 238 times
- maschoen
- QNX Master
- Posts: 2715
- Joined: Wed Jun 25, 2003 5:18 pm
RE: Resource Manager Template Code
my actual requirement is, i have two processes with two different timers one process is running for every 50 ms and another process is running for 10 ms , both processes are accessing same resource which is to be avoid by using semaphore .... but the problem i am getting is given above post .......... so i have to synchronize these two processes with out deadlock condition (here 10ms process is very important so that it has not to wait so much long time like 300 ms and above)
- raohansikarao
- Active Member
- Posts: 34
- Joined: Thu Feb 25, 2010 4:25 am
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests