[PATCH] Improvements in speed and readability of fork functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

   Patch to make fork functions faster. Also improve readability of
schedule() function.

Greetings,

Juan

PREVIOUS OPERATION AND BUGS

1. Function "kernel/fork.c/find_empty_process()" search for an empty
slot in "task" array. It examined every slot in the array and returned
the index of the last empty slot, a very inefficient process. It also
calculates the amount of empty slots.

2. Function "kernel/fork.c/get_pid()" returns a unique id number. It
checked that the id number is unique by looking for it in all slots of
the task array, even those marked as unused. It ran through the array
using an index.

3. Function "kernel/sched.c/schedule()" used 2 different variables
(prev and currentp) to hold the same information. Also, there was an
unused variable at the top level of file sched.c.

NEW OPERATION

1. A new variable keeps track of the amount of empty slots, modifying
its value as slots are taken or released. Another new variable is a
pointer to a slot very likely to be empty. The search stops with the
first unused slot found, uses and return a pointer to "struct
task_struct" instead of an integer index. As result, the new function
is faster and more compact.

2. The new get_pid function does not check empty slots, and uses a
pointer to "struct task_struct" instead of an integer index. Thus, it
is faster and more compact.

3. In file schedule, consolidated the use of two variables with only
one, improving readability. Removed unused top level variable.

OTHER CHANGES

1. A small optimization to reduce code size was done in files
irqtab.c, process.c and printk.c. There is a reduction in code size of
48 bytes.

 The Image builded without errors. The kernel was tested with QEMU and
dioscuri emulators. Also in a PPro pc booting from floppy.

Attachment: elksK.patch
Description: Binary data


[Index of Archives]     [Kernel]     [Linux ia64]     [DCCP]     [Linux for ARM]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux