difference between interrupt, trap gate and task gate

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
vijaymohan
Posts:9
Joined:Fri Sep 18, 2009 6:23 am
difference between interrupt, trap gate and task gate

Post by vijaymohan » Fri Sep 18, 2009 6:33 am

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

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: difference between interrupt, trap gate and task gate

Post by Andyhhp » Sun Sep 20, 2009 2:58 pm

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.
Image

vijaymohan
Posts:9
Joined:Fri Sep 18, 2009 6:23 am

Re: difference between interrupt, trap gate and task gate

Post by vijaymohan » Mon Sep 21, 2009 3:17 am

thanks for the reply andy. i have one more question, in demo 7 why do we install GDT twice (in assembly and C)?

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: difference between interrupt, trap gate and task gate

Post by Andyhhp » Mon Sep 21, 2009 8:13 am

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.
Image

Post Reply