patch-1.3.94 linux/kernel/sched.c

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

diff -u --recursive --new-file v1.3.93/linux/kernel/sched.c linux/kernel/sched.c
@@ -336,7 +336,10 @@
 	/*
 	 *	This is safe as we do not permit re-entry of schedule()
 	 */
-	prev->processor = NO_PROC_ID;	
+	prev->processor = NO_PROC_ID;
+#define idle_task (task[this_cpu])
+#else
+#define idle_task (&init_task)
 #endif	
 
 /*
@@ -346,7 +349,7 @@
  */
 /* this is the scheduler proper: */
 	c = -1000;
-	next = &init_task;
+	next = idle_task;
 	while (p != &init_task) {
 		int weight = goodness(p, prev, this_cpu);
 		if (weight > c)
@@ -359,20 +362,13 @@
 		for_each_task(p)
 			p->counter = (p->counter >> 1) + p->priority;
 	}
-#ifdef __SMP__	
-	
-	/*
-	 *	Context switching between two idle threads is pointless.
-	 */
-	if(!prev->pid && !next->pid)
-		next=prev;
+#ifdef __SMP__
 	/*
 	 *	Allocate process to CPU
 	 */
 	 
 	 next->processor = this_cpu;
 	 next->last_processor = this_cpu;
-	 
 #endif	 
 #ifdef __SMP_PROF__ 
 	/* mark processor running an idle thread */
@@ -1437,9 +1433,12 @@
 	 *	process right in SMP mode.
 	 */
 	int cpu=smp_processor_id();
+#ifndef __SMP__	
 	current_set[cpu]=&init_task;
-#ifdef __SMP__	
+#else
 	init_task.processor=cpu;
+	for(cpu = 0; cpu < NR_CPUS; cpu++)
+		current_set[cpu] = &init_task;
 #endif
 	init_bh(TIMER_BH, timer_bh);
 	init_bh(TQUEUE_BH, tqueue_bh);

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