Process: a program in execution, fundamentally a container that has all the information needed to run a program

Address space: a range of memory locations from 0 to some max that the process can read and write to

PSW: Program status word, contains

  • Condition code bits
  • CPU priority
  • The mode (user/kernel) of the current program

A CPU switches between processes multiprogramming

Daemon: a process running in the background

Every is identified by the process id (PID) and has a:

  • Working directory (pwd)
  • UID: the user id
  • GID: the goup id

child processes inherit the these properties from the parent process

The root user has UID 0 and all privileges

Process memory #

In Unix processes have their memory divided into three segments:

  • Text segment: the machine code to be executed
  • Data segment: the global & static variables of the program
  • Stack segment: stack memory for local variables

Process memory

Creation #

On Unix done using the fork syscall which copies over the memory, open files etc.

Termination #

If a parent process terminates before its child, the child is called an orphan and its parent is set to the init process. All threads are terminated though because they are part of the processes.

A process can be terminated by a signal, see system calls.

States #

A process is always in one of the following three states:

  1. Running, the CPU is actually executing the instructions
  2. Ready, runnable but another process is run
  3. Blocked, unable to run until something happens

Process states

The scheduler determines which process to run and when.

The state is maintained by the operating system in the Process Control Block (PCB) saved in the Process Table, a data structure that the operating system has for every process, itentified by the PID. The PCB contains the state, program counter, stack, open files etc