[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic system call question



Erik Mouw wrote:
> 
> On Mon, May 14, 2001 at 08:51:07AM +0100, Ralph Corderoy wrote:
> > > Why is the syscall "int 0x80"?  Is this where the system is actually
> > > executed with the arguments previously listed?  It is not the return
> > > value, and the system call number is already 42.
> >
> > The `int 0x80' generates the interrupt that switches to the kernel
> > which in turn seems to examine the %eax register to see what system
> > call is required.  I'd guess all system calls generate the same
> > interrupt, 0x80, and the only thing to distuinguish between them is the
> > value of %eax.
> 
> Your guess is correct (for i386, that is ;).

Which reminds me of a question I had some time ago, but wasn't
able to investigate at the time. The kernel_thread() function,
called to spawn kernel threads, seems to invoke int0x80 with
the contents of EAX undefined. Am I insane, or what? I suppose
something about the calling convention used in the kernel
must gaurantee the EAX value is something useful, but is that
documented anywhere? I have not been able to figure out why
this code works.

<http://lxr.linux.no/source/arch/i386/kernel/process.c#L439>

Thanks,

-- Joe
 

-- Joseph A Knapka
"If I ever get reincarnated... let me make certain I don't come back
 as a paperclip." -- protagonist, H Murakami's "Hard-boiled Wonderland"
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/