SMP - Changed prototype of sys_schedule()

- sys_schedule can change only selected values, -1 means that the
  current value should be kept unchanged. For instance we mostly want
  to change the scheduling quantum and priority but we want to keep
  the process at the current cpu

- RS can hand off its processes to scheduler

- service can read the destination cpu from system.conf

- RS can pass the information farther
This commit is contained in:
Tomas Hruby
2010-09-15 14:10:42 +00:00
parent c554aef0e1
commit 06b6e5624a
19 changed files with 104 additions and 38 deletions

View File

@@ -84,7 +84,7 @@ _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));
int priority, int quantum, int cpu));
/* system/do_newmap.c */
_PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,

View File

@@ -638,29 +638,51 @@ PUBLIC void kernel_call_resume(struct proc *caller)
/*===========================================================================*
* sched_proc *
*===========================================================================*/
PUBLIC int sched_proc(struct proc *rp, unsigned priority, unsigned quantum)
PUBLIC int sched_proc(struct proc *p,
int priority,
int quantum,
int cpu)
{
/* Make sure the priority number given is within the allowed range.*/
if (priority < TASK_Q || priority > NR_SCHED_QUEUES)
return EINVAL;
/* Make sure the values given are within the allowed range.*/
if ((priority < TASK_Q && priority != -1) || priority > NR_SCHED_QUEUES)
return(EINVAL);
/* Make sure the quantum given is within the allowed range.*/
if(quantum <= 0)
return EINVAL;
if (quantum < 1 && quantum != -1)
return(EINVAL);
if ((cpu < 0 && cpu != -1) || (cpu > 0 && (unsigned) cpu >= ncpus))
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);
/* FIXME this preempts the process, do we really want to do that ?*/
/* FIXME this is a problem for SMP if the processes currently runs on a
* different CPU */
if (proc_is_runnable(p) && p->p_cpu != cpuid &&
(cpu != -1 || cpu != p->p_cpu)) {
printf("WARNING : changing cpu of a runnable process %d "
"on a different cpu!\n", p->p_endpoint);
return(EINVAL);
}
if (proc_is_runnable(p))
RTS_SET(p, RTS_NO_QUANTUM);
if (priority != -1)
p->p_priority = priority;
if (quantum != -1) {
p->p_quantum_size_ms = quantum;
p->p_cpu_time_left = ms_2_cpu_time(quantum);
}
if (cpu != -1)
p->p_cpu = cpu;
/* 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);
RTS_UNSET(p, RTS_NO_QUANTUM);
return OK;
}

View File

@@ -8,7 +8,7 @@ PUBLIC int do_schedctl(struct proc * caller, message * m_ptr)
{
struct proc *p;
unsigned flags;
unsigned priority, quantum;
int priority, quantum, cpu;
int proc_nr;
int r;
@@ -29,11 +29,12 @@ PUBLIC int do_schedctl(struct proc * caller, message * m_ptr)
/* the kernel becomes the scheduler and starts
* scheduling the process.
*/
priority = (unsigned) m_ptr->SCHEDCTL_PRIORITY;
quantum = (unsigned) m_ptr->SCHEDCTL_QUANTUM;
priority = (int) m_ptr->SCHEDCTL_PRIORITY;
quantum = (int) m_ptr->SCHEDCTL_QUANTUM;
cpu = (int) m_ptr->SCHEDCTL_CPU;
/* Try to schedule the process. */
if((r = sched_proc(p, priority, quantum) != OK))
if((r = sched_proc(p, priority, quantum, cpu) != OK))
return r;
p->p_scheduler = NULL;
} else {

View File

@@ -9,7 +9,7 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
{
struct proc *p;
int proc_nr;
unsigned priority, quantum;
int priority, quantum, cpu;
if (!isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr))
return EINVAL;
@@ -21,7 +21,9 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr)
return(EPERM);
/* Try to schedule the process. */
priority = (unsigned) m_ptr->SCHEDULING_PRIORITY;
quantum = (unsigned) m_ptr->SCHEDULING_QUANTUM;
return sched_proc(p, priority, quantum);
priority = (int) m_ptr->SCHEDULING_PRIORITY;
quantum = (int) m_ptr->SCHEDULING_QUANTUM;
cpu = (int) m_ptr->SCHEDULING_CPU;
return sched_proc(p, priority, quantum, cpu);
}