Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2008 15:02:23 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-arch@freebsd.org
Cc:        Lawrence Stewart <lstewart@freebsd.org>
Subject:   Re: kthread_exit(9) unexpectedness
Message-ID:  <200811201502.23943.jhb@freebsd.org>
In-Reply-To: <492412E8.3060700@freebsd.org>
References:  <492412E8.3060700@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 19 November 2008 08:21:44 am Lawrence Stewart wrote:
> Hi all,
> 
> I tracked down a deadlock in some of my code today to some weird 
> behaviour in the kthread(9) KPI. The executive summary is that 
> kthread_exit() thread termination notification using wakeup() behaves as 
> expected intuitively in 8.x, but not in 7.x.

In 5.x/6.x/7.x kthreads are still processes and it has always been a wakeup on 
the proc pointer.  kthread_create() in 7.x returns a proc pointer, not a 
thread pointer for example.  In 8.x kthreads are actual threads and 
kthread_add() and kproc_kthread_add() both return thread pointers.  Hence in 
8.x kthread_exit() is used for exiting kernel threads and wakes up the thread 
pointer, but in 7.x kthread_exit() is used for exiting kernel processes and 
wakes up the proc pointer.  I think what is probably needed is to simply 
document that arrangement as such.  Note that the sleeping on proc pointer 
has been the documented way to synchronize with kthread_exit() since 5.0.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811201502.23943.jhb>