aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2004-02-05 21:01:37 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2004-02-05 21:01:37 +0000
commit4c3558aa829d42ebaf83ae4ef1b226ac87e8eade (patch)
tree359f9ec487b40f0b357c394127f1f83b8dcf8859 /sys/kern/kern_fork.c
parentb4323d772926ad1a7c5291fadf8aa47c89d646b4 (diff)
downloadsrc-4c3558aa829d42ebaf83ae4ef1b226ac87e8eade.tar.gz
src-4c3558aa829d42ebaf83ae4ef1b226ac87e8eade.zip
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.
Notes
Notes: svn path=/head/; revision=125496
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 5937c473875b..2ce506540164 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