Skip to content
CS core series · PDF ebook

Operating Systems, explained the way interviews ask.

Processes, threads, CPU scheduling, synchronization, deadlocks, paging, virtual memory and file systems, built up from zero. Then 16 solved problems, 60 rapid-fire interview questions and a Linux toolkit for real servers.

15
chapters
16
solved problems
60
interview Q&A
6
scheduling algorithms
₹79₹19960% off
  • Secure checkout via Razorpay
  • Digital PDF ebook
  • Read on phone, tablet or laptop
Operating Systems ebook coverPDF ebook
Quick answers

Short answers, straight from the book

The questions asked most in exams and interviews, answered the way you would say them out loud.

  • What is the difference between a process and a thread?

    A process is a program in execution with its own address space, files and resources. A thread is a unit of execution inside a process; threads of one process share its memory and files but each has its own stack, registers and program counter, so switching between them is cheaper.

  • What are the four conditions for deadlock?

    Mutual exclusion, hold and wait, no preemption and circular wait. A deadlock can happen only when all four hold at once, so breaking any one of them prevents it.

  • What is the difference between a mutex and a semaphore?

    A mutex is a lock with ownership: only the thread that locked it can unlock it, and it protects one critical section. A semaphore is a counter that any thread can signal; a counting semaphore can let several threads in, which suits resource pools and producer-consumer.

  • What is thrashing?

    Thrashing is when a process has too few frames, so it page-faults constantly and the system spends more time swapping pages than running code. CPU utilisation collapses; the fix is to give processes enough frames for their working set or run fewer of them.

Try it free

Run the numericals instead of drawing them

Edit the processes and watch the Gantt chart, waiting and turnaround times update. Then step a reference string through FIFO, LRU and Optimal.

Processes

PIDArrivalBurstPriorityRemove
P1
P2
P3
P4

Times in ms. For Priority, a lower number runs first. Ties go to the earlier arrival.

Gantt chart · Round Robin

PIDATBTCTTATWTRT
P105111160
P21310961
P3215322
P4329644
Avg7.254.501.75

CT completion · TAT = CT − AT · WT = TAT − BT · RT = first run − AT · 6 context switches

Same processes, every algorithm · average waiting time

  • 4
  • 3.25
  • 2.25lowest
  • 4.25
  • 4.50

Page replacement

Frame7012030423032
F17772222444000
F2000000003333
F311133322222
ResultFFFFHFHFFFFHH
Page faults
9
Hits
4
Hit ratio
30.8%
Compare
FIFO 10 · LRU 9 · Optimal 7

Highlighted cells are pages loaded on a fault. Optimal is the lower bound no real system can reach, because it needs the future. Add a frame under FIFO with “1 2 3 4 1 2 5 1 2 3 4 5” to see Belady’s anomaly.

AlgorithmTypeBest forTrade-off
FCFSNon-preemptiveSimple batch systemsEasy to implement but suffers from the convoy effect; long jobs delay everyone.
SJFNon-preemptiveMinimizing average waiting timeOptimal average waiting time among non-preemptive policies, but needs burst estimates and can starve long jobs.
SRTFPreemptiveShort-job responsivenessPreemptive SJF; best average waiting time, higher context-switch overhead and starvation risk.
PriorityEitherSystems with importance levelsLow-priority processes can starve; aging gradually raises their priority to fix it.
Round RobinPreemptiveTime-sharing and interactive systemsFair and responsive; performance depends heavily on the time quantum.
MLFQPreemptiveGeneral-purpose OS (Linux, Windows style)Moves processes between queues based on behaviour, balancing responsiveness and throughput.
Mental models

Two flows explain most of the OS

Most questions are about how a process moves between states, and how a virtual address becomes a physical one.

Model 01

Process lifecycle

A process moves between states as the scheduler, I/O and the kernel interact. Knowing each transition makes scheduling, synchronization and deadlocks easy.

  1. 1New
  2. 2Ready
  3. 3Running
  4. 4Waiting
  5. 5Done

Every context switch saves the running process in its PCB and restores another, which is the hidden cost behind scheduling decisions.

Model 02

Virtual address translation

Each process sees a private address space. The MMU, TLB and page tables translate virtual addresses, and the OS fetches missing pages from disk.

  1. 1Virtual addr
  2. 2TLB
  3. 3Page table
  4. 4Physical RAM
  5. 5Disk

A TLB hit is fast; a miss walks the page table; a page fault loads the page from disk. Effective access time numericals follow directly from this.

Syllabus

15 chapters, from the kernel to the Linux shell

Core foundations, scheduling and concurrency, memory and storage, security and real-world Linux, then a full practice and revision part.

15 chapters · 56 sections

Part 01Core FoundationsKernel, processes and threads
01Operating System Fundamentals7 sections

What an OS is and does, the types of operating systems, how the kernel is protected with dual mode, interrupts and traps, how programs request services through system calls, and how the OS boots.

  • What is an Operating System
  • Functions of an OS
  • Types of OS
  • Dual Mode, Interrupts and Traps
  • System Calls
  • OS Structures
  • The Boot Process
02Processes6 sections

Program vs process, process states, the PCB and context switching, schedulers and queues, fork/exec/wait, and inter-process communication.

  • Program vs Process
  • Process States
  • PCB and Context Switch
  • Schedulers and Queues
  • Process Creation and Termination (fork, exec, wait)
  • Inter-Process Communication
03Threads and Multithreading3 sections

What a thread is, user-level vs kernel-level threads with the mapping models, and the difference between concurrency and parallelism along with common thread issues.

  • What is a Thread
  • User-Level vs Kernel-Level Threads and Mapping Models
  • Concurrency, Parallelism and Thread Issues
Part 02Scheduling & ConcurrencyWho runs, when, and how they cooperate
04CPU Scheduling4 sections

Scheduling terms and formulas, every major algorithm, a worked example that runs four processes through four algorithms, and starvation, the convoy effect and real systems.

  • Basic Terms and Formulas
  • The Scheduling Algorithms
  • Worked Example (four processes, four algorithms)
  • Starvation, Convoy Effect and Real Systems
05Process Synchronization5 sections

Race conditions and the critical-section problem, Peterson's solution, hardware atomics and locks, semaphores, the classic synchronization problems, monitors and priority inversion.

  • Race Condition and the Critical-Section Problem
  • Peterson, Hardware Atomics, Locks
  • Semaphores
  • Classic Problems (Producer-Consumer, Readers-Writers, Dining Philosophers)
  • Monitors, Condition Variables and Priority Inversion
06Deadlocks4 sections

What a deadlock is, the strategies to handle it, safe states and Banker's algorithm for avoidance, and detection with recovery.

  • What is a Deadlock
  • Handling Deadlocks
  • Avoidance: Safe State and Banker's Algorithm
  • Detection and Recovery
Part 03Memory & StorageFrom RAM and paging to disks and files
07Memory Management4 sections

Logical vs physical addresses and binding, contiguous allocation and fragmentation, paging, segmentation and segmented paging.

  • Logical vs Physical Address, Binding
  • Contiguous Allocation and Fragmentation
  • Paging
  • Segmentation and Segmented Paging
08Virtual Memory3 sections

Demand paging and page faults, page replacement algorithms, frame allocation and thrashing.

  • Demand Paging and Page Faults
  • Page Replacement Algorithms
  • Frame Allocation and Thrashing
09File Systems5 sections

File concepts, allocation methods, the Unix inode with a worked example, free-space management, links and permissions, journaling, caching and common file systems.

  • File Concepts
  • File Allocation Methods
  • The Unix Inode and Worked Example
  • Free-Space Management, Links, Permissions
  • Journaling, Caching and Common File Systems
10I/O Systems and Disk Management4 sections

I/O hardware and techniques, disk structure and access time, disk scheduling algorithms, disk management and RAID.

  • I/O Hardware and Techniques
  • Disk Structure and Access Time
  • Disk Scheduling Algorithms
  • Disk Management and RAID
Part 04Security & Real-World OSProtection, virtualization and Linux in practice
11Protection, Security and Virtualization2 sections

How operating systems protect resources and defend against attacks, plus virtualization and containers.

  • Protection and Security
  • Virtualization and Containers
12OS in Practice (Linux Toolkit)3 sections

Map everyday Linux commands to the OS concepts behind them, understand file descriptors, redirection and pipes, and follow a troubleshooting checklist.

  • Everyday Commands Mapped to OS Concepts
  • File Descriptors, Redirection and Pipes
  • Troubleshooting Checklist
Part 05Practice & RevisionSolve, drill and revise before the interview
13Popular Solved Problems1 sections

16 fully solved numerical problems covering the questions that appear most often in exams and interviews.

  • 16 numerical problems, solved step by step
14Interview Rapid-Fire2 sections

60 interview questions with crisp model answers, plus OS problems that show up in coding rounds.

  • 60 questions and answers
  • Coding-Round OS Problems
15Quick Revision3 sections

A formula sheet, algorithm comparison tables and a night-before checklist that condense the whole book.

  • Formula Sheet
  • Algorithm Comparison
  • Night-Before Checklist
Free samples

OS concepts you can compile and run

fork and exec in C, schedulers, semaphores, Banker's algorithm and page replacement in Python, and the shell commands for a slow server.

Create a child process with fork()

The classic process-creation pattern: fork a child, replace its image with exec, and have the parent wait so no zombie is left behind.

process.c
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int main(void) {
    pid_t pid = fork();

    if (pid < 0) {
        perror("fork");
        return 1;
    }

    if (pid == 0) {
        printf("Child  PID=%d\n", getpid());
        execlp("ls", "ls", "-l", NULL);
        perror("execlp");   /* only runs if exec fails */
        _exit(127);
    }

    int status;
    waitpid(pid, &status, 0);
    printf("Parent: child exited with %d\n",
           WEXITSTATUS(status));
    return 0;
}
Choose your book

The CS core set: Networks, OS and SQL

The three subjects asked in almost every campus and off-campus technical round. Start with this one, add the others when you need them.

Computer Networks

Computer Network

OSI and TCP/IP, subnetting, routing, TCP, DNS, HTTP and TLS, with solved numericals.

  • 12 chapters, physical to application
  • 25 solved numericals
  • Interview Q&A and port cheat-sheet
₹79₹19960% off
Details
This page
Operating Systems

Operating Systems

Processes, threads, scheduling, synchronization, deadlocks, memory and file systems.

  • Scheduling with Gantt charts
  • Paging, page replacement, deadlocks
  • Interview Q&A and numericals
₹79₹19960% off
SQL & Databases

SQL & Database Interview Handbook

From first SELECT to window functions, indexes, transactions and scaling databases.

  • Joins, CTEs, window functions
  • Indexes, transactions, isolation
  • Interview-style query problems
₹79₹19960% off
Details
Who it's for

Written for exams, interviews and production systems

  • Students

    Built around university and GATE-style syllabi. Concepts explained from zero with diagrams, worked numericals and revision tables.

    • Syllabus-aligned flow
    • Step-by-step numericals
    • Formula sheets
  • Placement prep

    OS is asked in almost every campus and off-campus technical round. Practise the exact questions, with answers short enough to say out loud.

    • 60 rapid-fire Q&A
    • Solved problems
    • Night-before checklist
  • Working professionals

    Understand what happens under your code. Debug CPU, memory and I/O issues in production with the Linux toolkit.

    • Linux toolkit
    • Containers and cgroups
    • Debugging mindset

What you get

  • 15 chapters, kernel to Linux

    Every concept explained with diagrams and tables.

  • 16 solved numerical problems

    Gantt charts, Banker's, page replacement, TLB, disk scheduling.

  • 60 interview questions

    Crisp model answers plus coding-round OS problems.

  • Quick revision kit

    Formula sheet, algorithm comparison, night-before checklist.

  • Linux toolkit

    ps, top, strace, lsof, vmstat, iostat, /proc and pipes.

  • GATE and semester ready

    Follows the standard university syllabus.

₹79₹19960% off
Questions

Before you buy

Anything else? Write to [email protected]

Who is this Operating System ebook for?

It is written for three groups: college students preparing for semester exams and GATE, candidates preparing for campus and off-campus placements, and working professionals who want to understand what happens beneath their code and debug production systems.

Do I need prior knowledge of operating systems?

No. The book starts with kernel and system-call fundamentals and builds step by step. Basic familiarity with programming is enough.

Does it include numerical problems?

Yes. A dedicated chapter of 16 solved numerical problems covers CPU scheduling Gantt charts, Banker's algorithm, page replacement, TLB and effective access time, disk scheduling and more, with every step shown.

Will it help in technical interviews?

Yes. The Interview Rapid-Fire chapter has 60 questions with concise model answers across all topics, and the Quick Revision chapter condenses the entire book into cheat sheets for the night before an interview.

Is Linux covered?

Yes. The OS in Practice chapter covers the Linux toolkit: ps, top, strace, lsof, vmstat, iostat, /proc, signals, permissions and a debugging workflow for high CPU, memory and I/O problems.

In what format will I receive the book?

It is a digital PDF ebook. After a successful payment you receive access through the same flow used for all Target Trek ebooks. For any payment or access issue, contact our support email.

Stop memorising definitions. Understand what the kernel does.

15 chapters, 16 solved problems and 60 interview questions, in one PDF you can read anywhere.

₹79₹19960% off
Resume Lab by Target Trek

Applying everywhere but getting no interview calls?

Your book gets you ready for the interview. A better resume gets you the call. See exactly which lines cost you shortlists, and how to fix each one.

~2 min
AI report
Real people
review it
Pay once
no subscription
Operating Systems: The Placement Handbook
₹79₹19960% off