Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flipeador/8520fb03b6340f382d944d28be0c3383 to your computer and use it in GitHub Desktop.
Save flipeador/8520fb03b6340f382d944d28be0c3383 to your computer and use it in GitHub Desktop.
Asynchrony, concurrency and simultaneity.

Asynchrony - Concurrency - Simultaneity

🔄 Synchrony

Synchrony implies that the execution of multiple tasks occurs sequentially one after the other. Tasks are like steps that are executed in order, each operation blocks the others until completion.

Task #1   ├───────────┤............................
Task #2   .............├────────────┤..............
Task #3   ...........................├────────────┤

🌀 Asynchrony

Asynchrony implies that the execution of multiple tasks may occur in some form of parallelism. Asynchrony is made possible through a program whose programming model allows operations to be executed in a non-blocking fashion. Asynchronous tasks are typically handled by a single-threaded event loop, which can offload these tasks to a thread pool.

Task #1   ├─────...........───────────┤   (Core #1)
Task #2   ......├─────.....─────|......   (Core #2)
Task #3   ............├────......─────┤   (Core #2)
Task #4   ............├───────────────┤   (Core #3)
💻 Link
Node.js https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick
Python https://docs.python.org/library/asyncio-eventloop.html

⏰ Concurrency

Concurrency implies that the execution of multiple tasks occurs within the same period. Tasks may overlap temporally, but they are not executed at the same instant. Simulated parallelism is made possible through the use of multiple threads; The operating system is responsible for scheduling the execution times by interrupting a running thread to assign CPU time to another thread (Context Switch).

Task #1   ├─────......─────..................─────┤
Task #2   ......├─────...........─────┤............
Task #3   .................├─────......─────┤......

🔀 Simultaneity

Simultaneity implies that the execution of multiple tasks occurs at exactly the same time. Real parallelism is made possible through the use of hardware with multiple CPU/GPU cores.

Task #1   ├───────────────────────────┤   (Core #1)
Task #2   ├───────────────────────────┤   (Core #2)
Task #3   ├───────────────────────────┤   (Core #3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment