Concurrency Motivation

  • Why is concurrency important?

    • Had been used by mainframes since the 1960's
    • Became wider concern in the mid 1990's
  • Four main industry trends:

    • Rise of the Internet

      • Server throughput had to increase dramatically
    • Popularity of Windows

      • Separation of concerns (responsiveness)
    • Popularity of games and multimedia

      • Fast numeric computation
    • Availability of multi-core processors

      • Effective use of hardware

Server throughput

  • Single threaded server

  • Performs each activity as a single "process"

    • An instance of an executing program
  • A server process wait for a client to connect to it

  • When a client connects, the server creates a new process

    • The child process handles the client
    • The server waits for the next connection
  • The server may need to communicate with a child process

    • Control its execution
    • Exchange data with it
  • This requires "Interprocess Communication" (IPC)

  • Single threading causes overhead

    • Process creation
    • Setting up IPC
  • Reduces scalability

Separation of Concerns

  • Single threaded program to edit documents

  • The user starts a long running action

    • e.g. Indexing or formatting a large document
  • The program cannot respond to GUI events immediately

    • It is executing code to perform the action
  • The user interface ignores mouse clicks, key presses, etc

    • If the action is covered up by another application and then uncovered, it turns into a grey box
  • Eventually the action ends

    • The program processes all the stored-up GUI events
    • Usually with undesirable consequences!
    • Poor user experience

Fast Numeric Computation

  • Used to require specialized hardware

    • Supercomputers and transputers with large numbers of processors
    • Parallel processing architecture
    • Specialized programming languages
    • Very expensive!
  • Now feasible on modern general-purpose hardware

    • Much lower cost
    • Supported by standard programming languages
  • But not with single threaded programs!

Effective Use of Hardware

  • Demand for faster and more powerful computers

    • Make the processor bigger
    • Raise the clock frequency
  • Hardware engineers approaching physical limits

    • Speed at which electrons can move through silicon
    • Heat generated
  • Hardware designs began using "cores" instead

    • Several processors on the same silicon chip
  • A single-threaded program can only run on one core at a time

    • Only uses a fraction of the system's potential

Benefits of Concurrency

  • Server throughput

    • The child and server run in the same process
    • No overhead from creating processes
    • Can have direct access to each other's data
  • Separation of concerns

    • A program can respond to GUI events while performing a long-running task
    • Improves the user experience
  • Fast numeric computation

  • Effective use of hardware

    • A program can execute on different cores at the same time