Date: Sun, 8 Sep 2002 18:56:55 -0700 From: Jonathan Mini <mini@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 17249 for review Message-ID: <20020909015655.GZ7265@elvis.mu.org> In-Reply-To: <200209090145.g891jLMJ059559@freefall.freebsd.org> References: <200209090145.g891jLMJ059559@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <mini@freebsd.org> http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020909015655.GZ7265>