Subject: Re: interrupts, threads, and preventing wakeup-before-sleep?
To: None <>
From: Nathan J. Williams <>
List: tech-kern
Date: 02/17/2003 23:53:50 writes:

> So, when might an lwp get rescheduled? As in, how can a simple lock
> be used with ltsleep() to prevent an lwp from racing with another
> lwp? splsched()? How does that mix with splnet() or spltty()?

Currently, on each processor (and across all processors since we're
using a big-lock) a lwp in the kernel will run until it blocks
voluntarily - by calling mi_switch() or one of its callers like
yield(), preempt(), or tsleep(). There's no need to protect against
being preempted by another lwp in the top half (This is what people
are referring to when they say that the BSD kernel is

In a post-big-lock world there could be a lwp running on each
processor; in that situation the simple_lock()/simple_unlock()
protocol in my pseudocode will protect against data modification (say,
consuming an event from a queue) by a lwp on another processor.

        - Nathan