Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Interruption of select()

Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.triton.net!triton.net!newsfeeder.triton.net!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr13.news.prodigy.com.POSTED!fc97ea4a!not-for-mail
Newsgroups: comp.os.linux.development.apps,comp.programming.threads
Subject: Re: Interruption of select()
References: <b1t5qj$1on0$1@ns.felk.cvut.cz> <82n0l9i8g5.fsf@dev0.welkyn.com> <b1vnck$2nqp$1@ns.felk.cvut.cz>
From: sbu...@dev0.welkyn.com (Sean P. Burke)
Message-ID: <82isvwhtuf.fsf@dev0.welkyn.com>
Lines: 56
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 64.23.60.4
X-Complaints-To: abuse@prodigy.net
X-Trace: newssvr13.news.prodigy.com 1044639658 ST000 64.23.60.4 (Fri, 07 Feb 2003 12:40:58 EST)
NNTP-Posting-Date: Fri, 07 Feb 2003 12:40:58 EST
Organization: Prodigy Internet http://www.prodigy.com
X-UserInfo1: OXYYCWKDPZYUC^H]^JKBOW@@YJ_ZTB\MV@BZMVMHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_D_NCC@FUG^Q\DINVAXSLIFXYJSSCCALP@PB@\OS@BITWAH\CQZKJMMD^SJA^NXA\GVLSRBD^M_NW_F[YLVTWIGAXAQBOATKBBQRXECDFDMQ\DZFUE@\JM
Date: Fri, 07 Feb 2003 17:40:58 GMT


"Petr Pecka" <petr.pe...@ima.cz> writes:

> "Sean P. Burke" <sbu...@dev0.welkyn.com> píse v diskusním príspevku
> news:82n0l9i8g5.fsf@dev0.welkyn.com...
> >
> > "Petr Pecka" <petr.pe...@ima.cz> writes:
> >
> > > Hi,
> > >
> > > I have a mutlithreaded communication application where several threads
> wait
> > > in select() for an UDP packet. The select() returns only when packet is
> > > received or timeout expires. I need to be able to interrupt this
> select()
> > > immediately and do other processing when some event occurs in another
> > > thread. The select() timeout can be quite long (1 sec or so) and I don't
> > > want to decrease it and check continuously if the event occured or not.
> > > These events won't occur very often, but if they occur, I need immediate
> > > reaction in the communicatin thread.
> > >
> > > In Win32 it can be implemented using events and I can wait for UDP
> packet or
> > > event in one call, or I can assign event to socket using
> WSAEventSelect().
> > > Any advice how to implement this on Linux and pthreads?
> > >
> > > I can see these possibilities:
> > >     1. using SIGURS1 or SIGUSR2 to interrupt select() but there can are
> > > several identical threads waiting in select() and I need to interrupt
> only
> > > one of them. It is also discuraged to use signals with pthreads.
> > >     2. opening unix-domain datagram socket for each thread and make the
> > > select() wait on both of these sockets. The event thec can be signaled
> by
> > > sending some data on this unix-domain socket.
> > >     3. the same could be probably done with pipes.
> >
> > On Unix, I usually use solution 3, but I would like to know
> > how to do this on WIN32. Do you use select() on WIN32, or
> > WaitForMultipleObjects()?
> >
> >
> > -SEan
> >
> 
> On Win32 I use WaitForMultipleObejcts() or WSAWaitForMultipleEvents(). It
> should be more efficient than using pipes and select(), at least I hope so.

It has to be - the pipe/select technique does not work
at all on windows. The select call ignores the pipe fd.

Some windows calls look like their posix counterparts, 
but this is a trap for the unwary.

-SEan