In this second phase, scheduling is moved from PM to its own scheduler (see r6557 for phase one). In the next phase we hope to a) include useful information in the "out of quantum" message and b) create some simple scheduling policy that makes use of that information. When the system starts up, PM will iterate over its process table and ask SCHED to take over scheduling unprivileged processes. This is done by sending a SCHEDULING_START message to SCHED. This message includes the processes endpoint, the parent's endpoint and its nice level. The scheduler adds this process to its schedproc table, issues a schedctl, and returns its own endpoint to PM - as the endpoint of the effective scheduler. When a process terminates, a SCHEDULING_STOP message is sent to the scheduler. The reason for this effective endpoint is for future compatibility. Some day, we may have a scheduler that, instead of scheduling the process itself, forwards the SCHEDULING_START message on to another scheduler. PM has information on who schedules whom. As such, scheduling messages from user-land are sent through PM. An example is when processes change their priority, using nice(). In that case, a getsetpriority message is sent to PM, which then sends a SCHEDULING_SET_NICE to the process's effective scheduler. When a process is forked through PM, it inherits its parent's scheduler, but is spawned with an empty quantum. As before, a request to fork a process flows through VM before returning to PM, which then wakes up the child process. This flow has been modified slightly so that PM notifies the scheduler of the new process, before waking up the child process. If the scheduler fails to take over scheduling, the child process is torn down and the fork fails with an erroneous value. Process priority is entirely decided upon using nice levels. PM stores a copy of each process's nice level and when a child is forked, its parent's nice level is sent in the SCHEDULING_START message. How this level is mapped to a priority queue is up to the scheduler. It should be noted that the nice level is used to determine the max_priority and the parent could have been in a lower priority when it was spawned. To prevent a CPU intensive process from hawking the CPU by continuously forking children that get scheduled in the max_priority, the scheduler should determine in which queue the parent is currently scheduled, and schedule the child in that same queue. Other fixes: The USER_Q in kernel/proc.h was incorrectly defined as NR_SCHED_QUEUES/2. That results in a "off by one" error when converting priority->nice->priority for nice=0. This also had the side effect that if someone were to set the MAX_USER_Q to something else than 0, then USER_Q would be off.
111 lines
3.7 KiB
C
111 lines
3.7 KiB
C
/* Function prototypes. */
|
|
|
|
struct mproc;
|
|
struct stat;
|
|
struct mem_map;
|
|
struct memory;
|
|
|
|
#include <timers.h>
|
|
|
|
/* alarm.c */
|
|
_PROTOTYPE( int do_alarm, (void) );
|
|
_PROTOTYPE( int do_itimer, (void) );
|
|
_PROTOTYPE( void set_alarm, (struct mproc *rmp, clock_t ticks) );
|
|
_PROTOTYPE( void check_vtimer, (int proc_nr, int sig) );
|
|
|
|
/* break.c */
|
|
_PROTOTYPE( int do_brk, (void) );
|
|
|
|
/* dma.c */
|
|
_PROTOTYPE( int do_adddma, (void) );
|
|
_PROTOTYPE( int do_deldma, (void) );
|
|
_PROTOTYPE( int do_getdma, (void) );
|
|
|
|
/* exec.c */
|
|
_PROTOTYPE( int do_exec, (void) );
|
|
_PROTOTYPE( int do_exec_newmem, (void) );
|
|
_PROTOTYPE( int do_execrestart, (void) );
|
|
_PROTOTYPE( void exec_restart, (struct mproc *rmp, int result) );
|
|
|
|
/* forkexit.c */
|
|
_PROTOTYPE( int do_fork, (void) );
|
|
_PROTOTYPE( int do_srv_fork, (void) );
|
|
_PROTOTYPE( int do_exit, (void) );
|
|
_PROTOTYPE( void exit_proc, (struct mproc *rmp, int exit_status,
|
|
int dump_core) );
|
|
_PROTOTYPE( void exit_restart, (struct mproc *rmp, int dump_core) );
|
|
_PROTOTYPE( int do_waitpid, (void) );
|
|
_PROTOTYPE( int wait_test, (struct mproc *rmp, struct mproc *child) );
|
|
|
|
/* getset.c */
|
|
_PROTOTYPE( int do_get, (void) );
|
|
_PROTOTYPE( int do_set, (void) );
|
|
|
|
/* main.c */
|
|
_PROTOTYPE( int main, (void) );
|
|
_PROTOTYPE( void setreply, (int proc_nr, int result) );
|
|
|
|
/* mcontext.c */
|
|
_PROTOTYPE( int do_getmcontext, (void) );
|
|
_PROTOTYPE( int do_setmcontext, (void) );
|
|
|
|
/* misc.c */
|
|
_PROTOTYPE( int do_reboot, (void) );
|
|
_PROTOTYPE( int do_procstat, (void) );
|
|
_PROTOTYPE( int do_sysuname, (void) );
|
|
_PROTOTYPE( int do_getsysinfo, (void) );
|
|
_PROTOTYPE( int do_getsysinfo_up, (void) );
|
|
_PROTOTYPE( int do_getprocnr, (void) );
|
|
_PROTOTYPE( int do_getepinfo, (void) );
|
|
_PROTOTYPE( int do_svrctl, (void) );
|
|
_PROTOTYPE( int do_getsetpriority, (void) );
|
|
|
|
/* schedule.c */
|
|
_PROTOTYPE( void sched_init, (void) );
|
|
_PROTOTYPE( int sched_start, (endpoint_t ep, struct mproc *rmp, int flags) );
|
|
_PROTOTYPE( int sched_stop, (struct mproc *rmp) );
|
|
_PROTOTYPE( int sched_nice, (struct mproc *rmp, int nice) );
|
|
|
|
/* profile.c */
|
|
_PROTOTYPE( int do_sprofile, (void) );
|
|
_PROTOTYPE( int do_cprofile, (void) );
|
|
|
|
/* signal.c */
|
|
_PROTOTYPE( int do_kill, (void) );
|
|
_PROTOTYPE( int do_srv_kill, (void) );
|
|
_PROTOTYPE( int process_ksig, (endpoint_t proc_nr_e, int signo) );
|
|
_PROTOTYPE( int do_pause, (void) );
|
|
_PROTOTYPE( int check_sig, (pid_t proc_id, int signo, int ksig) );
|
|
_PROTOTYPE( void sig_proc, (struct mproc *rmp, int signo, int trace,
|
|
int ksig) );
|
|
_PROTOTYPE( int do_sigaction, (void) );
|
|
_PROTOTYPE( int do_sigpending, (void) );
|
|
_PROTOTYPE( int do_sigprocmask, (void) );
|
|
_PROTOTYPE( int do_sigreturn, (void) );
|
|
_PROTOTYPE( int do_sigsuspend, (void) );
|
|
_PROTOTYPE( void check_pending, (struct mproc *rmp) );
|
|
_PROTOTYPE( void restart_sigs, (struct mproc *rmp) );
|
|
_PROTOTYPE( void vm_notify_sig_wrapper, (endpoint_t ep) );
|
|
|
|
/* time.c */
|
|
_PROTOTYPE( int do_stime, (void) );
|
|
_PROTOTYPE( int do_time, (void) );
|
|
_PROTOTYPE( int do_times, (void) );
|
|
|
|
/* timers.c */
|
|
_PROTOTYPE( void pm_set_timer, (timer_t *tp, int delta,
|
|
tmr_func_t watchdog, int arg) );
|
|
_PROTOTYPE( void pm_expire_timers, (clock_t now) );
|
|
_PROTOTYPE( void pm_cancel_timer, (timer_t *tp) );
|
|
|
|
/* trace.c */
|
|
_PROTOTYPE( int do_trace, (void) );
|
|
_PROTOTYPE( void stop_proc, (struct mproc *rmp, int sig_nr) );
|
|
|
|
/* utility.c */
|
|
_PROTOTYPE( pid_t get_free_pid, (void) );
|
|
_PROTOTYPE( int no_sys, (void) );
|
|
_PROTOTYPE( char *find_param, (const char *key) );
|
|
_PROTOTYPE( struct mproc *find_proc, (pid_t lpid) );
|
|
_PROTOTYPE( int pm_isokendpt, (int ep, int *proc) );
|
|
_PROTOTYPE( void tell_fs, (struct mproc *rmp, message *m_ptr) );
|