Operating Systems
An operating system manages hardware resources and gives programs a clean, multiplexed view of them. Its job: schedule CPU time, allocate memory, mediate I/O, and isolate processes.
Overview
User-space code talks to the kernel through system calls. The kernel runs in privileged mode; everything else is sandboxed. Modern kernels are mostly monolithic (Linux, Windows NT) with loadable modules.
Processes & Threads
- Process — isolated address space, own page tables, PID.
- Thread — shares memory within a process; cheaper context switch.
- IPC: pipes, FIFOs, sockets, shared memory, message queues, signals.
- Synchronization: mutex, semaphore, condition variable, RW lock, atomics.
- Hazards: deadlock, livelock, priority inversion, race condition.
Memory Management
- Virtual memory + paging — typical page 4 KiB, huge pages 2 MiB / 1 GiB.
- TLB caches recent translations.
- Page faults — minor (allocate) vs major (disk).
- Allocators: brk/sbrk, mmap, slab, jemalloc, tcmalloc.
- OOM killer (Linux) reclaims pages under pressure.
Filesystems & I/O
- POSIX filesystems: ext4, XFS, btrfs, ZFS, APFS.
- Windows: NTFS, ReFS.
- Inodes, dentries, journals, copy-on-write, snapshots.
- Block / character / network devices.
- Async I/O: epoll, kqueue, io_uring, IOCP.
Scheduling
- Preemptive multitasking; time slices (jiffies, ticks).
- Linux CFS & EEVDF; real-time policies SCHED_FIFO, SCHED_RR.
- RTOS: FreeRTOS, Zephyr, VxWorks, QNX, RTEMS — used in embedded & safety systems.
- Priority inheritance to prevent inversion.
OS Families
- Unix-like: Linux distros, *BSD, macOS (Darwin), Solaris.
- Windows: NT-based (10, 11, Server 2019/2022/2025).
- Mobile: Android (Linux), iOS (Darwin).
- RTOS: see above.
- Industrial: Windows IoT, Linux with PREEMPT_RT, VxWorks.