2001-03-26 09:46:52

by Heusden, Folkert van

[permalink] [raw]
Subject: [PATCH] kernel/exit.c - 2.4.2 - small optimalisation (very small) to do_exit()

Hi,

This very small patches re-orders 2 if-statements so that in the
most common case 1 less if-statement is executed, in the worst
case the same number of if-statements is executed (doesn't matter
though: it's would be the fault-situation anyway).

diff -ur --minimal linux-vanilla/kernel/exit.c linux-2.4.2/kernel/exit.c
--- linux-vanilla/kernel/exit.c Mon Mar 26 09:28:13 2001
+++ linux-2.4.2/kernel/exit.c Mon Mar 26 10:50:30 2001
@@ -425,10 +425,12 @@

if (in_interrupt())
panic("Aiee, killing interrupt handler!");
- if (!tsk->pid)
- panic("Attempted to kill the idle task!");
- if (tsk->pid == 1)
- panic("Attempted to kill init!");
+ if (tsk->pid <= 1) {
+ if (tsk->pid)
+ panic("Attempted to kill init!");
+ else
+ panic("Attempted to kill the idle task!");
+ }
tsk->flags |= PF_EXITING;
del_timer_sync(&tsk->real_timer);


Greetings,

Folkert van Heusden ([email protected])
[ http://www.vanheusden.com ]