From: anaonymous@nku.edu
Subject: Re: awaking a thread ... waiting on select or poll
Date: Tue, 29 May 2001 13:29:58 -0400 [thread overview]
Message-ID: <3B13DC95.7F8675DB@nku.edu> (raw)
In-Reply-To: 9b799r$6jm$1@charity.cs.utexas.edu
perhaps an even more basic idea is to have the select include a fd for some
open temp file, and the cooperating process/thread could then periodically
write something to this file forcing the blocked thread to "awaken?"
Logan Shaw wrote:
> In article <qIsB6.3628$zv6.2622115@typhoon2.ba-dsg.net>,
> MrSignor <MrSignor@nospam_bellatlantic.net> wrote:
> >Is there a reliable way (across Unix platforms) to wake-up a thread
> >sleeping/waiting on a Select or Poll, that is not timing out the request.
> >
> >Basically, I have a thread, waiting for work on 1-n sockets. Upon
> >occassion, I would like to wake the sleeping-thread, because I
> >need to bring something to it's attention.
>
> Um... Maybe I'm missing something obvious, but why not write to one of
> the sockets it's listening to?
>
> Perhaps you could use a pipe. When you want the thread to wake up and
> do whatever, just write one byte to the pipe, using a non-blocking
> write. If you succeed in writing, the poll()-ing/select()-ing process
> will get the byte. If you don't succeed in writing, that means another
> byte is already in the pipe waiting to be read, which is just as good
> anyway, since the bytes are just random garbage designed to cause the
> thread to wake up.
>
> - Logan
> --
> my your his her our their _its_
> I'm you're he's she's we're they're _it's_
next prev parent reply other threads:[~2001-05-29 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-13 1:34 awaking a thread ... waiting on select or poll MrSignor
2001-04-13 3:21 ` Richard D. Latham
2001-04-13 10:45 ` Dave Butenhof
2001-04-13 16:25 ` Logan Shaw
2001-05-29 17:29 ` anaonymous [this message]
2001-04-13 19:41 ` Norman Black
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox