What should every engineer know about concurrency and operating systems?
Concurrency is structuring a program to handle many tasks at once; parallelism is executing them simultaneously on multiple cores.
Essentials
- Processes vs threads — processes are isolated; threads share memory (faster, but riskier)
- Async / event loop models (Node.js, Python asyncio) handle many I/O-bound tasks on few threads; CPU-bound work needs worker threads or processes
- Race conditions and shared state — protect with locks, atomic operations, immutable data or message passing
- Deadlock — avoid by acquiring locks in a consistent order and using timeouts
- Memory — stack vs heap, garbage collection, leaks and pressure; profile before tuning
- OS resources — file descriptors, sockets, scheduler behaviour and context-switch cost; ulimits and pool sizes matter under load
- Backpressure — bound queues and concurrency so overload degrades gracefully
Diagnosis tools: profilers, flame graphs, thread dumps, strace/perf and heap snapshots.