[Info-vax] The (now lost) future of Alpha.
Johnny Billquist
bqt at softjar.se
Tue Aug 7 15:33:29 EDT 2018
On 2018-08-07 20:40, Bob Koehler wrote:
> In article <pka3f3$fi1$1 at Iltempo.Update.UU.SE>, Johnny Billquist <bqt at softjar.se> writes:
>>
>> Even ioctl() is a C-like function in a library, that in turn does the
>> actual system call, which is a piece of assembler code.
>
> When I studied BSD UNIX, it was a user mode routine in there kernel,
> like it is in VMS, and IIRC, RSX. It contained the architecture specific
> technique for getting into the kernel mode routine.
Yes. When we say "ioctl" we can talk about two different things. Any
user mode program who calls ioctl() is calling a routine in user space,
which is included from a library. This routine is, by necessity, written
in assembler. But it is running in user space.
This routine in the library sets up the sequence to do the actual system
call. In RSX that would be loading some values on the stack and
executing an EMT instruction. In VMS I think it's also placing things on
the stack, and then doing a CHMK instruction, if I remember right (on
VAX). Unix on a PDP-11 would be using the TRAP instruction. Other
machines, and other OSes do things slightly differently, but the basic
principle is the same. You execute some instruction which traps into the
OS. The OS then looks at what caused the trap, and sees that it's a
system call, fetches the information from the user stack, and then
dispatches to the routine in the kernel that actually implement the
system call requested, which is the ioctl routine in this case then. You
can call that the ioctl function as well, but the only way to invoke
this function is through a specific sequence of instructions in user mode.
The routine in the kernel is not a user mode routine. It's a kernel mode
routine, but there are certainly more details we could be talking about
here, if needed. For example, in Unix, the system is still running in
the context of the user process even though it is in kernel mode, and a
context switch can happen when the process is down in kernel mode.
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: bqt at softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol
More information about the Info-vax
mailing list