Skip to content

Parallel Programming - Processes


A process is a program being executed.

Processes are managed by the operating system.


task_manager_processes.jpg


  • A process can take up several resources, mainly CPU and Memory (RAM)
  • A process can be executed on one ore more CPU cores and thus takes up a percentage of it’s computing power
  • A process can allocate memory in RAM

  • The operating system can execute more processes than the number of available cores.
  • This happens by scheduling the CPU computing time and deviding/sharing it between the processes.

  • The OS manages processes using process tables.
  • They contain the necessary information to control their execution.
  • Entries in a process table are called process control block (PCB).

  • Contains:
    • Process Identification (PID)
    • Resources requested by the process (e.g. files)
    • Area of the memory allocated by the process.
    • Process State
    • Contents of the process register

PCB.png


A process is executed by the operating system by loading it’s registers from the PCB into the CPU


  • A process is being executed if it is assigned to a CPU.
  • It’s state will then change to Running.

  • Processes are being controlled by changing their states
  • We can abstract 3 states:
    • Running
    • Ready
    • Blocked

Process_States.png


  • Running
    • The process is being executed
  • Ready
    • The process waits until the OS assigns a CPU to it
  • Blocked
    • The process needs an external resource
    • Until the resource can be loaded by the OS, the process will remain in the state Blocked.

  • A system is said to be concurrent if it can support two or more action in progress at the same time.
  • A system is said to be parallel if it can support two or more actions executing simultaneously.

Concurrent_vs_Parallel.png


Concurrent_vs_Parallel_2.png


  • Concurrent execution means two or more processes share the same CPU core.
  • The CPU will rotate through the processes giving each processes a certain amount of execution time, before switching to the next process.
  • When switching a process, the data of the process will be written into memory and the content of the next process will be loaded into the register of the CPU.

  • Loading a new process into the CPU is called context switch.
  • A context switch is a time consuming operations. Many context switches will slow down the system.

Context_Switch.png


  • A context switch consists of these steps:
    • Updating and saving the current PCB
    • Selecting the next process for execution
    • Restoring and updating the PCB of the new process.