Process

An OS abstraction that represents a program loaded into memory and executed, includes:

  • Memory resources

  • Execution state - registers

  • Resources

  • Process control block - state maintained by the OS
    Can have one or more threads

API

  • fork() - duplicate the current process - copy memory and register state

    • 2 processes will have different PID

    • Original is now the parent process, new is child process

  • exec()/execvp() - replaces the current process' memory image with a new program

  • wait() - parent process waits for one of its child processes to finish

    • If not called, the child enters zombie state - terminated but not cleaned up

Creation

  • OS allocates internal data structures

  • OS allocates an address space

    • Loads code, data from disk

    • Creates runtime stack, heap

  • OS opens basic files (STDIN, STDOUT, STDERR)

  • OS initialises CPU registers