Concurrency Introduction

  • Perform two activities at the same time

    • Conceptually different
  • e.g. A program which executes a long-running task

    • Fetching data over the network
    • Performing a lengthy computation
  • The program displays "feedback" to the user

    • "Hourglass" cursor
    • Progress counter
  • The task and the feedback are performed at the same time

Concurrency and Operating Systems

  • Standard in operating systems for many years
  • Computers run many programs at the same time
    • Compiler generates code
    • Word processor waits for the next keystroke
    • Mail program fetches a new email

Hardware Concurrency

  • Modern computers have multiple processors

    • Multiple CPU chips
    • CPU chips which contain multiple processor "cores"
  • Different processors can perform different activities at the same time

  • Even within the same program

  • These are known as "hardware threads"

    • Each processor follows its own "thread of execution" through the code
    • 1 hardware thread <=> 1 processor core

Software Concurrency

  • Modern operating systems support "software threading"
  • A program can perform multiple activities at the same time
    • These activities are managed by the operating system
  • Typically there are more software threads than hardware threads
    • Some threads may have to stop and wait for something
    • While they are waiting, another thread which is ready can run