Scheduling parameters out of the kernel.
This commit is contained in:
@@ -53,6 +53,9 @@ PUBLIC int main(void)
|
||||
rp->p_magic = PMAGIC;
|
||||
rp->p_nr = i; /* proc number from ptr */
|
||||
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) {
|
||||
sp->s_proc_nr = NONE; /* initialize as free */
|
||||
@@ -82,9 +85,6 @@ PUBLIC int main(void)
|
||||
DEBUGEXTRA(("initializing %s... ", ip->proc_name));
|
||||
rp = proc_addr(ip->proc_nr); /* get process pointer */
|
||||
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);
|
||||
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 */
|
||||
priv(rp)->s_sig_mgr = RSYS_SM; /* 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. */
|
||||
else {
|
||||
|
||||
@@ -14,18 +14,10 @@
|
||||
*/
|
||||
#include <minix/com.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/priv.h>
|
||||
#include "const.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 {
|
||||
proc_nr_t s_proc_nr; /* number of associated process */
|
||||
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 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 */
|
||||
|
||||
@@ -225,22 +225,6 @@ struct proc {
|
||||
* regs are significant (initialized)*/
|
||||
#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. */
|
||||
#define BEG_PROC_ADDR (&proc[0])
|
||||
#define BEG_USER_ADDR (&proc[NR_TASKS])
|
||||
|
||||
@@ -78,6 +78,8 @@ _PROTOTYPE( void clear_endpoint, (struct proc *rc) );
|
||||
_PROTOTYPE( void clear_ipc_refs, (struct proc *rc, int caller_ret) );
|
||||
_PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
|
||||
_PROTOTYPE( void kernel_call_resume, (struct proc *p));
|
||||
_PROTOTYPE( int sched_proc, (struct proc *rp,
|
||||
unsigned priority, unsigned quantum));
|
||||
|
||||
/* system/do_newmap.c */
|
||||
_PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* umap_bios: map virtual address in BIOS_SEG to physical
|
||||
* get_randomness: accumulate randomness in a buffer
|
||||
* clear_endpoint: remove a process' ability to send and receive messages
|
||||
* sched_proc: schedule a process
|
||||
*
|
||||
* Changes:
|
||||
* Nov 22, 2009 get_priv supports static priv ids (Cristiano Giuffrida)
|
||||
@@ -36,6 +37,7 @@
|
||||
#include "system.h"
|
||||
#include "proc.h"
|
||||
#include "vm.h"
|
||||
#include "kernel/clock.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
@@ -632,3 +634,34 @@ PUBLIC void kernel_call_resume(struct proc *caller)
|
||||
caller->p_misc_flags &= ~MF_KCALL_RESUME;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,9 @@ PUBLIC int do_schedctl(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
struct proc *p;
|
||||
unsigned flags;
|
||||
unsigned priority, quantum;
|
||||
int proc_nr;
|
||||
|
||||
/* Only system processes can change process schedulers */
|
||||
if (! (priv(caller)->s_flags & SYS_PROC))
|
||||
return(EPERM);
|
||||
int r;
|
||||
|
||||
/* check parameter validity */
|
||||
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) {
|
||||
/* the kernel becomes the scheduler and starts
|
||||
* scheduling the process; RTS_NO_QUANTUM which was
|
||||
* previously set by sys_fork is removed
|
||||
* scheduling the process.
|
||||
*/
|
||||
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;
|
||||
RTS_UNSET(p, RTS_NO_QUANTUM);
|
||||
} else {
|
||||
/* the caller becomes the scheduler */
|
||||
p->p_scheduler = caller;
|
||||
|
||||
@@ -9,6 +9,7 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
struct proc *p;
|
||||
int proc_nr;
|
||||
unsigned priority, quantum;
|
||||
|
||||
if (!isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr))
|
||||
return EINVAL;
|
||||
@@ -19,24 +20,8 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
|
||||
if (caller != p->p_scheduler)
|
||||
return(EPERM);
|
||||
|
||||
/* Make sure the priority number given is within the allowed range.*/
|
||||
if (m_ptr->SCHEDULING_PRIORITY < TASK_Q ||
|
||||
m_ptr->SCHEDULING_PRIORITY > NR_SCHED_QUEUES)
|
||||
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(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);
|
||||
/* Try to schedule the process. */
|
||||
priority = (unsigned) m_ptr->SCHEDULING_PRIORITY;
|
||||
quantum = (unsigned) m_ptr->SCHEDULING_QUANTUM;
|
||||
return sched_proc(p, priority, quantum);
|
||||
}
|
||||
|
||||
@@ -69,25 +69,25 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
|
||||
*/
|
||||
|
||||
PUBLIC struct boot_image image[] = {
|
||||
/* process nr, flags, ms, queue, stack, name */
|
||||
{IDLE, 0, 0, 0, IDL_S, "idle" },
|
||||
{CLOCK, 0, 0, 0, IDL_S, "clock" },
|
||||
{SYSTEM, 0, 0, 0, IDL_S, "system"},
|
||||
{HARDWARE, 0, 0, 0, HRD_S, "kernel"},
|
||||
|
||||
{DS_PROC_NR, BVM_F, DRIV_QUANTUM, 4, 0, "ds" },
|
||||
{RS_PROC_NR, 0, DRIV_QUANTUM, 4, 0, "rs" },
|
||||
|
||||
{PM_PROC_NR, OVM_F, SERV_QUANTUM, 4, 0, "pm" },
|
||||
{SCHED_PROC_NR,OVM_F, SERV_QUANTUM, 4, 0, "sched" },
|
||||
{VFS_PROC_NR, OVM_F, SERV_QUANTUM, 5, 0, "vfs" },
|
||||
{MEM_PROC_NR, BVM_F, DRIV_QUANTUM, 3, 0, "memory"},
|
||||
{LOG_PROC_NR, BVM_F, DRIV_QUANTUM, 2, 0, "log" },
|
||||
{TTY_PROC_NR, BVM_F, DRIV_QUANTUM, 1, 0, "tty" },
|
||||
{MFS_PROC_NR, BVM_F, SERV_QUANTUM, 5, 0, "mfs" },
|
||||
{VM_PROC_NR, 0, SERV_QUANTUM, 2, 0, "vm" },
|
||||
{PFS_PROC_NR, BVM_F, SERV_QUANTUM, 5, 0, "pfs" },
|
||||
{INIT_PROC_NR, BVM_F, USER_QUANTUM, USER_Q, 0, "init" },
|
||||
/* process nr, flags, stack, name */
|
||||
{IDLE, 0, IDL_S, "idle" },
|
||||
{CLOCK, 0, IDL_S, "clock" },
|
||||
{SYSTEM, 0, IDL_S, "system"},
|
||||
{HARDWARE, 0, HRD_S, "kernel"},
|
||||
|
||||
{DS_PROC_NR, BVM_F, 0, "ds" },
|
||||
{RS_PROC_NR, 0, 0, "rs" },
|
||||
|
||||
{PM_PROC_NR, OVM_F, 0, "pm" },
|
||||
{SCHED_PROC_NR,OVM_F, 0, "sched" },
|
||||
{VFS_PROC_NR, OVM_F, 0, "vfs" },
|
||||
{MEM_PROC_NR, BVM_F, 0, "memory"},
|
||||
{LOG_PROC_NR, BVM_F, 0, "log" },
|
||||
{TTY_PROC_NR, BVM_F, 0, "tty" },
|
||||
{MFS_PROC_NR, BVM_F, 0, "mfs" },
|
||||
{VM_PROC_NR, 0, 0, "vm" },
|
||||
{PFS_PROC_NR, BVM_F, 0, "pfs" },
|
||||
{INIT_PROC_NR, BVM_F, 0, "init" },
|
||||
};
|
||||
|
||||
/* Verify the size of the system image table at compile time. Also verify that
|
||||
|
||||
@@ -14,8 +14,6 @@ typedef struct { /* bitmap for system indexes */
|
||||
struct boot_image {
|
||||
proc_nr_t proc_nr; /* process number to use */
|
||||
int flags; /* process flags */
|
||||
unsigned quantum; /* time quantum in ms */
|
||||
int priority; /* scheduling priority */
|
||||
int stksize; /* stack size for tasks */
|
||||
char proc_name[P_NAME_LEN]; /* name in process table */
|
||||
endpoint_t endpoint; /* endpoint number when started */
|
||||
|
||||
Reference in New Issue
Block a user