Hi, This patch fixes some issues with scheduler code. Greetings, Juan PREVIOUS OPERATION AND BUGS 1. Function "kernel/sched.c/run_timer_list()" should run through the timer list removing structures whose timeout expired and issuing their callbacks. This process ends prematurely because after removing the first structure, the link to the next structure in the list is taken from the removed timer, which by then is NULL. 2. Function "kernel/sched.c/run_timer_list()" is called on every invocation to schedule(), but it's necessary to run it only when variable jiffies is incremented. 3. In function "kernel/sched.c/schedule()", when looking for the next task to run, checks for the next task not to be the idle task and variable nr_running > 0. But it's only necessary to check for the idle task. 4. If schedule() is called within an interrupt handler, task swapping is skipped. By the moment when the skip is taken, it already allocated a timer structure in the stack and might have it queued in the timer list, and these actions are not reversed, corrupting the timer list. NEW OPERATION 1. Function "run_timer_list()" was completely rewritten, avoiding its original bug, exploiting the fact that the timers to be removed are always at the beginning of the list, resulting in a more compact implementation. 2. Function "run_timer_list()" is called only at the end of "do_timer()" function. 3. Function "add_timer()" was completely rewritten, resulting in a more compact implementation. 4. Checking if running within an interrupt handler and skipping task switching is done before allocating a timer structure in the stack. Removed unnecessary check of nr_running. OTHER CHANGES 1. A small optimization to reduce code size was done in file irqtab.c. There is a reduction in code size of 80 bytes. The Image builded without errors. The kernel was tested with QEMU and dioscuri emulators. Also in a PPro pc booting from floppy.
Attachment:
elksL.patch
Description: Binary data