kuniga.me > Docs > Operating Systems Cheat Sheet

Operating Systems Cheat Sheet

Common definitions and terminology in operating systems.

For Linux specifics, see the Linux Cheat Sheet.

Index

  1. Lock
  2. Mutex
  3. Semaphore
  4. Spin Lock

Lock

Mutex

It’s a type of lock. Stands for mutually exclusive lock.

When a thread tries to acquire a already locked Mutex, the kernel puts that thread to sleep and it will be awakened once the lock is unlocked.

Semaphore

A semaphore is a more generalized version of a lock because it supports up to N threads to “enter” on a exclusive region.

If N = 1, it behaves like a lock, albeit an expensive one.

Spin Lock

It’s a type of lock that keeps trying to acquire a lock in a loop. It doesn’t require the thread to be context-switched, but consumes CPU cycles.