Multitasking, SMP & Timers
Posted: Tue May 15, 2012 10:17 am
Hi, I'm looking for some suggestions to design a SMP scheduler. I have HPET and LAPIC Timer drivers ready, and APs being booted so far. In the past I wrote a simple scheduler using the PIT, but that was for a single processor system. It was pretty good, I think. It had priorities, choosed processes in a round-robin way, but let processes with higher priority run for a larger amount of time. Eg: if time slice is 5 ms, then a process with priority 10 would have runt 50 ms, and a process with priority 3, just for 15 ms. It also kept a list of sleeping processes, with timeouts. Basically I subtracted the slices from the timeouts each time the scheduler was called and when the timeout got to 0, the threads were waked up.
My problems here:
1) I don't believe this would work in a SMP system.
2) I don't think my implementation of sleep was quite good. I read somewhere on the forum that some sort of one-shot timer might be used, interrupting one thread to wake up a sleeping one.
Things are even harder, now that I have the PIT, the LAPIC Timer, 1 Periodic timer from HPET and up to other 31 One Shot timers from HPET. (Eventually PM-timer will be implemented too).
How would you distribute the workload? Do you believe the HPET Periodic timer more appropriate than the LAPIC Timer for scheduling?
Should sleeping threads be "stuck" to the current AP? What if, using my old method, two APs call "schedule()" and they both subtract the time slice from the timeout and woke up the thread too early?
Waiting for your helpful considerations...
My problems here:
1) I don't believe this would work in a SMP system.
2) I don't think my implementation of sleep was quite good. I read somewhere on the forum that some sort of one-shot timer might be used, interrupting one thread to wake up a sleeping one.
Things are even harder, now that I have the PIT, the LAPIC Timer, 1 Periodic timer from HPET and up to other 31 One Shot timers from HPET. (Eventually PM-timer will be implemented too).
How would you distribute the workload? Do you believe the HPET Periodic timer more appropriate than the LAPIC Timer for scheduling?
Should sleeping threads be "stuck" to the current AP? What if, using my old method, two APs call "schedule()" and they both subtract the time slice from the timeout and woke up the thread too early?
Waiting for your helpful considerations...