Rework interaction between sleep API and exit1() and start unlocking ps_threads
authorclaudio <claudio@openbsd.org>
Mon, 20 May 2024 10:32:20 +0000 (10:32 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 20 May 2024 10:32:20 +0000 (10:32 +0000)
commit223cf45d6b4b8bd412b517414084d6496ca7e521
treea459b421c02ca8bd80712726bdfa26b3f9c3bf80
parent5149f89075431ea5d8d148a02b8e41b0fe8ecb65
Rework interaction between sleep API and exit1() and start unlocking ps_threads

This diff adjusts how single_thread_set() accounts the threads by using
ps_threadcnt as initial value and counting all threads out that are already
parked. In single_thread_check call exit1() before decreasing ps_singlecount
this is now done in exit1().

exit1() and thread_fork() ensure that ps_threadcnt is updated with the
pr->ps_mtx held and in exit1() also account for exiting threads since
exit1() can sleep.

OK mpi@
sys/kern/kern_exit.c
sys/kern/kern_fork.c
sys/kern/kern_proc.c
sys/kern/kern_resource.c
sys/kern/kern_sig.c
sys/kern/kern_synch.c
sys/sys/proc.h