Re: pthread issue.

From: Brent Verner (brent@linux1.org)
Date: Mon May 22 2000 - 20:20:41 EST


on Mon, May 22, 2000 at 04:50:27PM -0700, George Anzinger typed aloud:
   Kip Matthew Macy wrote:
>
> Read the man page again:
>
> <snip>
>
> ASYNC-SIGNAL SAFETY
> The mutex functions are not async-signal safe. What this
> means is that they should not be called from a signal han­
> dler. In particular, calling pthread_mutex_lock or
> pthread_mutex_unlock from a signal handler may deadlock
> the calling thread.
>
> </snip>
   <snip>
   
   Gosh, is this common or just a Linux'ism? Seems like a real drag and
   not to easy to get around.

depending on the locks needed, a semaphore might be viable as it
is safe to use from a signal handler, though it still might not
be pretty :)

<snippet src="man sem_init">

ASYNC-SIGNAL SAFETY
       On processors supporting atomic compare-and-swap (Intel
       486, Pentium and later, Alpha, PowerPC, MIPS II, Motorola
       68k), the sem_post function is async-signal safe and can
       therefore be called from signal handlers. This is the only
       thread synchronization function provided by POSIX threads
       that is async-signal safe.

</snippet>

cheers.
    brent

--
nuf sed

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:23 EST