# Operating Systems

> Cover processes and threads, CPU scheduling, synchronisation, deadlocks, memory management and virtual memory at interview depth. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/dsa-placement/operating-systems
Last updated: 2026-11-28

Cover processes and threads, CPU scheduling, synchronisation, deadlocks, memory management and virtual memory at interview depth.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [How Campus and Off-Campus Hiring Works](https://www.internhack.in/roadmaps/tracks/dsa-placement/placement-landscape)

OS is a favourite theory topic in both service and product-company interviews. Focus on clear explanations with small examples.

### Core concepts

- **Process vs thread**, process states, PCB, context switching, user vs kernel mode, system calls.
- **CPU scheduling**: FCFS, SJF, SRTF, Round Robin and priority scheduling. Be ready to compute average waiting and turnaround time for a small example. Starvation and aging.
- **Synchronisation**: race conditions, critical section, mutex vs semaphore (binary and counting), producer-consumer, readers-writers and dining philosophers.
- **Deadlocks**: four necessary conditions (mutual exclusion, hold and wait, no preemption, circular wait), prevention, avoidance with the Banker's algorithm, detection.
- **Memory management**: paging, segmentation, fragmentation (internal vs external), TLB.
- **Virtual memory**: demand paging, page faults, page replacement (FIFO, LRU, Optimal), Belady's anomaly, thrashing.
- Basics of file systems and disk scheduling (often asked at service companies).

### Pitfalls

- Saying mutex and binary semaphore are the same; ownership is the key difference.
- Memorising scheduling definitions without being able to draw a Gantt chart.

You are ready to move on when you can draw a Round Robin Gantt chart, list the four deadlock conditions with one way to break each, and run LRU on a page reference string.

## Key concepts

- **Processes, threads, context switch**
- **CPU scheduling algorithms**
- **Mutex, semaphores, critical section**
- **Classic synchronisation problems**
- **Deadlock conditions and Banker's algorithm**
- **Paging, segmentation, fragmentation**
- **Virtual memory and page replacement**
- **Disk scheduling**

## Mini project

Write a small simulator that takes a list of processes and prints Gantt charts and average waiting time for FCFS, SJF and Round Robin, plus a page replacement simulator for FIFO and LRU that counts page faults. Use it to answer 10 textbook numericals.

## Check yourself

What are the four necessary conditions for deadlock, and how does the Banker's algorithm avoid it?

## Free resources

- [Operating Systems: Three Easy Pieces](https://pages.cs.wisc.edu/~remzi/OSTEP/) (OSTEP)
- [NPTEL courses](https://nptel.ac.in/) (NPTEL)
- [GeeksforGeeks](https://www.geeksforgeeks.org/) (GeeksforGeeks)

Previous: [SQL for Interviews and OAs](https://www.internhack.in/roadmaps/tracks/dsa-placement/sql-interviews) · Next: [Computer Networks](https://www.internhack.in/roadmaps/tracks/dsa-placement/computer-networks)

## More in CS Core Subjects for Interviews

- [Object-Oriented Programming](https://www.internhack.in/roadmaps/tracks/dsa-placement/oop)
- [DBMS Concepts](https://www.internhack.in/roadmaps/tracks/dsa-placement/dbms)
- [SQL for Interviews and OAs](https://www.internhack.in/roadmaps/tracks/dsa-placement/sql-interviews)
- [Operating Systems](https://www.internhack.in/roadmaps/tracks/dsa-placement/operating-systems)
- [Computer Networks](https://www.internhack.in/roadmaps/tracks/dsa-placement/computer-networks)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DSA and Placement Prep Roadmap](https://www.internhack.in/roadmaps/tracks/dsa-placement)
