On Tue, Oct 10, 2023 at 06:00:57PM +0200, J. Hannken-Illjes wrote:

> > cvs rdiff -u -r1.63 -r1.64 src/sys/kern/sys_select.c
> 
> -    sleepq_unsleep(l, false);
> +    sleepq_remove(l->l_sleepq, l, true);
>     }
>    }
>    mutex_spin_exit(lock);
> 
> Looks like sleepq_remove() unlocks l->l_mutex == lock and
> then mutex_spin_exit(lock) will unlock an unlocked mutex.

lock is held before the call to sleepq_remove() and this is also true at the
time: l->l_mutex == lock.

After the call lock is still held, but now l->l_mutex != lock, because l has
changed state (e.g LSSLEEP -> LSRUN) which causes l_mutex to change in
concert.  There is a rough overview here:

        https://nxr.netbsd.org/xref/src/sys/kern/kern_lwp.c#156

Did you encounter a problem?

Cheers,
Andrew

Reply via email to