Scheduling parameters out of the kernel.

This commit is contained in:
Cristiano Giuffrida 2010-07-13 15:30:17 +00:00
parent d4e41fd1f6
commit 8cedace2f5
26 changed files with 196 additions and 156 deletions

View file

@ -20,7 +20,7 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
minix/fslib.h minix/ioctl.h minix/ipc.h minix/ipcconst.h \ minix/fslib.h minix/ioctl.h minix/ipc.h minix/ipcconst.h \
minix/keymap.h minix/minlib.h minix/mq.h \ minix/keymap.h minix/minlib.h minix/mq.h \
minix/netdriver.h minix/partition.h minix/paths.h \ minix/netdriver.h minix/partition.h minix/paths.h \
minix/portio.h minix/profile.h minix/queryparam.h \ minix/portio.h minix/priv.h minix/profile.h minix/queryparam.h \
minix/rs.h minix/safecopies.h minix/sched.h minix/sef.h minix/sound.h \ minix/rs.h minix/safecopies.h minix/sched.h minix/sef.h minix/sound.h \
minix/spin.h minix/sys_config.h minix/sysinfo.h minix/syslib.h \ minix/spin.h minix/sys_config.h minix/sysinfo.h minix/syslib.h \
minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \ minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \

View file

@ -668,12 +668,14 @@
#define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */ #define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */
/* Subfunctions for SYS_SCHEDCTL */ /* Subfunctions for SYS_SCHEDCTL */
#define SCHEDCTL_FLAGS m1_i1 /* flags for setting the scheduler */ #define SCHEDCTL_FLAGS m9_l1 /* flags for setting the scheduler */
# define SCHEDCTL_FLAG_KERNEL 1 /* mark kernel scheduler and remove # define SCHEDCTL_FLAG_KERNEL 1 /* mark kernel scheduler and remove
* RTS_NO_QUANTUM; otherwise caller is * RTS_NO_QUANTUM; otherwise caller is
* marked scheduler * marked scheduler
*/ */
#define SCHEDCTL_ENDPOINT m1_i2 /* endpt of process to be scheduled */ #define SCHEDCTL_ENDPOINT m9_l2 /* endpt of process to be scheduled */
#define SCHEDCTL_QUANTUM m9_l3 /* current scheduling quantum */
#define SCHEDCTL_PRIORITY m9_s4 /* current scheduling priority */
/*===========================================================================* /*===========================================================================*
* Messages for the Reincarnation Server * * Messages for the Reincarnation Server *

View file

@ -63,6 +63,28 @@
/* This feature enable the counting of system calls in PM and FS */ /* This feature enable the counting of system calls in PM and FS */
#define ENABLE_SYSCALL_STATS 0 #define ENABLE_SYSCALL_STATS 0
/* Max. number of I/O ranges that can be assigned to a process */
#define NR_IO_RANGE 64
/* Max. number of device memory ranges that can be assigned to a process */
#define NR_MEM_RANGE 20
/* Max. number of IRQs that can be assigned to a process */
#define NR_IRQ 8
/* Scheduling priorities. Values must start at zero (highest
* priority) and increment.
*/
#define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
#define TASK_Q 0 /* highest, used for kernel tasks */
#define MAX_USER_Q 0 /* highest priority for user processes */
#define USER_Q ((MIN_USER_Q - MAX_USER_Q) / 2 + MAX_USER_Q) /* default
(should correspond to nice 0) */
#define MIN_USER_Q (NR_SCHED_QUEUES - 1) /* minimum priority for user
processes */
/* default scheduling quanta */
#define USER_QUANTUM 200
/*===========================================================================* /*===========================================================================*
* There are no user-settable parameters after this line * * There are no user-settable parameters after this line *
*===========================================================================*/ *===========================================================================*/

24
include/minix/priv.h Normal file
View file

@ -0,0 +1,24 @@
/* Privilege-related definitions. */
#ifndef _MINIX_PRIV_H
#define _MINIX_PRIV_H
#include <minix/com.h>
#include <minix/config.h>
/* scheduler */
#define SRV_SCH KERNEL /* system services */
#define DSRV_SCH SCHED_PROC_NR /* dynamic system services */
#define USR_SCH NONE /* user processes */
/* scheduling priority queue. */
#define SRV_Q USER_Q /* system services */
#define DSRV_Q USER_Q /* dynamic system services */
#define USR_Q USER_Q /* user processes */
/* scheduling quantum. */
#define SRV_QT USER_QUANTUM /* system services */
#define DSRV_QT USER_QUANTUM /* dynamic system services */
#define USR_QT USER_QUANTUM /* user processes */
#endif /* _MINIX_PRIV_H */

View file

@ -45,7 +45,8 @@ _PROTOTYPE( int sys_exit, (void));
_PROTOTYPE( int sys_trace, (int req, endpoint_t proc_ep, long addr, long *data_p)); _PROTOTYPE( int sys_trace, (int req, endpoint_t proc_ep, long addr, long *data_p));
_PROTOTYPE( int sys_schedule, (endpoint_t proc_ep, unsigned priority, unsigned quantum)); _PROTOTYPE( int sys_schedule, (endpoint_t proc_ep, unsigned priority, unsigned quantum));
_PROTOTYPE( int sys_schedctl, (unsigned flags, endpoint_t proc_ep)); _PROTOTYPE( int sys_schedctl, (unsigned flags, endpoint_t proc_ep,
unsigned priority, unsigned quantum));
/* Shorthands for sys_runctl() system call. */ /* Shorthands for sys_runctl() system call. */
#define sys_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, 0) #define sys_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, 0)

View file

@ -53,6 +53,9 @@ PUBLIC int main(void)
rp->p_magic = PMAGIC; rp->p_magic = PMAGIC;
rp->p_nr = i; /* proc number from ptr */ rp->p_nr = i; /* proc number from ptr */
rp->p_endpoint = _ENDPOINT(0, rp->p_nr); /* generation no. 0 */ rp->p_endpoint = _ENDPOINT(0, rp->p_nr); /* generation no. 0 */
rp->p_scheduler = NULL; /* no user space scheduler */
rp->p_priority = 0; /* no priority */
rp->p_quantum_size_ms = 0; /* no quantum size */
} }
for (sp = BEG_PRIV_ADDR, i = 0; sp < END_PRIV_ADDR; ++sp, ++i) { for (sp = BEG_PRIV_ADDR, i = 0; sp < END_PRIV_ADDR; ++sp, ++i) {
sp->s_proc_nr = NONE; /* initialize as free */ sp->s_proc_nr = NONE; /* initialize as free */
@ -82,9 +85,6 @@ PUBLIC int main(void)
DEBUGEXTRA(("initializing %s... ", ip->proc_name)); DEBUGEXTRA(("initializing %s... ", ip->proc_name));
rp = proc_addr(ip->proc_nr); /* get process pointer */ rp = proc_addr(ip->proc_nr); /* get process pointer */
ip->endpoint = rp->p_endpoint; /* ipc endpoint */ ip->endpoint = rp->p_endpoint; /* ipc endpoint */
rp->p_scheduler = NULL; /* no user space scheduler */
rp->p_priority = ip->priority; /* current priority */
rp->p_quantum_size_ms = ip->quantum; /* quantum size */
make_zero64(rp->p_cpu_time_left); make_zero64(rp->p_cpu_time_left);
strncpy(rp->p_name, ip->proc_name, P_NAME_LEN); /* set process name */ strncpy(rp->p_name, ip->proc_name, P_NAME_LEN); /* set process name */
@ -119,6 +119,8 @@ PUBLIC int main(void)
kcalls = RSYS_KC; /* allowed kernel calls */ kcalls = RSYS_KC; /* allowed kernel calls */
priv(rp)->s_sig_mgr = RSYS_SM; /* signal manager */ priv(rp)->s_sig_mgr = RSYS_SM; /* signal manager */
priv(rp)->s_bak_sig_mgr = NONE; /* backup signal manager */ priv(rp)->s_bak_sig_mgr = NONE; /* backup signal manager */
rp->p_priority = SRV_Q; /* priority queue */
rp->p_quantum_size_ms = SRV_QT; /* quantum size */
} }
/* Priviliges for ordinary process. */ /* Priviliges for ordinary process. */
else { else {

View file

@ -14,18 +14,10 @@
*/ */
#include <minix/com.h> #include <minix/com.h>
#include <minix/const.h> #include <minix/const.h>
#include <minix/priv.h>
#include "const.h" #include "const.h"
#include "type.h" #include "type.h"
/* Max. number of I/O ranges that can be assigned to a process */
#define NR_IO_RANGE 64
/* Max. number of device memory ranges that can be assigned to a process */
#define NR_MEM_RANGE 20
/* Max. number of IRQs that can be assigned to a process */
#define NR_IRQ 8
struct priv { struct priv {
proc_nr_t s_proc_nr; /* number of associated process */ proc_nr_t s_proc_nr; /* number of associated process */
sys_id_t s_id; /* index of this system structure */ sys_id_t s_id; /* index of this system structure */
@ -156,8 +148,4 @@ EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
#define RSYS_SM SELF /* root system proc */ #define RSYS_SM SELF /* root system proc */
#define DEF_SYS_SM ROOT_SYS_PROC_NR /* default sys proc */ #define DEF_SYS_SM ROOT_SYS_PROC_NR /* default sys proc */
/* scheduler */
#define KERN_SCH KERNEL /* scheduled by kernel */
#define USER_SCH SCHED_PROC_NR /* scheduled in userland */
#endif /* PRIV_H */ #endif /* PRIV_H */

View file

@ -225,22 +225,6 @@ struct proc {
* regs are significant (initialized)*/ * regs are significant (initialized)*/
#define MF_SENDING_FROM_KERNEL 0x2000 /* message of this process is from kernel */ #define MF_SENDING_FROM_KERNEL 0x2000 /* message of this process is from kernel */
/* Scheduling priorities for p_priority. Values must start at zero (highest
* priority) and increment. Priorities of the processes in the boot image
* can be set in table.c.
*/
#define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
#define TASK_Q 0 /* highest, used for kernel tasks */
#define MAX_USER_Q 0 /* highest priority for user processes */
#define USER_Q ((MIN_USER_Q - MAX_USER_Q) / 2 + MAX_USER_Q) /* default
(should correspond to nice 0) */
#define MIN_USER_Q (NR_SCHED_QUEUES - 1) /* minimum priority for user
processes */
/* default scheduling quanta */
#define USER_QUANTUM 200
#define DRIV_QUANTUM 50
#define SERV_QUANTUM 500
/* Magic process table addresses. */ /* Magic process table addresses. */
#define BEG_PROC_ADDR (&proc[0]) #define BEG_PROC_ADDR (&proc[0])
#define BEG_USER_ADDR (&proc[NR_TASKS]) #define BEG_USER_ADDR (&proc[NR_TASKS])

View file

@ -78,6 +78,8 @@ _PROTOTYPE( void clear_endpoint, (struct proc *rc) );
_PROTOTYPE( void clear_ipc_refs, (struct proc *rc, int caller_ret) ); _PROTOTYPE( void clear_ipc_refs, (struct proc *rc, int caller_ret) );
_PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes)); _PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
_PROTOTYPE( void kernel_call_resume, (struct proc *p)); _PROTOTYPE( void kernel_call_resume, (struct proc *p));
_PROTOTYPE( int sched_proc, (struct proc *rp,
unsigned priority, unsigned quantum));
/* system/do_newmap.c */ /* system/do_newmap.c */
_PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp, _PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,

View file

@ -21,6 +21,7 @@
* umap_bios: map virtual address in BIOS_SEG to physical * umap_bios: map virtual address in BIOS_SEG to physical
* get_randomness: accumulate randomness in a buffer * get_randomness: accumulate randomness in a buffer
* clear_endpoint: remove a process' ability to send and receive messages * clear_endpoint: remove a process' ability to send and receive messages
* sched_proc: schedule a process
* *
* Changes: * Changes:
* Nov 22, 2009 get_priv supports static priv ids (Cristiano Giuffrida) * Nov 22, 2009 get_priv supports static priv ids (Cristiano Giuffrida)
@ -36,6 +37,7 @@
#include "system.h" #include "system.h"
#include "proc.h" #include "proc.h"
#include "vm.h" #include "vm.h"
#include "kernel/clock.h"
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
@ -632,3 +634,34 @@ PUBLIC void kernel_call_resume(struct proc *caller)
caller->p_misc_flags &= ~MF_KCALL_RESUME; caller->p_misc_flags &= ~MF_KCALL_RESUME;
kernel_call_finish(caller, &caller->p_vmrequest.saved.reqmsg, result); kernel_call_finish(caller, &caller->p_vmrequest.saved.reqmsg, result);
} }
/*===========================================================================*
* sched_proc *
*===========================================================================*/
PUBLIC int sched_proc(struct proc *rp, unsigned priority, unsigned quantum)
{
/* Make sure the priority number given is within the allowed range.*/
if (priority < TASK_Q || priority > NR_SCHED_QUEUES)
return EINVAL;
/* Make sure the quantum given is within the allowed range.*/
if(quantum <= 0)
return EINVAL;
/* In some cases, we might be rescheduling a runnable process. In such
* a case (i.e. if we are updating the priority) we set the NO_QUANTUM
* flag before the generic unset to dequeue/enqueue the process
*/
if (proc_is_runnable(rp))
RTS_SET(rp, RTS_NO_QUANTUM);
/* Clear the scheduling bit and enqueue the process */
rp->p_priority = priority;
rp->p_quantum_size_ms = quantum;
rp->p_cpu_time_left = ms_2_cpu_time(quantum);
RTS_UNSET(rp, RTS_NO_QUANTUM);
return OK;
}

View file

@ -8,11 +8,9 @@ PUBLIC int do_schedctl(struct proc * caller, message * m_ptr)
{ {
struct proc *p; struct proc *p;
unsigned flags; unsigned flags;
unsigned priority, quantum;
int proc_nr; int proc_nr;
int r;
/* Only system processes can change process schedulers */
if (! (priv(caller)->s_flags & SYS_PROC))
return(EPERM);
/* check parameter validity */ /* check parameter validity */
flags = (unsigned) m_ptr->SCHEDCTL_FLAGS; flags = (unsigned) m_ptr->SCHEDCTL_FLAGS;
@ -29,11 +27,15 @@ PUBLIC int do_schedctl(struct proc * caller, message * m_ptr)
if ((flags & SCHEDCTL_FLAG_KERNEL) == SCHEDCTL_FLAG_KERNEL) { if ((flags & SCHEDCTL_FLAG_KERNEL) == SCHEDCTL_FLAG_KERNEL) {
/* the kernel becomes the scheduler and starts /* the kernel becomes the scheduler and starts
* scheduling the process; RTS_NO_QUANTUM which was * scheduling the process.
* previously set by sys_fork is removed
*/ */
priority = (unsigned) m_ptr->SCHEDCTL_PRIORITY;
quantum = (unsigned) m_ptr->SCHEDCTL_QUANTUM;
/* Try to schedule the process. */
if((r = sched_proc(p, priority, quantum) != OK))
return r;
p->p_scheduler = NULL; p->p_scheduler = NULL;
RTS_UNSET(p, RTS_NO_QUANTUM);
} else { } else {
/* the caller becomes the scheduler */ /* the caller becomes the scheduler */
p->p_scheduler = caller; p->p_scheduler = caller;

View file

@ -9,6 +9,7 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
{ {
struct proc *p; struct proc *p;
int proc_nr; int proc_nr;
unsigned priority, quantum;
if (!isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr)) if (!isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr))
return EINVAL; return EINVAL;
@ -19,24 +20,8 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
if (caller != p->p_scheduler) if (caller != p->p_scheduler)
return(EPERM); return(EPERM);
/* Make sure the priority number given is within the allowed range.*/ /* Try to schedule the process. */
if (m_ptr->SCHEDULING_PRIORITY < TASK_Q || priority = (unsigned) m_ptr->SCHEDULING_PRIORITY;
m_ptr->SCHEDULING_PRIORITY > NR_SCHED_QUEUES) quantum = (unsigned) m_ptr->SCHEDULING_QUANTUM;
return(EINVAL); return sched_proc(p, priority, quantum);
/* In some cases, we might be rescheduling a runnable process. In such
* a case (i.e. if we are updating the priority) we set the NO_QUANTUM
* flag before the generic unset to dequeue/enqueue the process
*/
if (proc_is_runnable(p))
RTS_SET(p, RTS_NO_QUANTUM);
/* Clear the scheduling bit and enqueue the process */
p->p_priority = m_ptr->SCHEDULING_PRIORITY;
p->p_quantum_size_ms = m_ptr->SCHEDULING_QUANTUM;
p->p_cpu_time_left = ms_2_cpu_time(m_ptr->SCHEDULING_QUANTUM);
RTS_UNSET(p, RTS_NO_QUANTUM);
return(OK);
} }

View file

@ -69,25 +69,25 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
*/ */
PUBLIC struct boot_image image[] = { PUBLIC struct boot_image image[] = {
/* process nr, flags, ms, queue, stack, name */ /* process nr, flags, stack, name */
{IDLE, 0, 0, 0, IDL_S, "idle" }, {IDLE, 0, IDL_S, "idle" },
{CLOCK, 0, 0, 0, IDL_S, "clock" }, {CLOCK, 0, IDL_S, "clock" },
{SYSTEM, 0, 0, 0, IDL_S, "system"}, {SYSTEM, 0, IDL_S, "system"},
{HARDWARE, 0, 0, 0, HRD_S, "kernel"}, {HARDWARE, 0, HRD_S, "kernel"},
{DS_PROC_NR, BVM_F, DRIV_QUANTUM, 4, 0, "ds" }, {DS_PROC_NR, BVM_F, 0, "ds" },
{RS_PROC_NR, 0, DRIV_QUANTUM, 4, 0, "rs" }, {RS_PROC_NR, 0, 0, "rs" },
{PM_PROC_NR, OVM_F, SERV_QUANTUM, 4, 0, "pm" }, {PM_PROC_NR, OVM_F, 0, "pm" },
{SCHED_PROC_NR,OVM_F, SERV_QUANTUM, 4, 0, "sched" }, {SCHED_PROC_NR,OVM_F, 0, "sched" },
{VFS_PROC_NR, OVM_F, SERV_QUANTUM, 5, 0, "vfs" }, {VFS_PROC_NR, OVM_F, 0, "vfs" },
{MEM_PROC_NR, BVM_F, DRIV_QUANTUM, 3, 0, "memory"}, {MEM_PROC_NR, BVM_F, 0, "memory"},
{LOG_PROC_NR, BVM_F, DRIV_QUANTUM, 2, 0, "log" }, {LOG_PROC_NR, BVM_F, 0, "log" },
{TTY_PROC_NR, BVM_F, DRIV_QUANTUM, 1, 0, "tty" }, {TTY_PROC_NR, BVM_F, 0, "tty" },
{MFS_PROC_NR, BVM_F, SERV_QUANTUM, 5, 0, "mfs" }, {MFS_PROC_NR, BVM_F, 0, "mfs" },
{VM_PROC_NR, 0, SERV_QUANTUM, 2, 0, "vm" }, {VM_PROC_NR, 0, 0, "vm" },
{PFS_PROC_NR, BVM_F, SERV_QUANTUM, 5, 0, "pfs" }, {PFS_PROC_NR, BVM_F, 0, "pfs" },
{INIT_PROC_NR, BVM_F, USER_QUANTUM, USER_Q, 0, "init" }, {INIT_PROC_NR, BVM_F, 0, "init" },
}; };
/* Verify the size of the system image table at compile time. Also verify that /* Verify the size of the system image table at compile time. Also verify that

View file

@ -14,8 +14,6 @@ typedef struct { /* bitmap for system indexes */
struct boot_image { struct boot_image {
proc_nr_t proc_nr; /* process number to use */ proc_nr_t proc_nr; /* process number to use */
int flags; /* process flags */ int flags; /* process flags */
unsigned quantum; /* time quantum in ms */
int priority; /* scheduling priority */
int stksize; /* stack size for tasks */ int stksize; /* stack size for tasks */
char proc_name[P_NAME_LEN]; /* name in process table */ char proc_name[P_NAME_LEN]; /* name in process table */
endpoint_t endpoint; /* endpoint number when started */ endpoint_t endpoint; /* endpoint number when started */

View file

@ -79,7 +79,7 @@ PUBLIC int rss_nice_decode(int nice, endpoint_t *scheduler,
*quantum = DECODE(nice, QUANTUM_SHIFT, QUANTUM_BITS); *quantum = DECODE(nice, QUANTUM_SHIFT, QUANTUM_BITS);
} else { } else {
/* old ABI, not useful so just take defaults */ /* old ABI, not useful so just take defaults */
*scheduler = USER_SCH; *scheduler = SCHED_PROC_NR;
*priority = USER_Q; *priority = USER_Q;
*quantum = USER_QUANTUM; *quantum = USER_QUANTUM;
} }

View file

@ -53,14 +53,29 @@ PUBLIC int sched_start(endpoint_t scheduler_e, endpoint_t schedulee_e,
int rv; int rv;
message m; message m;
assert(_ENDPOINT_P(scheduler_e) >= 0); /* No scheduler given? We are done. */
if(scheduler_e == NONE) {
return OK;
}
assert(_ENDPOINT_P(schedulee_e) >= 0); assert(_ENDPOINT_P(schedulee_e) >= 0);
assert(_ENDPOINT_P(parent_e) >= 0); assert(_ENDPOINT_P(parent_e) >= 0);
assert(maxprio >= 0); assert(maxprio >= 0);
assert(maxprio < NR_SCHED_QUEUES); assert(maxprio < NR_SCHED_QUEUES);
assert(quantum > 0); assert(quantum > 0);
assert(newscheduler_e); assert(newscheduler_e);
/* The KERNEL must schedule this process. */
if(scheduler_e == KERNEL) {
if ((rv = sys_schedctl(SCHEDCTL_FLAG_KERNEL,
schedulee_e, maxprio, quantum)) != OK) {
return rv;
}
*newscheduler_e = scheduler_e;
return OK;
}
/* A user-space scheduler must schedule this process. */
m.SCHEDULING_ENDPOINT = schedulee_e; m.SCHEDULING_ENDPOINT = schedulee_e;
m.SCHEDULING_PARENT = parent_e; m.SCHEDULING_PARENT = parent_e;
m.SCHEDULING_MAXPRIO = (int) maxprio; m.SCHEDULING_MAXPRIO = (int) maxprio;

View file

@ -1,10 +1,13 @@
#include "syslib.h" #include "syslib.h"
PUBLIC int sys_schedctl(unsigned flags, endpoint_t proc_ep) PUBLIC int sys_schedctl(unsigned flags, endpoint_t proc_ep, unsigned priority,
unsigned quantum)
{ {
message m; message m;
m.SCHEDCTL_FLAGS = (int) flags; m.SCHEDCTL_FLAGS = (int) flags;
m.SCHEDCTL_ENDPOINT = proc_ep; m.SCHEDCTL_ENDPOINT = proc_ep;
m.SCHEDCTL_PRIORITY = priority;
m.SCHEDCTL_QUANTUM = quantum;
return(_kernel_call(SYS_SCHEDCTL, &m)); return(_kernel_call(SYS_SCHEDCTL, &m));
} }

View file

@ -220,12 +220,12 @@ PUBLIC void image_dmp()
return; return;
} }
printf("Image table dump showing all processes included in system image.\n"); printf("Image table dump showing all processes included in system image.\n");
printf("---name- -nr- flags -qs- -queue- -stack-\n"); printf("---name- -nr- flags -stack-\n");
for (m=0; m<NR_BOOT_PROCS; m++) { for (m=0; m<NR_BOOT_PROCS; m++) {
ip = &image[m]; ip = &image[m];
printf("%8s %4d %5s %4d %7d %7d\n", printf("%8s %4d %5s %7d\n",
ip->proc_name, ip->proc_nr, ip->proc_name, ip->proc_nr,
boot_flags_str(ip->flags), ip->quantum, ip->priority, ip->stksize); boot_flags_str(ip->flags), ip->stksize);
} }
printf("\n"); printf("\n");
} }

View file

@ -239,7 +239,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Set process details found in the image table. */ /* Set process details found in the image table. */
rmp = &mproc[ip->proc_nr]; rmp = &mproc[ip->proc_nr];
strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN); strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN);
rmp->mp_nice = get_nice_value(ip->priority);
(void) sigemptyset(&rmp->mp_ignore); (void) sigemptyset(&rmp->mp_ignore);
(void) sigemptyset(&rmp->mp_sigmask); (void) sigemptyset(&rmp->mp_sigmask);
(void) sigemptyset(&rmp->mp_catch); (void) sigemptyset(&rmp->mp_catch);
@ -255,6 +254,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Set scheduling info */ /* Set scheduling info */
rmp->mp_scheduler = KERNEL; rmp->mp_scheduler = KERNEL;
rmp->mp_nice = get_nice_value(USR_Q);
} }
else { /* system process */ else { /* system process */
if(ip->proc_nr == RS_PROC_NR) { if(ip->proc_nr == RS_PROC_NR) {
@ -268,6 +268,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* RS schedules this process */ /* RS schedules this process */
rmp->mp_scheduler = NONE; rmp->mp_scheduler = NONE;
rmp->mp_nice = get_nice_value(SRV_Q);
} }
/* Get kernel endpoint identifier. */ /* Get kernel endpoint identifier. */

View file

@ -93,6 +93,9 @@
#define SRV_DF (DRV_FORCED) /* system services */ #define SRV_DF (DRV_FORCED) /* system services */
#define DSRV_DF (SRV_DF) /* dynamic system services */ #define DSRV_DF (SRV_DF) /* dynamic system services */
/* Shorthands. */
#define SRV_OR_USR(rp, X, Y) (rp->r_priv.s_flags & SYS_PROC ? X : Y)
/* Reply flags. */ /* Reply flags. */
#define RS_DONTREPLY 0 #define RS_DONTREPLY 0
#define RS_REPLY 1 #define RS_REPLY 1

View file

@ -54,3 +54,4 @@
#include "type.h" #include "type.h"
#include "glo.h" #include "glo.h"
EXTERN _PROTOTYPE( int do_sef_lu_request, (message *m_ptr) );

View file

@ -160,7 +160,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
{ {
/* Initialize the reincarnation server. */ /* Initialize the reincarnation server. */
struct boot_image *ip; struct boot_image *ip;
int s,i,j, usersched; int s,i,j;
int nr_image_srvs, nr_image_priv_srvs, nr_uncaught_init_srvs; int nr_image_srvs, nr_image_priv_srvs, nr_uncaught_init_srvs;
struct rproc *rp; struct rproc *rp;
struct rproc *replica_rp; struct rproc *replica_rp;
@ -170,7 +170,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
struct boot_image_priv *boot_image_priv; struct boot_image_priv *boot_image_priv;
struct boot_image_sys *boot_image_sys; struct boot_image_sys *boot_image_sys;
struct boot_image_dev *boot_image_dev; struct boot_image_dev *boot_image_dev;
message m;
int pid, replica_pid; int pid, replica_pid;
endpoint_t replica_endpoint; endpoint_t replica_endpoint;
@ -311,10 +310,12 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
fill_call_mask(boot_image_priv->vm_calls, NR_VM_CALLS, fill_call_mask(boot_image_priv->vm_calls, NR_VM_CALLS,
rpub->vm_call_mask, VM_RQ_BASE, TRUE); rpub->vm_call_mask, VM_RQ_BASE, TRUE);
/* Scheduling parameters. */
rp->r_scheduler = SRV_OR_USR(rp, SRV_SCH, USR_SCH);
rp->r_priority = SRV_OR_USR(rp, SRV_Q, USR_Q);
rp->r_quantum = SRV_OR_USR(rp, SRV_QT, USR_QT);
/* Get some settings from the boot image table. */ /* Get some settings from the boot image table. */
rp->r_scheduler = boot_image_priv->sched;
rp->r_priority = ip->priority;
rp->r_quantum = ip->quantum;
rpub->endpoint = ip->endpoint; rpub->endpoint = ip->endpoint;
/* Set some defaults. */ /* Set some defaults. */
@ -338,13 +339,8 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
rpub->in_use = TRUE; rpub->in_use = TRUE;
} }
/* - Step 2: allow every system service in the boot image to run. /* - Step 2: allow every system service in the boot image to run. */
* first start kernel-scheduled servers, including the PM and the
* scheduler which are needed to be able to start the
* user-space-scheduled processes
*/
nr_uncaught_init_srvs = 0; nr_uncaught_init_srvs = 0;
for (usersched=0; usersched <= 1; usersched++) {
for (i=0; boot_image_priv_table[i].endpoint != NULL_BOOT_NR; i++) { for (i=0; boot_image_priv_table[i].endpoint != NULL_BOOT_NR; i++) {
boot_image_priv = &boot_image_priv_table[i]; boot_image_priv = &boot_image_priv_table[i];
@ -353,11 +349,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
continue; continue;
} }
/* Kernel-scheduled processes first */
if ((boot_image_priv->sched == KERNEL) ? usersched : !usersched) {
continue;
}
/* Lookup the corresponding slot in the system process table. */ /* Lookup the corresponding slot in the system process table. */
rp = &rproc[boot_image_priv - boot_image_priv_table]; rp = &rproc[boot_image_priv - boot_image_priv_table];
rpub = rp->r_pub; rpub = rp->r_pub;
@ -403,7 +394,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
catch_boot_init_ready(ANY); catch_boot_init_ready(ANY);
nr_uncaught_init_srvs--; nr_uncaught_init_srvs--;
} }
}
/* - Step 4: all the system services in the boot image are now running. /* - Step 4: all the system services in the boot image are now running.
* Complete the initialization of the system process table in collaboration * Complete the initialization of the system process table in collaboration

View file

@ -58,24 +58,23 @@ PRIVATE int
/* Definition of the boot image priv table. The order of entries in this table /* Definition of the boot image priv table. The order of entries in this table
* reflects the order boot system services are made runnable and initialized * reflects the order boot system services are made runnable and initialized
* at boot time, except for the fact that kernel-scheduled services are * at boot time.
* handled before user-scheduled ones.
*/ */
PUBLIC struct boot_image_priv boot_image_priv_table[] = { PUBLIC struct boot_image_priv boot_image_priv_table[] = {
/*endpoint, label, flags, traps, ipcto, sigmgr, sched, kcalls, vmcalls */ /*endpoint, label, flags, traps, ipcto, sigmgr, kcalls, vmcalls */
{RS_PROC_NR, "rs", RSYS_F, RSYS_T, RSYS_M, RSYS_SM, KERN_SCH, rs_kc, rs_vmc }, {RS_PROC_NR, "rs", RSYS_F, RSYS_T, RSYS_M, RSYS_SM, rs_kc, rs_vmc },
{VM_PROC_NR, "vm", VM_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, vm_kc, vm_vmc }, {VM_PROC_NR, "vm", VM_F, SRV_T, SRV_M, SRV_SM, vm_kc, vm_vmc },
{PM_PROC_NR, "pm", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, pm_kc, pm_vmc }, {PM_PROC_NR, "pm", SRV_F, SRV_T, SRV_M, SRV_SM, pm_kc, pm_vmc },
{SCHED_PROC_NR,"sched", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, sched_kc, sched_vmc }, {SCHED_PROC_NR,"sched", SRV_F, SRV_T, SRV_M, SRV_SM, sched_kc, sched_vmc },
{VFS_PROC_NR, "vfs", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, vfs_kc, vfs_vmc }, {VFS_PROC_NR, "vfs", SRV_F, SRV_T, SRV_M, SRV_SM, vfs_kc, vfs_vmc },
{DS_PROC_NR, "ds", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, ds_kc, ds_vmc }, {DS_PROC_NR, "ds", SRV_F, SRV_T, SRV_M, SRV_SM, ds_kc, ds_vmc },
{TTY_PROC_NR, "tty", SRV_F, SRV_T, SRV_M, SRV_SM, USER_SCH, tty_kc, tty_vmc }, {TTY_PROC_NR, "tty", SRV_F, SRV_T, SRV_M, SRV_SM, tty_kc, tty_vmc },
{MEM_PROC_NR, "memory", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, mem_kc, mem_vmc }, {MEM_PROC_NR, "memory", SRV_F, SRV_T, SRV_M, SRV_SM, mem_kc, mem_vmc },
{LOG_PROC_NR, "log", SRV_F, SRV_T, SRV_M, SRV_SM, USER_SCH, log_kc, log_vmc }, {LOG_PROC_NR, "log", SRV_F, SRV_T, SRV_M, SRV_SM, log_kc, log_vmc },
{MFS_PROC_NR,"fs_imgrd", SRV_F, SRV_T, SRV_M, SRV_SM, KERN_SCH, mfs_kc, mfs_vmc }, {MFS_PROC_NR,"fs_imgrd", SRV_F, SRV_T, SRV_M, SRV_SM, mfs_kc, mfs_vmc },
{PFS_PROC_NR, "pfs", SRV_F, SRV_T, SRV_M, SRV_SM, USER_SCH, pfs_kc, pfs_vmc }, {PFS_PROC_NR, "pfs", SRV_F, SRV_T, SRV_M, SRV_SM, pfs_kc, pfs_vmc },
{INIT_PROC_NR, "init", RUSR_F, RUSR_T, RUSR_M, RUSR_SM, NONE, rusr_kc, rusr_vmc }, {INIT_PROC_NR, "init", RUSR_F, RUSR_T, RUSR_M, RUSR_SM, rusr_kc, rusr_vmc },
{NULL_BOOT_NR, "", 0, 0, 0, 0, 0, no_kc, no_vmc } {NULL_BOOT_NR, "", 0, 0, 0, 0, no_kc, no_vmc }
}; };
/* Definition of the boot image sys table. */ /* Definition of the boot image sys table. */

View file

@ -12,7 +12,6 @@ struct boot_image_priv {
short trap_mask; /* allowed system call traps */ short trap_mask; /* allowed system call traps */
int ipc_to; /* send mask protection */ int ipc_to; /* send mask protection */
endpoint_t sig_mgr; /* signal manager */ endpoint_t sig_mgr; /* signal manager */
endpoint_t sched; /* scheduler */
int *k_calls; /* allowed kernel calls */ int *k_calls; /* allowed kernel calls */
int *vm_calls; /* allowed vm calls */ int *vm_calls; /* allowed vm calls */
}; };

View file

@ -195,36 +195,22 @@ PUBLIC int rs_isokendpt(endpoint_t endpoint, int *proc)
*===========================================================================*/ *===========================================================================*/
PUBLIC int sched_init_proc(struct rproc *rp) PUBLIC int sched_init_proc(struct rproc *rp)
{ {
int s; int s;
int is_usr_proc;
switch (rp->r_scheduler) { /* Make sure user processes have no scheduler. PM deals with them. */
is_usr_proc = !(rp->r_priv.s_flags & SYS_PROC);
case NONE: if(is_usr_proc) assert(rp->r_scheduler == NONE);
/* don't touch user processes, PM deals with them */ if(!is_usr_proc) assert(rp->r_scheduler != NONE);
assert(!(rp->r_priv.s_flags & SYS_PROC));
break; /* Start scheduling for the given process. */
if ((s = sched_start(rp->r_scheduler, rp->r_pub->endpoint,
case KERNEL: RS_PROC_NR, rp->r_priority, rp->r_quantum,
/* Confirm kernel scheduler to remove RTS_NO_QUANTUM */ &rp->r_scheduler)) != OK) {
assert(rp->r_priv.s_flags & SYS_PROC); return s;
if ((s = sys_schedctl(SCHEDCTL_FLAG_KERNEL, }
rp->r_pub->endpoint)) != OK) {
panic("unable to kernel-schedule service: %d", s); return s;
}
break;
default:
/* tell scheduler to schedule this one */
assert(rp->r_priv.s_flags & SYS_PROC);
if ((s = sched_start(rp->r_scheduler, rp->r_pub->endpoint,
RS_PROC_NR, rp->r_priority, rp->r_quantum,
&rp->r_scheduler)) != OK) {
return s;
}
break;
}
return OK;
} }
/*===========================================================================* /*===========================================================================*

View file

@ -134,7 +134,7 @@ PUBLIC int do_start_scheduling(message *m_ptr)
/* Take over scheduling the process. The kernel reply message populates /* Take over scheduling the process. The kernel reply message populates
* the processes current priority and its time slice */ * the processes current priority and its time slice */
if ((rv = sys_schedctl(0, rmp->endpoint)) != OK) { if ((rv = sys_schedctl(0, rmp->endpoint, 0, 0)) != OK) {
printf("Sched: Error taking over scheduling for %d, kernel said %d\n", printf("Sched: Error taking over scheduling for %d, kernel said %d\n",
rmp->endpoint, rv); rmp->endpoint, rv);
return rv; return rv;