A Time Source for Multitasking
Posted: Tue May 29, 2007 1:43 am
Hi All,
I have written a basic device manager which I am fairly happy with for starters and devices such as the PIT, RTC etc... are now to be controlled through that rather than directly from the kernel itself. Now I am getting a little more organised, I've been thinking about whether I am doing the "correct thing" with multitasking.
Up until now, the kernel has had control of the PIT, which increments a tick count and calls the task scheduler if the current task's time slot is up. When the PIT is controlled via the device manager, I see 3 options:
1. The kernel retains control of the PIT which is purely used for scheduling. A different timer value is set on each task switch depending on current priority. This is probably the fastest way (least code execution) of doing things, but is inflexible in that IRQ0 can *only* be used for the PIT. I need to find another time source for the tick counter (I believe the APIC and RTC(?) can be used as interrupt sources).
2. After scanning and adding hardware, the kernel scans for how many timers are available on the system and, if appropriate, "takes control" of one of them as in 1.
3. The PIT is entirely controlled by the device manager as with every other device. A number of interrupt handlers can service IRQ0 including the task switcher (when necessary) and tick counter which should be installed as with every other interrupt. This is the most flexible system, but requires the most code execution on each cycle of the timer.
At the moment, I quite favour option 1, but this completely ties up the PIT and IRQ0 with task switching. I know ultimately I need to make the design decision, but any ideas?
Cheers,
Adam
I have written a basic device manager which I am fairly happy with for starters and devices such as the PIT, RTC etc... are now to be controlled through that rather than directly from the kernel itself. Now I am getting a little more organised, I've been thinking about whether I am doing the "correct thing" with multitasking.
Up until now, the kernel has had control of the PIT, which increments a tick count and calls the task scheduler if the current task's time slot is up. When the PIT is controlled via the device manager, I see 3 options:
1. The kernel retains control of the PIT which is purely used for scheduling. A different timer value is set on each task switch depending on current priority. This is probably the fastest way (least code execution) of doing things, but is inflexible in that IRQ0 can *only* be used for the PIT. I need to find another time source for the tick counter (I believe the APIC and RTC(?) can be used as interrupt sources).
2. After scanning and adding hardware, the kernel scans for how many timers are available on the system and, if appropriate, "takes control" of one of them as in 1.
3. The PIT is entirely controlled by the device manager as with every other device. A number of interrupt handlers can service IRQ0 including the task switcher (when necessary) and tick counter which should be installed as with every other interrupt. This is the most flexible system, but requires the most code execution on each cycle of the timer.
At the moment, I quite favour option 1, but this completely ties up the PIT and IRQ0 with task switching. I know ultimately I need to make the design decision, but any ideas?
Cheers,
Adam