Page 1 of 1
task switching
Posted: Sat Sep 29, 2007 1:44 pm
by ashokvarma2
Can anyone suggest a good tutorial to study about task switching.
Posted: Sat Sep 29, 2007 2:06 pm
by piranha
Study the Linux task scheduler.
Check osdever.net
STFW
-JL
Posted: Sat Sep 29, 2007 2:11 pm
by ashokvarma2
i checked osdever, that was the first thing i did.I even found this tutorial based on skelixos
http://en.skelix.org/skelixos/tutorial06.php
but a much more precise tutorial can help
but thanx neway
Posted: Sat Sep 29, 2007 2:31 pm
by jnc100
Once you realise that task switching and scheduling are two different things, it becomes easier to find what you are looking for. Task switching is an entirely processor-dependent way of, well, switching from one task to another. The basic method is to simply store the cpu state from one process, and load a saved one for another process. For the i386, this translates to the general purpose registers, possibly the segment selectors if you freely mix kernel- and process-level threads, cr3 if you use paging., and the fpu state if necessary. As regards to the tutorial you found, I would personally steer clear of hardware-based task switching.
Context Switching contains some introductory information.
A scheduler, on the other hand, is simply a method of choosing which task to switch to next, and its implementation should not be tied to any one processor. There are many different algorithms available (I think recent Linux allows you to choose a different algorithm at compile time), each suited for a different purpose. For example, a server would probably be more efficient with a different algorithm than a workstation, and a real-time system needs something different. Using multiple processors complicates things further. The wiki contains some articles to start from, including
Scheduling Algorithms. It isn't paricularly difficult to implement a priority-based round-robin scheduler, which can serve as a base. Adding support for sleeping and blocking tasks isn't that much more difficult. I would suggest looking at
Blocking Process for information about delta queues.
Regards,
John.
Posted: Sat Sep 29, 2007 2:42 pm
by Dex
This is not a tut, but its a demo of doing multi-tasking in the boot sector of a floppy.
So is small and easy to follow.
It may help.