Re: Semaphore Usage Problem

"Wan-Teh Chang" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On Tue, Mar 4, 2008 at 5:05 AM,  <[email protected]> wrote:
> I am using PRSem for managing various resources in my application.
>
>  As these semaphores has kernel persistence, I run into a problem now
>  and then.
>
>  If my program terminates abruptly, the next time I start the program,
>  it may wait forever on one of the semaphores
>  created by previous execution which had been terminated abruptly.
>
>  My question is how can I recover from this without restarting the
>  system. Is there any strategy to use semaphores?

You can use PR_DeleteSemaphore:
http://www.mozilla.org/projects/nspr/reference/html/pripcsem.html#PR_DeleteSemaphore
http://developer.mozilla.org/en/docs/PR_DeleteSemaphore

The difference between PR_DeleteSemaphore and PR_CloseSemaphore is:
PR_DeleteSemaphore is like deleting a file.
PR_CloseSemaphore is like closing a file descriptor (handle).

Wan-Teh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.