diff options
author | Juli Mallett <jmallett@FreeBSD.org> | 2004-06-09 14:06:44 +0000 |
---|---|---|
committer | Juli Mallett <jmallett@FreeBSD.org> | 2004-06-09 14:06:44 +0000 |
commit | 6c27c6039b0c96613aaca7a958e18ab9cd1778f6 (patch) | |
tree | 0c1cad43a9927d6f4c2e2abe8e492696124173a4 /sys/kern/kern_thread.c | |
parent | 615f49ba6868c0bba6a0fdd9c1b57e379d49edb0 (diff) | |
download | src-test2-6c27c6039b0c96613aaca7a958e18ab9cd1778f6.tar.gz src-test2-6c27c6039b0c96613aaca7a958e18ab9cd1778f6.zip |
Notes
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 242fba5628a9..7b1d45e06b1c 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -124,6 +124,19 @@ thread_ctor(void *mem, int size, void *arg) td->td_tid = 0; td->td_state = TDS_INACTIVE; td->td_oncpu = NOCPU; + + /* + * Note that td_critnest begins life as 1 because the thread is not + * running and is thereby implicitly waiting to be on the receiving + * end of a context switch. A context switch must occur inside a + * critical section, and in fact, includes hand-off of the sched_lock. + * After a context switch to a newly created thread, it will release + * sched_lock for the first time, and its td_critnest will hit 0 for + * the first time. This happens on the far end of a context switch, + * and when it context switches away from itself, it will in fact go + * back into a critical section, and hand off the sched lock to the + * next thread. + */ td->td_critnest = 1; } |