* [PATCH][1/3] Schedrange
@ 2004-08-04 0:42 Con Kolivas
0 siblings, 0 replies; only message in thread
From: Con Kolivas @ 2004-08-04 0:42 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
This patch is to make it easier in code to implement more scheduling
policies.
Patch against 2.6.8-rc2-mm2
Signed-off-by: Con Kolivas <kernel@kolivas.org>
[-- Attachment #2: schedrange --]
[-- Type: text/plain, Size: 1922 bytes --]
Index: linux-2.6.8-rc2-mm1/include/linux/sched.h
===================================================================
--- linux-2.6.8-rc2-mm1.orig/include/linux/sched.h 2004-08-02 13:44:05.000000000 +1000
+++ linux-2.6.8-rc2-mm1/include/linux/sched.h 2004-08-02 15:41:06.666863796 +1000
@@ -127,6 +127,14 @@
#define SCHED_FIFO 1
#define SCHED_RR 2
+#define SCHED_MIN 0
+#define SCHED_MAX 2
+
+#define SCHED_RANGE(policy) ((policy) >= SCHED_MIN && \
+ (policy) <= SCHED_MAX)
+#define SCHED_RT(policy) ((policy) == SCHED_FIFO || \
+ (policy) == SCHED_RR)
+
struct sched_param {
int sched_priority;
};
Index: linux-2.6.8-rc2-mm1/kernel/sched.c
===================================================================
--- linux-2.6.8-rc2-mm1.orig/kernel/sched.c 2004-08-02 13:44:11.000000000 +1000
+++ linux-2.6.8-rc2-mm1/kernel/sched.c 2004-08-02 15:41:06.695859473 +1000
@@ -2339,7 +2339,7 @@
BUG_ON(task_queued(p));
p->policy = policy;
p->rt_priority = prio;
- if (policy != SCHED_NORMAL)
+ if (SCHED_RT(policy))
p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority;
else
p->prio = p->static_prio;
@@ -2385,9 +2385,8 @@
policy = p->policy;
else {
retval = -EINVAL;
- if (policy != SCHED_FIFO && policy != SCHED_RR &&
- policy != SCHED_NORMAL)
- goto out_unlock;
+ if (!SCHED_RANGE(policy))
+ goto out_unlock;
}
/*
@@ -2397,12 +2396,11 @@
retval = -EINVAL;
if (lp.sched_priority < 0 || lp.sched_priority > MAX_USER_RT_PRIO-1)
goto out_unlock;
- if ((policy == SCHED_NORMAL) != (lp.sched_priority == 0))
- goto out_unlock;
+ if (!SCHED_RT(policy) != (lp.sched_priority == 0))
+ goto out_unlock;
retval = -EPERM;
- if ((policy == SCHED_FIFO || policy == SCHED_RR) &&
- !capable(CAP_SYS_NICE))
+ if (SCHED_RT(policy) && !capable(CAP_SYS_NICE))
goto out_unlock;
if ((current->euid != p->euid) && (current->euid != p->uid) &&
!capable(CAP_SYS_NICE))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-08-04 0:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-04 0:42 [PATCH][1/3] Schedrange Con Kolivas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®