From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 115614,aa6f820f3f67c7ef X-Google-Attributes: gid115614,public X-Google-Thread: fcda7,aa6f820f3f67c7ef X-Google-Attributes: gidfcda7,public X-Google-Thread: 10650a,aa6f820f3f67c7ef X-Google-Attributes: gid10650a,public X-Google-Thread: 11035d,aa6f820f3f67c7ef X-Google-Attributes: gid11035d,public X-Google-Thread: fa528,aa6f820f3f67c7ef X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-04-13 09:26:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-out.visi.com!hermes.visi.com!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed.cs.utexas.edu!news.cs.utexas.edu!not-for-mail From: logan@cs.utexas.edu (Logan Shaw) 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: 13 Apr 2001 11:25:31 -0500 Organization: CS Dept, University of Texas at Austin Sender: logan@charity.cs.utexas.edu Message-ID: <9b799r$6jm$1@charity.cs.utexas.edu> References: NNTP-Posting-Host: charity.cs.utexas.edu X-Trace: news.cs.utexas.edu 987179155 16563 128.83.144.122 (13 Apr 2001 16:25:55 GMT) X-Complaints-To: usenet@cs.utexas.edu NNTP-Posting-Date: Fri, 13 Apr 2001 16:25:55 +0000 (UTC) Xref: supernews.google.com comp.unix.internals:492 comp.unix.solaris:38146 comp.unix.tru64:2119 comp.sys.hp.hpux:8706 comp.unix.aix:14840 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_