Quantum in fork

- This patch removes the time slice split between parent and child in
  fork.

- The time slice of the parent remains unchanged and the child does
  not have any.

- If the process has a scheduler, the scheduler must assign the
  quantum and priority of the new process and let it run.

- If the child does not inherit a scheduler, it is scheduled by the
  dummy default kernel policy. (servers, drivers, etc.)

- In theory, the scheduler can change the quantum even of the parent
  process and implement any policy for splitting the quantum as
  neither the parent nor the child are runnable.  Sending the
  out-of_quantum message on behalf of the processes may look like the
  right solution, however, the scheduler would probably handle the
  message before the whole fork protocol is finished. This way the
  scheduler has absolute control when the process should become
  runnable.
This commit is contained in:
Tomas Hruby 2010-04-10 15:27:38 +00:00
parent 1a31d158ad
commit 9b599bac1d
2 changed files with 9 additions and 18 deletions

View file

@ -80,25 +80,14 @@ PUBLIC int do_fork(struct proc * caller, message * m_ptr)
rpc->p_virt_left = 0; /* disable, clear the process-virtual timers */
rpc->p_prof_left = 0;
/* Parent and child have to share the quantum that the forked process had,
* so that queued processes do not have to wait longer because of the fork.
*/
/*
* we want to avoid having processes that loose their quantum without going
* through the standard path where the "out of quantum" is handled. We add
* some more time to such processes.
*
* This is a temporary solution until we are able to handle this in the
* userspace
* if the child process inherited a scheduler, the child process is not
* runnable until it's scheduled. Otherwise the default kernel policy applies.
* This is only the case of system servers, drivers and similar sensitive
* processes
*/
if (rpp->p_ticks_left < 2)
rpp->p_ticks_left = 2;
rpc->p_ticks_left = rpp->p_ticks_left / 2;
rpp->p_ticks_left = rpp->p_ticks_left / 2;
assert(rpc->p_ticks_left > 0 && rpp->p_ticks_left > 0);
if (rpc->p_scheduler)
RTS_SET(rpc, RTS_NO_QUANTUM);
/* If the parent is a privileged process, take away the privileges from the
* child process and inhibit it from running by setting the NO_PRIV flag.

View file

@ -504,7 +504,9 @@ PRIVATE void handle_fs_reply()
break;
case PM_FORK_REPLY:
/* Wake up the newly created process */
/* Schedule the newly created process ... */
schedule_process(rmp);
/* ... and wake it up */
setreply(proc_n, OK);
/* Wake up the parent */