Knowledgebase

Concurrency and Parallelism Print

  • programminglanguages, programming, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Doing several things.

WHAT CONCURRENCY IS

Structuring a program so several tasks can be in progress.

WHAT PARALLELISM IS

Executing several tasks simultaneously, on several cores.

WHY THEY ARE DIFFERENT

Concurrency is about structure. Parallelism is about execution.

WHAT APPROACHES EXIST

Threads, sharing memory Processes, isolated Asynchronous execution on one thread Lightweight tasks managed by the runtime Message passing between isolated units

WHAT SHARED MEMORY CAUSES

Race conditions, where the result depends on timing.

WHAT THOSE ARE LIKE

Intermittent, difficult to reproduce, and among the hardest bugs to diagnose.

WHAT PREVENTS THEM

Locks, used correctly Avoiding shared changing state Message passing

WHAT A GLOBAL INTERPRETER LOCK IS

A mechanism in some runtimes preventing threads executing code simultaneously.

WHAT THAT MEANS

Threads help with waiting, not with computation.

WHAT TO USE FOR COMPUTATION IN THOSE LANGUAGES

Separate processes.

WHAT TO ESTABLISH FOR ANY LANGUAGE

What its model is, and what it protects you from.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot