]> Zhao Yanbai Git Server - minix.git/commitdiff
Restructure and simplyfycation of the scheduling code in PM a little bit.
authorTomas Hruby <tom@minix3.org>
Sat, 10 Apr 2010 15:24:49 +0000 (15:24 +0000)
committerTomas Hruby <tom@minix3.org>
Sat, 10 Apr 2010 15:24:49 +0000 (15:24 +0000)
- It introduces schedule_process() which makes a kernel call to set
  the scheduling parameters of a process. It is used in the next patch.

servers/pm/misc.c
servers/pm/proto.h
servers/pm/schedule.c

index ec7f8ab7d87e8cafa9651b0b585991ed33113a21..b5c7c0595a01176a6232bd15ad2ce6b89d48818b 100644 (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;
index 702f405cfa0b3e1dbc64b555b2d5a4df004e6e32..fd31529a2194424e920041fc91d028a09c14535c 100644 (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)                    );
index 15f8150c04275a0229f48c917c7abd5f82303eb9..590ce45d2e045d7591f25fb563232b8ba4291cca 100644 (file)
 
 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);
                        }
                }
        }