p->thread_info->preempt_count = 1;
#endif
p->did_exec = 0;
- p->state = TASK_UNINTERRUPTIBLE;
+
+ /*
+ * We mark the process as running here, but have not actually
+ * inserted it onto the runqueue yet. This guarantees that
+ * nobody will actually run it, and a signal or other external
+ * event cannot wake it up and insert it on the runqueue either.
+ */
+ p->state = TASK_RUNNING;
copy_flags(clone_flags, p);
if (clone_flags & CLONE_IDLETASK)
set_tsk_thread_flag(p, TIF_SIGPENDING);
}
- p->state = TASK_STOPPED;
if (!(clone_flags & CLONE_STOPPED))
wake_up_forked_process(p); /* do this last */
+ else
+ p->state = TASK_STOPPED;
++total_forks;
if (unlikely (trace)) {
unsigned long flags;
runqueue_t *rq = task_rq_lock(current, &flags);
- p->state = TASK_RUNNING;
+ BUG_ON(p->state != TASK_RUNNING);
+
/*
* We decrease the sleep average of forking parents
* and children as well, to keep max-interactive tasks