mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH][1/3] Schedrange
Date: Wed, 04 Aug 2004 10:42:07 +1000	[thread overview]
Message-ID: <cone.1091580127.491907.9775.502@pc.kolivas.org> (raw)

[-- 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))

                 reply	other threads:[~2004-08-04  0:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cone.1091580127.491907.9775.502@pc.kolivas.org \
    --to=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®