I've got multitasking working. Now I want to add that when a task wants to wait on something, it is preempted immediately, and another task continues.
One problem I see with this is that the first task would get only part of the timeslice, and the other task would get the remainder of the timeslice, so code like this in the timer interrupt:
Code: Select all
timer()
{
task->timeslice--;
}
Let's say the timer ticks each ms, one could have
task->timeslice -= 1000
and when early preemption is done, one could query the pit for it's current counter value, to know exactly how much of the timeslice has been used and the remaining time left in the timeslice for the next task, and use those values for decrementing task->timeslice
Any thoughts.. ?
How is this usually done?
--
Sigurd Lerstad