From 52adb98aefd6ee43674dc6ccd40f9644daa3db66 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 4 Aug 2003 20:28:20 +0000 Subject: [PATCH] Set td_critnest to 1 when setting up a thread since it is a MI field with MI values. This ensures that td_critnest for a newly fork'd thread is always valid. Requested by: bde (a long time ago) --- sys/kern/kern_kse.c | 1 + sys/kern/kern_thread.c | 1 + sys/sys/proc.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c index 6bcbd9538f31..421e4373b13c 100644 --- a/sys/kern/kern_kse.c +++ b/sys/kern/kern_kse.c @@ -142,6 +142,7 @@ thread_ctor(void *mem, int size, void *arg) td = (struct thread *)mem; td->td_state = TDS_INACTIVE; td->td_oncpu = NOCPU; + td->td_critnest = 1; } /* diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 6bcbd9538f31..421e4373b13c 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -142,6 +142,7 @@ thread_ctor(void *mem, int size, void *arg) td = (struct thread *)mem; td->td_state = TDS_INACTIVE; td->td_oncpu = NOCPU; + td->td_critnest = 1; } /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 47188fb898d9..97d0699dcc93 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -294,7 +294,6 @@ struct thread { u_int td_uuticks; /* (*) Statclock in user, for UTS */ u_int td_usticks; /* (*) Statclock in kernel, for UTS */ int td_intrval; /* (*) Return value of TDF_INTERRUPT */ - u_int td_critnest; /* (k) Critical section nest level. */ sigset_t td_oldsigmask; /* (k) Saved mask from pre sigpause. */ sigset_t td_sigmask; /* (c) Current signal mask. */ sigset_t td_siglist; /* (c) Sigs arrived, not delivered. */ @@ -330,6 +329,7 @@ struct thread { struct vm_object *td_altkstack_obj;/* (a) Alternate kstack object. */ vm_offset_t td_altkstack; /* (a) Kernel VA of alternate kstack. */ int td_altkstack_pages; /* (a) Size of the alternate kstack */ + u_int td_critnest; /* (k) Critical section nest level. */ struct mdthread td_md; /* (k) Any machine-dependent fields. */ struct td_sched *td_sched; /* (*) Scheduler specific data */ };