STEM · Computer Science · Foundational Concepts/Principles
SaveOperating Systems Concepts
Significance: OS manages hardware resources and provides abstractions for applications. Key concepts: processes (executing programs), threads (lightweight processes), scheduling (CPU allocation), memory management (virtual memory, paging), file systems, concurrency (synchronization, deadlock). Understanding OS essential for systems programming and performance optimization.
Questions to think through
- explain
Explain virtual memory: Physical RAM is limited (e.g., 16 GB). Virtual memory gives each process illusion of large address space (e.g., 256 TB on 64-bit systems). OS maps virtual addresses to physical addresses using page tables. When physical memory is full, OS swaps pages to disk. Explain: (a) why this enables running programs larger than RAM (b) how protection works (processes can't access others' memory) (c) what causes page faults (accessing unmapped page requires loading from disk).
- explain
Analyze concurrency: Two threads increment shared counter: `x = x + 1`. Without synchronization, race condition occurs: both read x=0, both write x=1, final value is 1 (should be 2). Explain why: operation is three steps (load, increment, store), threads can interleave. Solutions: (a) locks/mutexes (acquire before access, release after) (b) atomic operations (hardware guarantees indivisibility) (c) transactional memory. Why does lock-free programming (using atomics) perform better but is much harder to reason about?
