From: Tomas Hruby Date: Sat, 10 Apr 2010 15:24:49 +0000 (+0000) Subject: Restructure and simplyfycation of the scheduling code in PM a little bit. X-Git-Tag: v3.1.7~158 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=1a31d158ad624282229d8e121c96935486b089c3;p=minix.git 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. --- diff --git a/servers/pm/misc.c b/servers/pm/misc.c index ec7f8ab7d..b5c7c0595 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -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; diff --git a/servers/pm/proto.h b/servers/pm/proto.h index 702f405cf..fd31529a2 100644 --- a/servers/pm/proto.h +++ b/servers/pm/proto.h @@ -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) ); diff --git a/servers/pm/schedule.c b/servers/pm/schedule.c index 15f8150c0..590ce45d2 100644 --- a/servers/pm/schedule.c +++ b/servers/pm/schedule.c @@ -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); } } }