Subj : Re: pthread_getspecific or __thread for signal handler? To : comp.programming.threads From : Loic Domaigne Date : Mon Jan 31 2005 11:13 pm Hi Ian, > I've been slowly grinding along on my pthread-safe alarm function (so I > can interrupt blocked stdio functions in a multi-threaded program). My > design thus far has been to use a separate thread for each alarm object. > Such an "alarm thread" spends most of its time blocked in > pthread_cond_wait (waiting to be set) or pthread_cond_timedwait (when > "ticking"). When the alarm thread "rings", it sends a SIGALRM to its > "target thread" via pthread_kill. [snip] > Both pthread_getspecific and __thread appear to be working. My question > is which is the "safest" option. The safest option being the one that > will break most obviously on a system where it doesn't work, rather than > lurking around until the program is run in a certain pathological > environment. > > Opinions? I would go for __thread. Because on platform where it is not supported, you won't be able to compile the program. And on platform where it is supported, it should work too. Just my 2 cents! Cheers, Loic. .