James Carlson wrote:
> Garrett D'Amore writes:
>   
>> Hmm... checkout pthread_kill(3c) .... you can deliver a signal to a
>> specific thread.  But as far as  I know you can -only- do this from
>> inside the process containing the thread to be signaled.
>>     
>
> Yes, I was mixing two things.
>
> You can't send a signal to a specific thread within a process.  Once
> there inside the process, it doesn't really make much sense to use
> pthread_kill to "reflect" that same signal to other threads if they
> have it blocked, as they can't receive it.
>
> So, you either have any of the running threads potentially receiving
> that signal and then sending it to each other (!) or you use a
> _different_ signal when you reflect it outwards.
>
> Backing way up, I think it's useful to ask what sort of problem is
> being solved, and whether there aren't better ways to go about solving
> it.
>
>   

I have used pthread_kill() to send a signal to interrupt a call to
poll(), in another thread.  (Basically, the problem I had run into, was
that I couldn't figure out how to use a condvar to wake up a thread that
was sleeping waiting for IO.  In this particular case the poll was on a
file descriptor associated with a USB device.)

I considered that whole approach very ugly, and regretted using this
approach.  What I had wished for at the time, was a way to provide a
condvar as an alternate way to wake up a thread sitting in poll().  In
retrospect, I suppose another approach would have been to use a pipe()
and signal it by writing to the pipe (then the thread could add the read
side of the pipe to the list of fd's it was poll()'ing for.)

-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to