patch-2.0.1 linux/kernel/sched.c

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

diff -u --recursive --new-file v2.0.0/linux/kernel/sched.c linux/kernel/sched.c
@@ -573,6 +573,7 @@
 {
 	struct timer_list * timer;
 
+	cli();
 	while ((timer = timer_head.next) != &timer_head && timer->expires <= jiffies) {
 		void (*fn)(unsigned long) = timer->function;
 		unsigned long data = timer->data;
@@ -583,6 +584,7 @@
 		fn(data);
 		cli();
 	}
+	sti();
 }
 
 static inline void run_old_timers(void)
@@ -942,6 +944,12 @@
 			}
 			update_one_process(p, ticks, utime, stime);
 
+			if (p->priority < DEF_PRIORITY)
+				kstat.cpu_nice += utime;
+			else
+				kstat.cpu_user += utime;
+			kstat.cpu_system += stime;
+
 			p->counter -= ticks;
 			if (p->counter >= 0)
 				continue;
@@ -966,25 +974,27 @@
 static unsigned long lost_ticks = 0;
 static unsigned long lost_ticks_system = 0;
 
-static void timer_bh(void)
+static inline void update_times(void)
 {
-	unsigned long ticks, system;
+	unsigned long ticks;
 
-	run_old_timers();
-
-	cli();
-	run_timer_list();
-	ticks = lost_ticks;
-	lost_ticks = 0;
-	system = lost_ticks_system;
-	lost_ticks_system = 0;
-	sti();
+	ticks = xchg(&lost_ticks, 0);
 
 	if (ticks) {
+		unsigned long system;
+
+		system = xchg(&lost_ticks_system, 0);
 		calc_load(ticks);
 		update_wall_time(ticks);
 		update_process_times(ticks, system);
 	}
+}
+
+static void timer_bh(void)
+{
+	update_times();
+	run_old_timers();
+	run_timer_list();
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov