Page 1 of 1
Questions about x86 and Windows
Posted: Tue Sep 22, 2009 1:15 pm
by Valeron
I've got great interest to how the processor/Windows do context-switch/function-calls between different privilege level.
I've read Intel's document and some other articles. I know x86 is capable of hardware task-switch. But wikipedia articles say that software context-switch is dominating the real world because of performance.
I'd like to know how the features of processor help in a multi-tasking system but it seems that the essential part of multi-tasking does not follow the hardware design.
And since I find that the Intel document is a bit obscure on the topic, no real workflow example is given. "CALL or JMP to TSS descriptor invoke a task switch." How the OS avoid using hardware task-switch? Does it disable TSS completely? I haven't read the Intel document throughout yet. Is there any good books/articles describe this issue with example workflow and details?
Thanks.
Posted: Tue Sep 22, 2009 4:28 pm
by hto
Hi!
Valeron wrote:
I'd like to know how the features of processor help in a multi-tasking system but it seems that the essential part of multi-tasking does not follow the hardware design.
Look at OS sources, how they do it; then take debugger in hands.
There are some places in reactos:
• System calls.
KiIntSystemCall and KiFastSystemCall.
KiSystemService and KiFastCallEntry.
KeReturnFromSystemCall.
• Context switch.
KiSwapContext, KiSwapContextInternal
There is nothing magical in it.
"CALL or JMP to TSS descriptor invoke a task switch." How the OS avoid using hardware task-switch?
Simply does not CALL or JMP to TSS descriptor. :)
Does it disable TSS completely?
It is not completely disabled. In reactos it is used for NMI and double fault exception. See some code in
Ki386InitializeTss.
Re: Questions about x86 and Windows
Posted: Wed Sep 23, 2009 3:59 am
by Valeron
Hi, hto, thanks for your reply.
I haven't read the codes you post yet. I've got another question up.
If I'm going to learn multi-tasking principle, e.g. how the OS and hardware incooperate to achieve context-switch/process memory protection/priviledge level protection..etc, in what order I should read the books/articles?
For example, I read x86 document first, the features relate to multi-tasking is just hardware only, an OS completely employee the hardware can definitely function right to set-up and multi-tasking architeture. But in real world, we know it's another world. The OS give up hardware context-switch but employee the memory protection feature of the processor and GDT/LDT/IDT. And we know there's some feature is mandated, e.g. memory segmentation. You know that the x86 document(volume 3: system programming guide) is very looooooong, and with little example. That makes it not easy to be read.
Should I first understand x86's system feature before understand real-world OS?
Posted: Wed Sep 23, 2009 10:50 am
by hto
Valeron wrote:
in what order I should read the books/articles?
I don't know what to suggest; join
#ReactOS IRC channel, where most of the ros devs live. Maybe someone will point to the right direction.
Also, there is a
wiki page with some links / books. Maybe it will be useful.
Should I first understand x86's system feature before understand real-world OS?
In order to understand low-level parts of OS, some knowledge of how the processor works is needed, of course.
You can begin from some OS, and when questions will arise, search answers in books / articles / on the Web / ask people.
Re: Questions about x86 and Windows
Posted: Wed Sep 23, 2009 11:39 am
by Valeron
Thank you.
