2b – Process Abstraction in Unix

Process initialization

The master process init

Fork creates the process tree from the most common ancestor (PID = 1). Continues running until shutdown.

Process creation

Creates a new child process, a duplicate of the current executable image.

New program execution

execl replaces currently executing process image with a new one.

int main() {
	execl( "/bin/ls", "ls", "-al", NULL);
} // executes "ls -al"

Parent/Child synchronization

wait(int *status) returns the PID of the terminated child process in the least significant byte of *status.

waitid() suspends until the child specified by the PID argument changes state.

Scheduling Running –> Ready: When the OS decides you are taking up too much CPU time, you will be sent back to the ready queue

Process Termination

Zombie Processes

Orphan Processes