Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Aug 1999 02:43:07 -0700
From:      "Jay Nordwick" <nordwick@scam.xcf.berkeley.edu>
To:        freebsd-hackers@freebsd.org
Subject:   select/poll implementation
Message-ID:  <19990822094307.99527.qmail@scam.xcf.berkeley.edu>

next in thread | raw e-mail | index | archive | help
I had always wondered how select/poll worked (actually see the end of the
mail to see the broader question), so I pulled up select() and family
and started reading and chasing stuff around.  I think that I fully
understand (much praise to whoever wrote most of that, it was incredibly
easy to read) everything from sys_generic.c.

I just need someone to clear up a couple things:

1) It seems that all select (and poll) calls wait on the same
   condition variable (selwait), so when you wake up on select/poll
	call, you wake them all up.  (selwakeup() seems to call wake()
	on selwait, but then hunts for a specific process to make runnable(),
	I'm confused).

2) Where does the struct sockbuf -> struct selinfo sb_sel get filled
   in?  I see it passed around, but I do not see select setting it
	before it tsleeps() on selwait.


thanks
-jason

P.S., Specifically, I was porting a threaed win32 program to UNIX and pthreads.
The one big problem is that there is some win32 event handling code that
waits for events (a glorified condition variable).  There two procedures
that I have to implement are called WaitForSingleEvent() and
WaitForMultipleEvents().  Okay, waiting for a single event is easy to
implement, but waiting for any of multiple events seems more difficult.
I thought to go see how select()/poll() did it, since it did something
similar.




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990822094307.99527.qmail>