diff options
author | attilio <attilio@FreeBSD.org> | 2010-01-24 15:07:00 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2010-01-24 15:07:00 +0000 |
commit | a4281bb8848a39a697bf8c77c4e958baf048bdea (patch) | |
tree | b9469e81eedd64257cbfcad33ebdccc86a58a8d2 /share/man | |
parent | 62a013da482cd3be2013620de2512c32e56adb68 (diff) | |
download | FreeBSD-src-a4281bb8848a39a697bf8c77c4e958baf048bdea.zip FreeBSD-src-a4281bb8848a39a697bf8c77c4e958baf048bdea.tar.gz |
- Fix the kthread_{suspend, resume, suspend_check}() locking.
In the current code, the locking is completely broken and may lead
easilly to deadlocks. Fix it by using the proc_mtx, linked to the
suspending thread, as lock for the operation. Keep using the
thread_lock for setting and reading the flag even if it is not entirely
necessary (atomic ops may do it as well, but this way the code is more
readable).
- Fix a deadlock within kthread_suspend().
The suspender should not sleep on a different channel wrt the suspended
thread, or, otherwise, the awaker should wakeup both. Uniform the
interface to what the kproc_* counterparts do (sleeping on the same
channel).
- Change the kthread_suspend_check() prototype.
kthread_suspend_check() always assumes curthread and must only refer to
it, so skip the thread pointer as it may be easilly mistaken.
If curthread is not a kthread, the system will panic.
In collabouration with: jhb
Tested by: Giovanni Trematerra
<giovanni dot trematerra at gmail dot com>
MFC: 2 weeks
Diffstat (limited to 'share/man')
-rw-r--r-- | share/man/man9/kthread.9 | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/share/man/man9/kthread.9 b/share/man/man9/kthread.9 index ffb5179..d2c770b 100644 --- a/share/man/man9/kthread.9 +++ b/share/man/man9/kthread.9 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 26, 2009 +.Dd January 24, 2010 .Dt KTHREAD 9 .Os .Sh NAME @@ -50,7 +50,7 @@ .Ft int .Fn kthread_suspend "struct thread *td" "int timo" .Ft void -.Fn kthread_suspend_check "struct thread *td" +.Fn kthread_suspend_check "void" .In sys/unistd.h .Ft int .Fo kthread_add @@ -208,12 +208,9 @@ functions are used to suspend and resume a kernel thread. During the main loop of its execution, a kernel thread that wishes to allow itself to be suspended should call .Fn kthread_suspend_check -passing in -.Va curthread -as the only argument. -This function checks to see if the kernel thread has been asked to suspend. +in order to check if the it has been asked to suspend. If it has, it will -.Xr tsleep 9 +.Xr msleep 9 until it is told to resume. Once it has been told to resume it will return allowing execution of the kernel thread to continue. |