Operating Systems Deep Dive | Resources by Shumbul Arifa

🖥️ Operating Systems Deep Dive

The OS concepts interviewers love, explained with everyday analogies so they actually stick. Read a section, take its quiz, and finish with a scored final quiz to prove you have got it.

🎯 Interview-oriented 📝 Quiz after each section 🏆 Final scored quiz

Processes & threads

A process is a running program with its own private memory. A thread is a lighter unit of execution that lives inside a process and shares that process's memory with sibling threads.

Analogy: a process is a house (its own address, its own stuff). Threads are the people living in that house, they share the kitchen and rooms (memory), so they cooperate cheaply, but if one starts a fire, everyone is affected.
Remember:
  • Processes are isolated (a crash in one does not kill another); threads in a process are not.
  • Creating a thread is cheaper than a process; switching between threads is faster too.
  • Threads share memory (fast communication, but needs synchronization); processes need IPC to talk.

CPU scheduling

The CPU can run one thing at a time per core, so the OS scheduler decides who runs next. The goal: keep the CPU busy while feeling responsive to users.

AlgorithmIdeaWatch out for
FCFSFirst come, first servedA long job blocks everyone (convoy effect)
SJFShortest job firstLong jobs can starve; needs to know job length
Round RobinEach gets a fixed time slice, then rotateTime slice too big = FCFS; too small = overhead
PriorityHighest priority runs firstLow-priority starvation (fix with aging)
Analogy: Round Robin is a group of friends sharing one video-game controller with a 5-minute timer, everyone gets a fair turn. SJF is a supermarket "10 items or fewer" lane: quick shoppers finish fast, but someone with a full cart may wait a long time.

Deadlocks

A deadlock is when processes wait on each other forever, none can proceed. It needs all four of these conditions at once:

  • Mutual exclusion - a resource is held by only one process at a time.
  • Hold and wait - a process holds one resource while waiting for another.
  • No preemption - resources cannot be forcibly taken away.
  • Circular wait - a cycle of processes each waiting on the next.
Analogy: two people at a narrow bridge, each stepping on halfway and refusing to back up. Neither can pass, neither will reverse. Break any one rule (say, one agrees to reverse, that is preempting) and the deadlock is gone.

Because you need all four, breaking any one prevents deadlock. A common practical fix: always acquire locks in a fixed global order, which removes circular wait.

Synchronization: mutex vs semaphore

When threads share data, you must stop them corrupting it by acting at once. That shared, must-be-exclusive code is the critical section.

MutexSemaphore
MeaningA lock: one holder at a timeA counter allowing N at a time
OwnershipOwned by the locker (only it unlocks)No ownership; anyone can signal
Use forMutual exclusion (one resource)Limiting access to N resources / signaling
Analogy: a mutex is the single key to one toilet, whoever holds it is inside, everyone else waits. A semaphore is a parking lot with N spaces and a counter at the gate: it lets N cars in, then makes the rest wait until a space frees up.

Virtual memory & paging

Virtual memory gives each process the illusion of a large, private, contiguous memory, even though physical RAM is limited and shared. The OS splits memory into fixed-size pages and maps virtual pages to physical frames.

When a process touches a page that is not in RAM, a page fault occurs and the OS loads it from disk. Too many page faults (constant swapping) is called thrashing, and it destroys performance.

Analogy: your desk is RAM (small, fast), the filing cabinet is disk (big, slow). Paging is fetching just the folder you need onto the desk. Thrashing is a desk so small you spend all day swapping folders in and out and never actually working.

Final quiz

Ten questions across everything above. Aim for 7+ before you call this subject interview-ready.

What to do next

🌱 How to use this

Each section gives you the theory with a real-world analogy, then a short quiz so you can check yourself immediately. At the very end there is a final quiz that scores you out of 10. Do not just read, answer the quizzes out loud too, that is closer to the real interview. Want a concept re-explained? Tap ✦ Ask AI. This is the deep dive companion to the CS Fundamentals guide.