From owner-freebsd-hackers Sun Aug 22 2:43:45 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from scam.xcf.berkeley.edu (scam.XCF.Berkeley.EDU [128.32.43.201]) by hub.freebsd.org (Postfix) with SMTP id 5322B14DCE for ; Sun, 22 Aug 1999 02:43:44 -0700 (PDT) (envelope-from nordwick@scam.xcf.berkeley.edu) Received: (qmail 99528 invoked by uid 27268); 22 Aug 1999 09:43:07 -0000 Message-ID: <19990822094307.99527.qmail@scam.xcf.berkeley.edu> To: freebsd-hackers@freebsd.org Subject: select/poll implementation MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <99526.935314987.1@scam.XCF.Berkeley.EDU> Date: Sun, 22 Aug 1999 02:43:07 -0700 From: "Jay Nordwick" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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