patch-1.3.43 linux/kernel/sched.c

Next file: linux/mm/Makefile
Previous file: linux/kernel/fork.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.42/linux/kernel/sched.c linux/kernel/sched.c
@@ -106,9 +106,9 @@
 	if (p->counter > current->counter + 3)
 		need_resched = 1;
 	nr_running++;
-	(p->next_run = init_task.next_run)->prev_run = p;
-	p->prev_run = &init_task;
-	init_task.next_run = p;
+	(p->prev_run = init_task.prev_run)->next_run = p;
+	p->next_run = &init_task;
+	init_task.prev_run = p;
 }
 
 static inline void del_from_runqueue(struct task_struct * p)
@@ -137,6 +137,18 @@
 	p->prev_run = NULL;
 }
 
+static inline void move_last_runqueue(struct task_struct * p)
+{
+	struct task_struct *next = p->next_run;
+	struct task_struct *prev = p->prev_run;
+
+	next->prev_run = prev;
+	prev->next_run = next;
+	(p->prev_run = init_task.prev_run)->next_run = p;
+	p->next_run = &init_task;
+	init_task.prev_run = p;
+}
+
 /*
  * Wake up a process. Put it on the run-queue if it's not
  * already there.  The "current" process is always on the
@@ -189,6 +201,14 @@
 #endif
 
 	/*
+	 * Realtime process, select the first one on the
+	 * runqueue (taking priorities within processes
+	 * into account).
+	 */
+	if (p->policy != SCHED_OTHER)
+		return 1000 + p->priority;
+
+	/*
 	 * Give the process a first-approximation goodness value
 	 * according to the number of clock-ticks it has left.
 	 *
@@ -197,7 +217,7 @@
 	 */
 	weight = p->counter;
 	if (weight) {
-
+			
 #ifdef __SMP__
 		/* Give a largish advantage to the same processor...   */
 		/* (this is equivalent to penalizing other processors) */
@@ -241,6 +261,11 @@
 
 	need_resched = 0;
 	cli();
+	/* move an exhausted RR process to be last.. */
+	if (!current->counter && current->policy == SCHED_RR) {
+		current->counter = current->priority;
+		move_last_runqueue(current);
+	}
 	switch (current->state) {
 		case TASK_INTERRUPTIBLE:
 			if (current->signal & ~current->blocked)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this