Hi everyone,
i am new to the OS development. i find the tutorial very useful. thanks mike and all for this wonderful site.
please can any one explain me what is the difference between interrupt, trap gate and task gate.
currently developing
http://zygote.googlecode.com
difference between interrupt, trap gate and task gate
Moderator:Moderators
-
- Posts:9
- Joined:Fri Sep 18, 2009 6:23 am
Re: difference between interrupt, trap gate and task gate
i suggest reading http://wiki.osdev.org/Interrupt_Descriptor_Table.
As a brief overview - trap and interrupt gates are almost identical apart from the fact that interrupt gates automatically disable interrupts while active whereas trap gates don't.
Task gates are used in hardware task switching, which is old and slow and generally not used these days. The only thing they are used for is when a piece of userland code needs to call a kernel function which requires a task switch to ring 0.
As a brief overview - trap and interrupt gates are almost identical apart from the fact that interrupt gates automatically disable interrupts while active whereas trap gates don't.
Task gates are used in hardware task switching, which is old and slow and generally not used these days. The only thing they are used for is when a piece of userland code needs to call a kernel function which requires a task switch to ring 0.

-
- Posts:9
- Joined:Fri Sep 18, 2009 6:23 am
Re: difference between interrupt, trap gate and task gate
thanks for the reply andy. i have one more question, in demo 7 why do we install GDT twice (in assembly and C)?
Re: difference between interrupt, trap gate and task gate
The first time we install the GDT, it is a basic one allowing us to jump into 32bit mode without having to deal with the full complexities of a complete GDT.
Later, in C, we install our own one separately, where we can easily append entries as and when we need them:
Specifically, we will need entries for ring 3 descriptors when making the jump to userland, and a Task State Segment (per CPU for a multi-core processor) to allow userland programs to make kernel calls.
In C, we can just append these entries and recompile, whereas using the original GDT would require us to find it first, then trash the code around it. It is also likely that the boot sector will be kept, as it is completely useless to the operating system once it has loaded, meaning that the original GDT would be lost completely.
Later, in C, we install our own one separately, where we can easily append entries as and when we need them:
Specifically, we will need entries for ring 3 descriptors when making the jump to userland, and a Task State Segment (per CPU for a multi-core processor) to allow userland programs to make kernel calls.
In C, we can just append these entries and recompile, whereas using the original GDT would require us to find it first, then trash the code around it. It is also likely that the boot sector will be kept, as it is completely useless to the operating system once it has loaded, meaning that the original GDT would be lost completely.
