Q: thread holding semaphore dies...

169 views
Skip to first unread message

joe

unread,
Oct 10, 2001, 3:12:01 AM10/10/01
to
hi all,

I want to know what happens when a thread or process that holds a
semaphore dies? windows does not see to have a SEM_UNDO kind of
functionality. How to handle this situation?

a.p.

Ruediger R. Asche

unread,
Oct 10, 2001, 8:04:04 AM10/10/01
to
Semaphores on Win32 are different from Unix semaphores in that they are not
associated with owners. You can release a semaphore without having claimed
it before. Thus, there is no way for Win32 to do anything - the semaphore is
not owned so it can not be released, implicitly or explicitly. Semaphores on
Win32 are rather like event extensions, not mutex extensions.

The only synch objects in Win32 that are associated with owners are muteces.
If the owner of a mutex dies without releasing it, threads waiting on the
mutex return from the wait with a special return value (MUTEX_ABANDONED or
something the like).

If you have control over the thread that has claimed the semaphore, you can
use SEH to ensure that the semaphore is always released (you should use SEH
in any case).

RAc
"joe" <ace_...@rediffmail.com> schrieb im Newsbeitrag
news:5ca11246.01100...@posting.google.com...

Reply all
Reply to author
Forward
0 new messages