Subj : Interrupts
To   : Lee Aroner
From : Vitus Jensen
Date : Thu May 24 2001 06:00 am

Moin Lee!

23.05.2001, Lee Aroner wrote a message to Vitus Jensen:

RV>>> First, OS/2 doesn't use interrupts.  You have to use API calls.
RV>>> Second, since OS/2 is a multitasking OS, it manages memory much
RV>>> differently than DOS does.

LA>>    Not to niggle the point, but of course OS/2 uses interrupts. Each
LA>> and every one of those API calls is a wrapper around an interrupt
LA>> call.

VJ>> Well, to be exact: OS/2 uses callgates to jump into kernel code.
VJ>> Callbacks  are similar to interrupt gates in that they switch  priviledge
VJ>> levels and have a predefined entry point into  the kernel but they
VJ>> additionally copy bytes from lower to  higher level stacks while
VJ>> swichting (byte count defined in  the callgate).  Something what a
VJ>> interrupt gate won't do.
VJ>> It is a common design of OSses to do this switching via a software
VJ>> interrupt but OS/2 is different.

LA>    Ah, but are not those callgates accessed through an interrupt?
LA> It's irrelevant that it is an invalid interrupt, a spade 's a
LA> spade after all...

It's no INT xx instruction but really a call far.  You do a *CALL FAR
XXXX:0000*.
The offset doesn't matter (as the callgate defines the entry point) but the
XXXX (selector) points to an entry in the GDT or LDT (LDT should be possible
but I've never seen a callgate in it in OS/2) which is a callgate (descriptor
type 4).  The descriptor defines the destination (selector:offset) and how many
words are copied from the lower ring stack to the new stack.

You can examine how this works by installing _Theseus_ on your machine.  Debug
your program using any debugger which can display assembler instructions and
trace until you find a "CALL XXX:0000" instruction, write down the XXXX.
Now start Theseus and have a look at the GDT.  Lookup XXXX (ignore bit 0-2),
you find a descriptor with /Descriptor Priviledge Level/ 3 (because it's
callable from a ring 3 application), some offset and a selector which is
probably 0168 (perhaps dependent on OS/2 version).
Lookup 0168 in the GDT, you find the code selector for the kernel, ring 0,
limit FFFFFFFF.

I would like to have an Intel or AMD manual about the i386 because this stuff
IMHO is best explained by the processor vendor but I have only a bad german
short reference.  One of these days I should "lend" one from the library...

Bye,
  Vitus

PS: I'm maintaining an OS for embedded systems where we use an interrupt, a
structure pointed to by register XWA and a software dispatcher.  This is
probably what you have in mind.
PPS: just implemented preemptive multithreading for that system.  Cool!
---
* Origin: Accelerate Windows, to escape velocity. (2:2474/424.1)