Exec

Execute an executable file

long Exec (
        struct EXEC *exec,
        long argc,
        char *argv
)

Arguments

exec Pointer to executable file descriptor
argc Number of arguments
argv Argument string

Return value

1 is returned if the function was successful.
0 is returned in all other cases.

Explanation

An executable file that has been loaded into memory and which is described by the information contained in the EXEC structure pointed to by exec is executed.
argc and argv are passed to the executable program.
If exec->s_addr is 0, neither the stack pointer nor the frame pointer is initialized.
The operation of Exec() is shown below:
  1. The uninitialized data section is cleared.
  2. sp, fp and gp are saved, then initialized (fp is set to the value of sp).
  3. The arguments of main() are set in the a0 and a1 registers.
  4. A jump is made to the execution start address.
  5. sp, fp and gp are restored after returning.

Notes

Exec() must be executed in a critical section.

See Also

EXEC, Load()