2005-04-11 06:54:48

by Tomko

[permalink] [raw]
Subject: question about execve()

Hi,

I would like to ask when a userprogram called in user space called
execve("/bin/abc".... will this system call finally copy the code of
/bin/abc into kernel space before kernel runs it or just leave the code
in the userspace and run directly ? If the system really copy the
program into kernel space , why ?
Hope some one can tell me

Regards,
TOM


2005-04-11 08:34:45

by Tommy Reynolds

[permalink] [raw]
Subject: Re: question about execve()

Uttered Tomko <[email protected]>, spake thus:

> I would like to ask when a userprogram called in user space called
> execve("/bin/abc".... will this system call finally copy the code of
> /bin/abc into kernel space before kernel runs it or just leave the code
> in the userspace and run directly ?

None of these. All "execve" really does is to discard the current VM
setup, tell the VM system to attach this process to the new
executable image, and then transfer control to the starting
instruction of the program. Since nothing is really in memory, aside
from maybe some caching/readahead, page faults do all the work of
loading application code, page by page, on demand.

HTH


Attachments:
(No filename) (687.00 B)
(No filename) (189.00 B)
Download all attachments