Hi,
kimes wrote:
Does anyone know well-documented tutorial or something like that about Task Switching and Multitasking?
(except intel doc, It's also hard to follow for me)
If the latest Intel manuals are too hard to follow you may want to get hold of the old manual for 80386. It isn't cluttered by all of the enhancements, and reading (understanding) it will make the later manuals much easier to comprehend.
One of the things I do when I need to understand technical material that is too complex for me is to read it multiple times. The first time I may understand 25% of it. The second time I'd be able to understand 35% of it because I already knew some. The third time I might end up understanding 50% of it. Using this approach almost anything can be understood (even if you have to read it 100 times).
IMHO being able to understand complex technical reference material is one of the requirements for writing a good OS. It's not just Intel's manuals, but AMD's manuals, manuals and datasheets for low level chips (PIT, PIC, ISA DMA, RTC, etc), PCI specifications, hundreds of docs for devices, RFC's (for networking protocols), etc.
BTW are you asking about software task switching, hardware task switching, how the CPU uses TS or scheduling algorithms?
The TS flag is set by the CPU when it does a hardware task switch, so that the next FPU/MMX/SSE instruction executed will generate an exception which allows the OS to save the FPU/MMX/SSE state (and clear the TS flag). In this way the FPU/MMX/SSE state can be saved "automatically" when it needs to be (rather than as part of the task switch). If you want to use hardware task switching, but don't want to use automatic FPU/MMX/SSE saving you can clear the TS flag after doing the task switch.
Alternatively, if you want to do software task switching you could set TS yourself (just like the CPU would) and still use automatic FPU/MMX/SSE saving, or you could leave TS clear and save the FPU/MMX/SSE state during every task switch.
There's a document in the Wiki that covers all this in more detail:
http://www.osdev.org/osfaq2/index.php/C ... 0Switching
Cheers,
Brendan