Scheduling parameters out of the kernel.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user