Kernel mode programming

Zera William Holladay zholla1 at uic.edu
Tue Jan 18 10:31:56 PST 2005



On Tue, 18 Jan 2005, Ryan Sommers wrote:

> Zera William Holladay said:
> > Even if the application were run as a kernel module, how much of a
> > performance benefit could there be when making system calls?  I suspect
> > that the module would get a higher scheduling priority but realistically
> > wouldn't the module still have to make system calls in the same manner
> > that a regular user process does?  I really don't know, so would some kind
> > soul tell me please?
> >
> > -Zera Holladay
>
> The kernel is already running in privileged mode on the CPU so there is no
> need for a system call. Technically the kernel never has to make a system
> call. A system call is just a well defined method of transitioning between
> user and supervisor code. Since the kernel is already supervisor code
> there is no need to make a system call.
>
> Whenever a program makes a system call it has to generate an interrupt,
> this is the extra savings he is talking about. By already executing in the
> kernel his code does not have to suffer the overhead of an interrupt
> handler and can just make a jump to the syscall handler.

My understanding is that when a system call is made from a user process,
there is a trap into the kernel, the state of the user process is saved
and the address of the system call is determined by a looking up the
address of the system call in vector table.

I assume that a kernel module would at least have to push the parameters
of the system call, push some of its registers, jump to the address space
of the system call and return.  Further I assume, the kernel would have to
copy the parameters of the system call to another address, since it is
possible for the call to be interrupted and some of the parameters to be
corrupted.

I am really asking a question out of blind ignorance in an attempt to
learn more about what goes on with the kernel.  What is the difference
between a system call made from the kernel and a system call made from
user code?

Thanks, Zera


More information about the freebsd-hackers mailing list