I recently had to modify the Linux scheduling scheme in one homework assignment, working on kernel version 2.4.18-14 which is identical to the 2.6 kernels in terms of scheduling.
I noticed a weird situation: When processes are moved to the expired queue when they have finished their timeslice, their timeslice for the next epoch is calculated. When I deleted the line that does this, I got a bug where do_fork() was being executed for a task with timeslice=0, which creates some problems for do_fork() and therefor it throws a bug.
How does this make sense? If do_fork() was called from a process, it means it was running, which means it still had a piece of its timeslice left... How does fork get called from a process after it has finsihed its timeslice?
May I ask why you deleted the part of the code that recalculates the process's timeslice?
Yeah, of course you may :-)
The assignment was about creating a new scheduling scheme, in which you calculate the timeslice of all proccesses at the begining of an epoch, so that the total timeslices you give out is 150*N (millisecs), where N is the number of tasks in the run queue. There are more requirements of course, but this is the general idea.
Therefor, when an epoch ends I do all the calculations and calculate all the timeslices based on the processes currently in the active queue and there is no need to re-calculate the timeslice of a task after it finishes its timeslice as it will be done when the entire epoch ends and a new one begins.