Restructure and simplyfycation of the scheduling code in PM a little bit.

- It introduces schedule_process() which makes a kernel call to set
  the scheduling parameters of a process. It is used in the next patch.
This commit is contained in:
Tomas Hruby 2010-04-10 15:24:49 +00:00
parent 512058ca98
commit 1a31d158ad
3 changed files with 21 additions and 13 deletions

View file

@ -455,8 +455,7 @@ PUBLIC int do_getsetpriority()
if (new_q > MIN_USER_Q) new_q = MIN_USER_Q; /* shouldn't happen */
rmp->mp_max_priority = rmp->mp_priority = new_q;
if ((r = sys_schedule(rmp->mp_priority, rmp->mp_priority,
rmp->mp_time_slice)) != OK)
if ((r = schedule_process(rmp)))
return(r);
rmp->mp_nice = arg_pri;

View file

@ -61,6 +61,7 @@ _PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_getsetpriority, (void) );
/* schedule.c */
_PROTOTYPE( int schedule_process, (struct mproc * rmp) );
_PROTOTYPE( void do_noquantum, (void) );
_PROTOTYPE( void overtake_scheduling, (void) );
_PROTOTYPE( void balance_queues, (struct timer *tp) );

View file

@ -11,6 +11,23 @@
PRIVATE timer_t sched_timer;
/*
* makes a kernel call that schedules the process using the actuall scheduling
* parameters set for this process
*/
PUBLIC int schedule_process(struct mproc * rmp)
{
int err;
if ((err = sys_schedule(rmp->mp_endpoint, rmp->mp_priority,
rmp->mp_time_slice)) != OK) {
printf("PM: An error occurred when trying to schedule %s: %d\n",
rmp->mp_name, err);
}
return err;
}
/*===========================================================================*
* do_noquantum *
*===========================================================================*/
@ -31,11 +48,7 @@ PUBLIC void do_noquantum(void)
rmp->mp_priority += 1; /* lower priority */
}
if ((rv = sys_schedule(rmp->mp_endpoint, rmp->mp_priority,
rmp->mp_time_slice))) {
printf("PM: An error occurred when trying to schedule %s: %d\n",
rmp->mp_name, rv);
}
schedule_process(rmp);
}
/*===========================================================================*
@ -77,12 +90,7 @@ struct timer *tp;
if (rmp->mp_flags & IN_USE) {
if (rmp->mp_priority > rmp->mp_max_priority) {
rmp->mp_priority -= 1; /* increase priority */
if ((rv = sys_schedule(rmp->mp_endpoint,
rmp->mp_priority,
rmp->mp_time_slice))) {
printf("PM: An error occurred when balancing %s: %d\n",
rmp->mp_name, rv);
}
schedule_process(rmp);
}
}
}