From owner-p4-projects Sun Sep 8 18:57: 6 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C478B37B409; Sun, 8 Sep 2002 18:57:00 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 55F9337B4C8 for ; Sun, 8 Sep 2002 18:56:56 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA07243E3B for ; Sun, 8 Sep 2002 18:56:55 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id 4FDADAE1C1; Sun, 8 Sep 2002 18:56:55 -0700 (PDT) Date: Sun, 8 Sep 2002 18:56:55 -0700 From: Jonathan Mini To: Perforce Change Reviews Subject: Re: PERFORCE change 17249 for review Message-ID: <20020909015655.GZ7265@elvis.mu.org> References: <200209090145.g891jLMJ059559@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200209090145.g891jLMJ059559@freefall.freebsd.org> User-Agent: Mutt/1.4i Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Great. I submitted more than I intended. Pointy-hat to me. > kse_yield(struct thread *td, struct kse_yield_args *uap) > { > + struct thread *td2; > + > + /* KSE-enabled processes only, please. */ > + if ((td->td_proc->p_flag & P_KSES) == 0) > + return (EINVAL); > + > + /* Don't discard the last thread. */ > + td2 = FIRST_THREAD_IN_PROC(td->td_proc); > + KASSERT(td2 != NULL, ("kse_yield: no threads in our proc")); > + if (TAILQ_NEXT(td, td_plist) == NULL) > + return (EINVAL); > > /* Abandon thread. */ > PROC_LOCK(td->td_proc); This code disallows kse_yield() to be called from a non-KSE-process, and in a KSE-process, does not the proc abandon the last thread (leaving a struct proc with zero threads, which -- among other things -- is unkillable). As an aside, being able to rely on kse_yield() failing when there are no other threads running lets it intelligently decide to drop into an idle loop. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message