Subj : Re: threaded ticker design problem To : comp.programming.threads From : Loic Domaigne Date : Tue Jan 04 2005 08:18 pm Hi Paul! > I'm attempting to solve a problem I am having that deals with the > interaction of both threads and signals. (Yeah!) [snip] > However, it is the update function, which is called from a signal > handler, that presents a problem. Looking at the list of functions > which are safe to call from a signal handler (POSIX), there aren't any > pthread_*() calls available. Correct. > I do note, however, the presence of sem_post(). I'm thinking it might > be safe to actually have *two* threads which handle the timer. One > thread waits on the semaphore while the signal handler does a > sem_post() to notify it to increment the counter. Avoid sema if you can. > Anyway, thoughts on how this might be architected differently/cleanly > are requested. Yes, perhaps. Block with pthread_sigmask() the targeted signal in all threads. Dedicated a special thread responsible for the handling of the signal. In that thread, waits synchronously on the signal using sigwait(). HTH, Loic. .