POV-Ray : Newsgroups : povray.off-topic : Linking : Re: Linking Server Time
2 Jul 2024 23:28:03 EDT (-0400)
  Re: Linking  
From: clipka
Date: 31 May 2016 14:58:24
Message: <574dded0@news.povray.org>
Am 29.05.2016 um 09:48 schrieb Orchid Win7 v1:

> I was *about* to say that I've only done it with AmigaOS - but that's
> not quite right. What I was *actually* looking it is calling *the OS*,
> which is a bit different.
...
> Presumably any self-respecting protected-mode OS does it differently. In
> particular, calling the kernel presumably implies a transition to
> ring-0, and I don't remember how x86 does that exactly. (From what I
> dimly recall, you purposely trigger a kind of software interrupt, but
> I'm not sure how you designate what function you're trying to call.)

That's pretty simple: You pass a kind of function ID in a particular CPU
register.

For instance, in good old DOS, the sole entry point for all operating
system functions was INT 21h, with the AH register indicating which
function you intended to call.

According to Wikipedia, Linux originally used pretty much the same
principle, except with INT 80h and the AX register.

Windows also uses the AX register to identify the kernel function, but
uses the faster dedicated SYSENTER instruction (introduced with the
Pentium II) instead of a software interrupt. (The drawback is that this
instruction doesn't push a return address onto the stack, so a CALL to a
stub is usually employed.)

Likewise, Linux running on modern machines also uses SYSENTER or the
even newer SYSCALL.


The x86 architecture also provides a mechanism known as a "call gate",
which uses a CALL FAR instruction to a segment specifically set up by
the operating system to redirect the call to an entirely different
address while switching privilege level. This mechanism was used by some
operating systems, but has gone out of style. Not sure whether those
systems used a single call gate and a register to pass a function ID, or
whether they used one call gate per kernel function.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.