Operating systems: processes, threads, memory and race conditions
Connecting operating-system fundamentals to practical software failures: isolation, scheduling and shared-state races.
Processes and threads
A process runs in a managed execution context with its own virtual address space and resources. Threads inside a process normally share memory but have independent execution stacks. More threads do not automatically make code faster. Unsynchronized access to shared state can produce results that depend on scheduling order.
Why races occur
Two threads can read the same counter, increment locally and write back, losing one update. Read-modify-write is not automatically atomic. Mutexes, atomic operations and message passing offer different ways to protect critical sections. Lock ordering and deadlock risks must be considered alongside correctness.
Virtual memory and limits
Virtual address space does not map one-to-one to installed RAM; operating systems use paging and memory management. Growth can arise from leaks, caches or valid data processing. One number in a task manager is not a diagnosis. Compare working set, allocations, page faults and application-level measurements.
Reproduce the race
Run many concurrent counter updates to expose lost increments, then repeat with proper synchronization. Compare both correctness and latency. Not every workload benefits from more threads; keeping shared state minimal often improves clarity and reliability.
Comments
0 real commentsNo real reader comments yet.
✎ Write a comment