]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] clean up maximum priorities
authorRobert Love <rml@tech9.net>
Fri, 17 May 2002 16:42:53 +0000 (09:42 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 17 May 2002 16:42:53 +0000 (09:42 -0700)
This patch further cleans up and separates the code in an effort to
allow setting (a) a larger maximum real-time priority than default and
(b) a maximum kernel RT priority that is separate than the maximum
priority exported to user-space.

include/linux/init_task.h
include/linux/sched.h
kernel/sched.c

index 98951775c26752563f4084f33e39a47f7a7baedb..4fcbad0862b81a9061d225216912309c6e9aa879 100644 (file)
@@ -45,8 +45,8 @@
     thread_info:       &init_thread_info,                              \
     flags:             0,                                              \
     lock_depth:                -1,                                             \
-    prio:              120,                                            \
-    static_prio:       120,                                            \
+    prio:              MAX_PRIO-20,                                    \
+    static_prio:       MAX_PRIO-20,                                    \
     policy:            SCHED_OTHER,                                    \
     cpus_allowed:      -1,                                             \
     mm:                        NULL,                                           \
index 392d2174d84a4e8e1ff6128490afbbac3d18ba24..2ad9171a66b72728dc4598d11dbfef79eea57362 100644 (file)
@@ -206,7 +206,24 @@ struct signal_struct {
        spinlock_t              siglock;
 };
 
+/*
+ * Priority of a process goes from 0..MAX_PRIO-1, valid RT
+ * priority is 0..MAX_RT_PRIO-1, and SCHED_OTHER tasks are
+ * in the range MAX_RT_PRIO..MAX_PRIO-1. Priority values
+ * are inverted: lower p->prio value means higher priority.
+ *
+ * The MAX_RT_USER_PRIO value allows the actual maximum
+ * RT priority to be separate from the value exported to
+ * user-space.  This allows kernel threads to set their
+ * priority to a value higher than any user task. Note:
+ * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
+ */
+
+#define MAX_USER_RT_PRIO       100
+#define MAX_RT_PRIO            MAX_USER_RT_PRIO
 
+#define MAX_PRIO               (MAX_RT_PRIO + 40)
 /*
  * Some day this will be a full-fledged user tracking system..
  */
index 2c8302b22524103518878532eff3faff4dd38c0b..698375f4e140b3391bb74a1dcf03cef0279ad3a5 100644 (file)
 #include <linux/completion.h>
 #include <linux/kernel_stat.h>
 
-/*
- * Priority of a process goes from 0 to 139. The 0-99
- * priority range is allocated to RT tasks, the 100-139
- * range is for SCHED_OTHER tasks. Priority values are
- * inverted: lower p->prio value means higher priority.
- * 
- * MAX_USER_RT_PRIO allows the actual maximum RT priority
- * to be separate from the value exported to user-space.
- * NOTE: MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
- */
-#define MAX_RT_PRIO            100
-#define MAX_USER_RT_PRIO       100
-#define MAX_PRIO               (MAX_RT_PRIO + 40)
-
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
- * to static priority [ 100 ... 139 (MAX_PRIO-1) ],
+ * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
  * and back.
  */
 #define NICE_TO_PRIO(nice)     (MAX_RT_PRIO + (nice) + 20)
@@ -1138,8 +1124,8 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param)
        }
        
        /*
-        * Valid priorities for SCHED_FIFO and SCHED_RR are 1..99, valid
-        * priority for SCHED_OTHER is 0.
+        * Valid priorities for SCHED_FIFO and SCHED_RR are
+        * 1..MAX_USER_RT_PRIO, valid priority for SCHED_OTHER is 0.
         */
        retval = -EINVAL;
        if (lp.sched_priority < 0 || lp.sched_priority > MAX_USER_RT_PRIO-1)