From owner-freebsd-current Fri Jul 20 9:18:17 2001 Delivered-To: freebsd-current@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id 6450A37B40C for ; Fri, 20 Jul 2001 09:18:06 -0700 (PDT) (envelope-from julian@elischer.org) Received: from elischer.org (InterJet.elischer.org [192.168.1.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id LAA04916 for ; Fri, 20 Jul 2001 11:05:04 -0700 (PDT) Message-ID: <3B585580.6A697127@elischer.org> Date: Fri, 20 Jul 2001 09:00:00 -0700 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: current@freebsd.org Subject: Re: huh? in Selrecord(): what is this for? References: <3B5854E3.B6D9C86D@elischer.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Never mind.. I'm an ijut... Julian Elischer wrote: > > void > selrecord(selector, sip) > struct proc *selector; > struct selinfo *sip; > { > struct proc *p; > pid_t mypid; > > mypid = selector->p_pid; > if (sip->si_pid == mypid) > return; > if (sip->si_pid && (p = pfind(sip->si_pid))) { > > Why do we look up 'p' when we got it as an argument? > (race condition detection?) > > (I'm modifying things for threads so I came up against this....) > > mtx_lock_spin(&sched_lock); > if (p->p_wchan == (caddr_t)&selwait) { > mtx_unlock_spin(&sched_lock); > PROC_UNLOCK(p); > sip->si_flags |= SI_COLL; > return; > } > mtx_unlock_spin(&sched_lock); > PROC_UNLOCK(p); > } > sip->si_pid = mypid; > } > -- > +------------------------------------+ ______ _ __ > | __--_|\ Julian Elischer | \ U \/ / hard at work in > | / \ julian@elischer.org +------>x USA \ a very strange > | ( OZ ) \___ ___ | country ! > +- X_.---._/ presently in San Francisco \_/ \\ > v -- +------------------------------------+ ______ _ __ | __--_|\ Julian Elischer | \ U \/ / hard at work in | / \ julian@elischer.org +------>x USA \ a very strange | ( OZ ) \___ ___ | country ! +- X_.---._/ presently in San Francisco \_/ \\ v To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message