Page 1 of 1
system calls
Posted: Thu Jun 12, 2003 11:00 pm
by pepito
I like to know which way is better to implement system calls:
1) Call gates
2) Interrupts
Why?
Thank you
pepito
RE:system calls
Posted: Fri Jun 13, 2003 11:00 pm
by mikeleany
Whichever way you want, because it's your OS. I'm going with call gates though, because they have a built-in way of passing parameters between privilege levels. You can also have more call gates than you can interrupts, but that doesn't really matter too much, because you can use one interrupt (or call gate) for multiple functions.
RE:system calls
Posted: Sun Jun 15, 2003 11:00 pm
by pepito
How the 'built-in way of passing parameters' works? It sounds interesting!
RE:system calls
Posted: Mon Jun 16, 2003 11:00 pm
by mikeleany
What I meant was that with interrupts, you (usually) can't pass parameters on the stack in protected mode, because your interrupt service routing (ISR) is usually more privileged than your application, so when your ISR is called, the processor switches to a different stack for a different privilege level. So any parameters you may have tried to pass to the interrupt on the stack wouldn't be on the new stack. Of course, there are ways that you can get around that, and some people just pass the parameters through registers instead of pushing them onto the stack.
With a call gate, you still have the stack switch, but the difference is that you can tell the CPU to copy your parameters from the old stack to the new stack for you.
To learn more about call gates, stack switching and interrupts, I suggest you refer to section 4.8 (especially 4.8.2 - 4.8.5) and chapter 5 of the Intel Manual Volume 3.
http://developer.intel.com/design/Pentium4/manuals/
RE:system calls
Posted: Wed Jun 18, 2003 11:00 pm
by pepito
Thank you very much, I'll see the manual...
pepito
RE:system calls
Posted: Thu Jun 26, 2003 11:00 pm
by pepito
I read the manual and I try to write a little example, but it fails.
I just insert a call gate (DPL=3, 0 parameters) at my GDT, and call it from the KERNEL (DPL=0) with the instruction:
call 0x820:0
But the computer restart!
What's wrong?
Where may I get some working example?
Thank you.
RE:system calls
Posted: Mon Jun 30, 2003 11:00 pm
by pepito
I get it works!
I was an error at the GDT, but now is working...
Thank you xSadar!