Table of Contents

What are some common threading models?

  1. OS Threads (use libpthreads to map to the OS’ memory model)
  2. Single-threaded event loop (node.js as an example). There is a single event loop, where actions on the main loop are blocking, but there can be asynchronous tasks scheduled.
  3. N:1 threads: The model maps N user threads to a single system thread. The process then handles running those threads at different times. These can be more lightweight.
  4. Multi-thread event loops: One or several threads run event dispatchers. They can move tasks to other threads for execution.
  5. M:N threading library: The model maps M user threads to N system threads. They are like N:1 threads but more flexibly, but can have trouble with cache coherence and perforamnce.