Synchronization and Concurrency in Kernel Space
Manage shared data safely in the kernel using spinlocks, mutexes, atomic operations, and an awareness of interrupt context versus process context.
The Concurrency Problem
Kernel code runs in a brutally concurrent environment: multiple CPUs, preemptible threads, and interrupts that fire anytime. Unprotected shared data leads to race conditions and corruption.
Process vs Interrupt Context
Kernel code runs in two contexts:
- Process context: on behalf of a syscall; can sleep
- Interrupt context: handling hardware; must NOT sleep
The context dictates which locking primitive is legal.
All lessons in this course
- Introduction to Kernel Space
- Writing Simple Device Drivers
- Interfacing with Hardware Directly
- Synchronization and Concurrency in Kernel Space