Process API

Process API

OS - Ch 5

Reference : http://pages.cs.wisc.edu/~remzi/OSTEP/cpu-api.pdf

Process API

  • Unix uses for() and exec() system call to create a process.

  • What kind of interface does OS provide to create and control process?

Fork()

  • forked process starts where it is called (not from the beginning)
  • Child process:
    • has Different address space, register and its own PC from its parent process.

fork() system call return value is different. Parent process gets child PID as its return, childe process gets 0.
This difference allows programmer to easily code the program that child and parent execute different code.

  • The execution order of processes may differ (non-determinism).

Wait()

  • In case when the parent process has to wait for its child processes.
  • Once every child process finishes, it returns.

Exec()

  • System call to run another process (not oneself)
  • Input: file name (program), inputs –> read the static data and program code, and overwrite the current process’s code segment and static data section.
    • For the new program, it resets heap, stack, and space addresses and so on.
    • At the given example, the child process becomes the new process (It still is a child process).
      • IT DOES NOT create a new process
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×