From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcda7,aa6f820f3f67c7ef X-Google-Attributes: gidfcda7,public X-Google-Thread: 11035d,aa6f820f3f67c7ef X-Google-Attributes: gid11035d,public X-Google-Thread: 10650a,aa6f820f3f67c7ef X-Google-Attributes: gid10650a,public X-Google-Thread: fa528,aa6f820f3f67c7ef X-Google-Attributes: gidfa528,public X-Google-Thread: 115614,aa6f820f3f67c7ef X-Google-Attributes: gid115614,public X-Google-ArrivalTime: 2001-05-29 10:30:58 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: anaonymous@nku.edu Newsgroups: comp.unix.internals,comp.unix.solaris,comp.unix.tru64,comp.sys.hp.hpux,comp.unix.aix Subject: Re: awaking a thread ... waiting on select or poll Date: Tue, 29 May 2001 13:29:58 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <3B13DC95.7F8675DB@nku.edu> X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 References: <9b799r$6jm$1@charity.cs.utexas.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.unix.internals:524 comp.unix.solaris:43328 comp.unix.tru64:2334 comp.sys.hp.hpux:9676 comp.unix.aix:16648 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 , > MrSignor 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_