diff options
author | jhb <jhb@FreeBSD.org> | 2004-02-05 21:01:37 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2004-02-05 21:01:37 +0000 |
commit | 85386c7cf693d54b97291de5ede43e750dd30946 (patch) | |
tree | 359f9ec487b40f0b357c394127f1f83b8dcf8859 | |
parent | 4f63b6f6e07f41a50172a3c8536307ed14f016a1 (diff) | |
download | FreeBSD-src-85386c7cf693d54b97291de5ede43e750dd30946.zip FreeBSD-src-85386c7cf693d54b97291de5ede43e750dd30946.tar.gz |
Always set a process' state to normal when it is fully constructed in
fork1() rather than only doing it for the RFSTOPPED case and then having
to fix it up in other places later on.
-rw-r--r-- | sys/kern/kern_fork.c | 14 | ||||
-rw-r--r-- | sys/kern/kern_idle.c | 1 |
2 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 5937c47..2ce5065 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -681,17 +681,21 @@ again: EVENTHANDLER_INVOKE(process_fork, p1, p2, flags); /* + * Set the child start time and mark the process as being complete. + */ + microuptime(&p2->p_stats->p_start); + mtx_lock_spin(&sched_lock); + p2->p_state = PRS_NORMAL; + + /* * If RFSTOPPED not requested, make child runnable and add to * run queue. */ - microuptime(&p2->p_stats->p_start); if ((flags & RFSTOPPED) == 0) { - mtx_lock_spin(&sched_lock); - p2->p_state = PRS_NORMAL; TD_SET_CAN_RUN(td2); setrunqueue(td2); - mtx_unlock_spin(&sched_lock); } + mtx_unlock_spin(&sched_lock); /* * Now can be swapped. @@ -776,7 +780,7 @@ fork_exit(callout, arg, frame) td = curthread; p = td->td_proc; td->td_oncpu = PCPU_GET(cpuid); - p->p_state = PRS_NORMAL; + KASSERT(p->p_state == PRS_NORMAL, ("executing process is still new")); /* * Finish setting up thread glue so that it begins execution in a diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c index c5fff0a..5538baf 100644 --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -57,7 +57,6 @@ idle_setup(void *dummy) PROC_LOCK(p); p->p_flag |= P_NOLOAD; mtx_lock_spin(&sched_lock); - p->p_state = PRS_NORMAL; td = FIRST_THREAD_IN_PROC(p); td->td_state = TDS_CAN_RUN; td->td_flags |= TDF_IDLETD; |