Operating Systems

How the layer between your programs and the hardware decides who gets what, and when.

14 concepts 11 with a 3D simulation 52 interview questions

013D simulation

What is RAID?

Simple definition

RAID (Redundant Array of Independent Disks) combines several physical drives into one logical volume to gain speed, redundancy, or both. Different RAID levels trade capacity against protection.

Fig. 01 — RAID
RAID 0A1Disk 1A2Disk 2A3Disk 3Striping — speed, no safetyRAID 1B1Disk 1B1Disk 2B1Disk 3Mirroring — full copy on each diskRAID 5C1Disk 1C2Disk 2CpDisk 3Striping + distributed parity

Swipe sideways to see the whole diagram →

Step by step

  1. RAID 0 — striping

    Data is split across all disks, so reads and writes run in parallel. Fastest, but one disk failure loses everything.

  2. RAID 1 — mirroring

    Every disk holds an identical copy. You lose half your capacity but survive a disk failure with no data loss.

  3. RAID 5 — striping with parity

    Data plus a parity block are spread across at least three disks. Any one disk can fail and its contents are rebuilt from the rest.

  4. RAID 6 — double parity

    Two parity blocks, so two disks can fail simultaneously. Important with large drives where a rebuild takes many hours.

  5. RAID 10 — mirrored stripes

    Mirrored pairs that are then striped. Excellent speed and resilience, at the cost of half the raw capacity.

  6. Rebuild

    After replacing a failed disk, the array reconstructs the missing data. Performance drops during this window and a second failure here is the real danger.

Real-world example

A small business server runs RAID 5 across four drives. A drive fails on a Tuesday; staff keep working while a hot spare rebuilds in the background. Nobody loses a file — but the nightly backup still runs, because RAID is not a backup.

Where people get this wrong

The single most expensive misunderstanding in storage: RAID is not a backup. A deleted file is deleted on every disk instantly, and ransomware encrypts a mirrored array just as quickly as a single drive.

Common interview questions

Is RAID a backup?

No. It protects against hardware failure only. Deleted files, ransomware and corruption are replicated instantly across the array.

How much usable capacity does RAID 5 give?

The total minus one disk. Four 1 TB drives give 3 TB usable.

Why is RAID 5 discouraged with very large drives?

Rebuild times run into many hours, and the heavy read load raises the chance of a second failure before the rebuild finishes. RAID 6 or 10 is safer.

What is the difference between hardware and software RAID?

Hardware RAID uses a dedicated controller with its own cache. Software RAID is handled by the operating system — cheaper and more portable, but it uses host CPU.

Inside the Druvexaa simulation

The lab lets you pull a disk out of a running array and watch the rebuild start, along with the performance drop while it runs — the window in which a second failure becomes genuinely dangerous.

Related concepts


023D simulation

How does an OS allocate memory?

Simple definition

Memory allocation is how the operating system decides which free region of RAM to give a process. The strategy chosen affects both speed and how much memory is wasted as unusable gaps.

Fig. 02 — An OS allocate memory
01Process requests 6MBNeeds a free block02Scan free listFind candidate holes03Apply strategyFirst / Best / Worstfit04Allocate and splitRemainder stays free

Swipe sideways to see the whole diagram →

Step by step

  1. First fit

    Take the first hole large enough. Fast, because the search usually ends early.

  2. Best fit

    Search all holes and take the smallest one that fits. Wastes the least space per allocation but leaves many tiny unusable gaps.

  3. Worst fit

    Take the largest hole, on the theory that the leftover piece will still be useful. In practice it performs poorly.

  4. External fragmentation

    Free memory exists but is scattered in small pieces, so a large request fails even though the total free space is sufficient.

  5. Internal fragmentation

    A process is given a slightly larger fixed block than it asked for, and the unused remainder inside that block is wasted.

  6. Paging solves it

    Splitting memory into fixed-size pages removes external fragmentation entirely, which is why every modern OS uses paging with virtual memory.

Real-world example

Ask any system to allocate a large contiguous buffer after hours of uptime and it may fail even with plenty of free RAM. The free space is there, just broken into pieces too small to use — classic external fragmentation.

Where people get this wrong

Fragmentation is treated as a rounding error. It is why a system with gigabytes free can still refuse a large allocation. The total number tells you almost nothing; the shape of the free space tells you everything.

Common interview questions

Which is faster, first fit or best fit?

First fit, because it stops at the first suitable hole instead of scanning the entire free list.

What is the difference between internal and external fragmentation?

Internal is wasted space inside an allocated block. External is free space between blocks that is too fragmented to use.

What is compaction?

Relocating allocated blocks so free space becomes contiguous. It works but is expensive, since processes must be paused and pointers updated.

How does paging eliminate external fragmentation?

Every frame is the same fixed size, so any free frame can satisfy any page request. There are no awkwardly shaped gaps.

Inside the Druvexaa simulation

Allocate and free blocks in any order in the simulation and watch the memory map fill with gaps, then try a large request and watch it fail while the free total still looks healthy.

Related concepts


033D simulation

What is Process Scheduling?

Simple definition

Process scheduling is how the operating system decides which ready process gets the CPU next. Since a core can run only one process at a time, the scheduler creates the illusion that everything runs at once.

Fig. 03 — Process Scheduling
01NewProcess created02ReadyWaiting in thequeue03RunningHolds the CPU04WaitingBlocked on I/O05TerminatedFinished

Swipe sideways to see the whole diagram →

Step by step

  1. FCFS

    First Come First Served runs processes in arrival order. Simple, but one long job delays everything behind it — the convoy effect.

  2. SJF

    Shortest Job First gives the best average waiting time, but it requires knowing burst lengths in advance and can starve long jobs.

  3. Round Robin

    Each process gets a fixed time slice, then goes to the back of the queue. This is what makes interactive systems feel responsive.

  4. Priority scheduling

    Higher-priority processes run first. Ageing gradually raises the priority of waiting processes to prevent starvation.

  5. Preemptive vs non-preemptive

    A preemptive scheduler can take the CPU away mid-execution. A non-preemptive one waits for the process to yield.

  6. Multilevel queues

    Real systems use several queues with different policies — interactive tasks get quick slices, background jobs get longer ones.

Real-world example

You drag a window while a video encodes in the background. Round-robin style scheduling with priority boosting hands the CPU to the interface repeatedly, so the drag stays smooth even though the encoder wants every cycle it can get.

Where people get this wrong

Scheduling is taught as an algorithm comparison exercise. Real systems use several at once, in layers, and the interesting question is not which algorithm is best but which one should apply to which kind of work.

Common interview questions

What is the difference between preemptive and non-preemptive scheduling?

Preemptive scheduling can interrupt a running process; non-preemptive waits until it blocks or finishes. Preemption is what makes a system responsive.

What is the convoy effect?

Short processes stuck waiting behind one long process under FCFS, which badly inflates average waiting time.

How is the time quantum chosen in Round Robin?

Too large and it degrades into FCFS; too small and context-switch overhead dominates. It is tuned to sit comfortably above the switch cost.

What is starvation, and how is it fixed?

A low-priority process never getting CPU time. Ageing fixes it by increasing priority the longer a process waits.

Inside the Druvexaa simulation

The simulation runs the same set of processes under FCFS, SJF and Round Robin, then shows the resulting Gantt charts side by side with average waiting times calculated for each.

Related concepts


043D simulation

What is Context Switching?

Simple definition

A context switch is the act of saving one process's CPU state and loading another's, so the CPU can move between processes. It is the mechanism that makes multitasking possible on a single core.

Fig. 04 — Context Switching
01Process A runningUses CPU registers02Interrupt orquantum endsScheduler steps in03Save A's state toPCBRegisters, PC, stackpointer04Load B's stateRestore from B's PCB

Swipe sideways to see the whole diagram →

Step by step

  1. A trigger occurs

    A timer interrupt fires, the process blocks on I/O, or a higher-priority process becomes ready.

  2. Save the context

    The CPU registers, program counter, stack pointer and memory mapping details are written into the Process Control Block.

  3. Update the process state

    The outgoing process moves from Running to Ready or Waiting.

  4. Pick the next process

    The scheduler selects the next process from the ready queue.

  5. Restore its context

    That process's saved registers and program counter are loaded back into the CPU.

  6. Resume

    Execution continues from exactly where it left off. The process is unaware it was ever paused.

Real-world example

A modern desktop performs thousands of context switches per second. Each one costs a few microseconds of pure overhead — no useful work happens during a switch, which is why excessive switching hurts throughput.

Where people get this wrong

Switching is assumed to be free because it is fast. It is fast and it is pure waste — no user work happens during it, and the incoming process starts with a cold cache, which costs more than the switch itself.

Common interview questions

What is stored in a Process Control Block?

Process ID, state, program counter, CPU registers, memory management information, open file list and accounting data.

Why is context switching considered pure overhead?

No user work is done during the switch, and the CPU cache and TLB are often left cold for the incoming process.

Is switching between threads cheaper than between processes?

Yes. Threads in one process share an address space, so the memory mapping does not have to be swapped out.

What triggers a context switch?

Timer interrupts, I/O requests, system calls, higher-priority processes arriving, or a process terminating.

Inside the Druvexaa simulation

The simulation shows the CPU registers being written into one process control block and read out of another, with a counter tracking how much time was spent switching rather than computing.

Related concepts


053D simulation

What is the Critical Section Problem?

Simple definition

A critical section is the part of a program that accesses shared data. If two processes execute their critical sections at the same time, the shared data can be corrupted — this is a race condition.

Fig. 05 — Critical Section Problem
01Entry sectionRequest the lock02Critical sectionOnly one processinside03Exit sectionRelease the lock04Remainder sectionOrdinary work

Swipe sideways to see the whole diagram →

Step by step

  1. Identify shared data

    Any variable, file or device touched by more than one process or thread is a candidate.

  2. Mutual exclusion

    At most one process may be inside the critical section at any moment.

  3. Progress

    If nobody is inside, a waiting process must eventually be allowed in. The decision cannot be postponed indefinitely.

  4. Bounded waiting

    There must be a limit on how many times others can enter before a waiting process gets its turn — this prevents starvation.

  5. Enforce with a lock

    A mutex allows exactly one holder. A semaphore is a counter that allows up to n holders, useful for a pool of resources.

  6. Avoid new problems

    Careless locking creates deadlock, where each process holds what another needs, and priority inversion, where a low-priority holder blocks a high-priority waiter.

Real-world example

Two threads increment the same counter from 100. Without a lock, both may read 100, both write 101, and one increment silently disappears. With a mutex, the result is reliably 102 every time.

Where people get this wrong

Race conditions are assumed to be rare because the timing window is small. Small windows are hit constantly at machine speed, and the resulting bugs are intermittent, unreproducible, and among the hardest to find in software.

Common interview questions

What are the three requirements of a critical section solution?

Mutual exclusion, progress and bounded waiting.

What is the difference between a mutex and a semaphore?

A mutex is a lock with an owner, allowing one holder. A counting semaphore permits up to n concurrent holders and has no ownership.

What is a race condition?

When the result depends on the unpredictable order in which processes access shared data.

What are the four conditions for deadlock?

Mutual exclusion, hold and wait, no preemption, and circular wait. Breaking any one of them prevents deadlock.

Inside the Druvexaa simulation

Run two processes without a lock in the simulation and watch the shared counter produce a wrong result, then add a mutex and run the identical scenario again.

Related concepts


063D simulation

What happens when you power on a computer?

Simple definition

Booting is the sequence that takes a machine from powered-off silence to a usable desktop. Firmware tests the hardware, finds a bootable device, and hands control to the operating system kernel.

Fig. 06 — When you power on a computer
01Power onVoltagesstabilise02POSTFirmware testshardware03BootloaderGRUB or Windowsloader04Kernel loadsDriversinitialise05Login readyServices started

Swipe sideways to see the whole diagram →

Step by step

  1. Power good signal

    The power supply stabilises and signals the motherboard that voltages are within tolerance.

  2. POST

    Firmware runs the Power-On Self Test, checking CPU, RAM and essential devices. Failures are reported by beep codes or LEDs.

  3. Firmware initialises

    UEFI (or legacy BIOS) sets up hardware and reads the configured boot order.

  4. Find the boot device

    UEFI reads the EFI System Partition; legacy BIOS reads the Master Boot Record in the first sector of the disk.

  5. Bootloader runs

    GRUB, systemd-boot or the Windows Boot Manager presents any choices and loads the selected kernel into memory.

  6. Kernel takes over

    It initialises memory management, mounts the root filesystem and loads drivers.

  7. Init starts services

    systemd or an equivalent brings up services and the display manager, and you get a login screen.

Real-world example

A machine that beeps and shows nothing on screen usually failed POST — often a reseating problem with the RAM. A machine that reaches the bootloader but hangs afterwards points at the operating system, not the hardware. The boot sequence tells you where to look.

Where people get this wrong

Booting is treated as one opaque event. It is a chain, and knowing where it stopped tells you what to fix — a POST failure is hardware, a bootloader failure is configuration, and a hang after the kernel loads is the operating system.

Common interview questions

What is the difference between BIOS and UEFI?

UEFI is the modern replacement: it supports drives over 2 TB with GPT, boots faster, has a graphical interface, and supports Secure Boot.

What is POST?

Power-On Self Test — the firmware's hardware check before any operating system code runs.

What does the bootloader do?

Locates the kernel, loads it into memory with the right parameters, and transfers control. It also lets you choose between installed systems.

What is the difference between MBR and GPT?

MBR is the legacy partition scheme, limited to 2 TB and four primary partitions. GPT supports far larger disks, many partitions, and stores redundant headers.

Inside the Druvexaa simulation

The simulation walks the sequence stage by stage and lets you break any stage deliberately, so you can learn to read the symptom and name the stage that failed.

Related concepts


073D simulation

What is Deadlock?

Simple definition

Deadlock is a state where a set of processes are all waiting for resources held by each other, so none of them can ever proceed. Nothing crashes — the system simply stops making progress.

Fig. 07 — Deadlock
Process AProcess BPrinterScannerholdsholdsEach waits for what the other holds — neither will ever release

Swipe sideways to see the whole diagram →

Step by step

  1. Mutual exclusion

    At least one resource can be held by only one process at a time. Without this, there is nothing to fight over.

  2. Hold and wait

    A process holds one resource while requesting another, instead of asking for everything at once.

  3. No preemption

    A resource cannot be forcibly taken from the process holding it — it must be released voluntarily.

  4. Circular wait

    A closed chain exists where each process waits for a resource held by the next.

  5. All four together

    Deadlock requires every one of these conditions simultaneously. Break any single one and it becomes impossible.

  6. Prevention, avoidance, detection

    Prevention removes a condition by design. Avoidance uses algorithms like Banker's to refuse unsafe allocations. Detection lets it happen and then kills or rolls back a process.

Real-world example

Two bank transfers run at once. One locks account A then reaches for B; the other locks B then reaches for A. Both wait forever. Forcing every transfer to lock accounts in numerical order removes the circular wait and the bug disappears.

Where people get this wrong

Deadlock is assumed to be a crash, so people look for an error message. A deadlocked system looks alive — threads exist, memory is allocated, nothing is logged. It is diagnosed by noticing that work stopped completing, not by an exception, which is why it survives testing and appears in production.

Common interview questions

What are the four Coffman conditions?

Mutual exclusion, hold and wait, no preemption, and circular wait. All four must hold at once for deadlock to occur.

What is the difference between deadlock and starvation?

Deadlock means no process in the set can ever proceed. Starvation means a process could proceed but keeps being passed over indefinitely.

How does lock ordering prevent deadlock?

If every process acquires locks in the same global order, a circular wait cannot form, which removes one of the four required conditions.

What does the Banker's algorithm do?

It checks whether granting a resource request would leave the system in a safe state, and refuses the request if it would not.

Inside the Druvexaa simulation

The synchronisation simulation lets you assign resources in an order that creates a circular wait and watch both processes freeze, then re-run it with an enforced lock ordering so the same workload completes cleanly.

Related concepts


083D simulation

What is Virtual Memory and Paging?

Simple definition

Virtual memory gives every process its own private address space that is larger than the physical RAM installed. The operating system and hardware translate those virtual addresses to real ones, moving rarely used pages out to disk when memory runs short.

Fig. 08 — Virtual Memory and Paging
Process virtual pagesPage 0Page 1Page 2Page table+ MMU and TLBPhysical RAMFrame 7Frame 2On diskPage 2 is not in RAM — touching it triggers a page faultPages are a fixed size, so any free frame fits any page

Swipe sideways to see the whole diagram →

Step by step

  1. Split everything into pages

    Virtual memory is divided into fixed-size pages, and physical memory into frames of the same size, typically 4 KB.

  2. Keep a page table

    Each process has a table mapping its pages to physical frames, or marking them as not present.

  3. Translate in hardware

    The Memory Management Unit performs the lookup on every access. A small cache called the TLB holds recent translations so this stays fast.

  4. Demand paging

    Pages are loaded only when first touched. A program can start before most of it is in memory.

  5. Page fault

    Accessing a page that is not resident traps to the operating system, which fetches it from disk, updates the table and resumes the instruction.

  6. Replacement and thrashing

    When RAM is full, an algorithm such as LRU chooses a victim page to evict. If the working set exceeds RAM, the system spends more time paging than computing — that is thrashing.

Real-world example

A machine with 8 GB of RAM runs applications whose combined address space is far larger. It works because at any moment each program is actively touching only a small fraction of its pages, and the rest sit on disk unnoticed.

Where people get this wrong

Virtual memory is often described as simply using disk as extra RAM. Swapping is the emergency behaviour, not the purpose. The real purposes are isolation — one process cannot see another's memory — and the removal of external fragmentation, both of which apply even on a machine that never swaps a single page.

Common interview questions

What is a page fault?

A trap raised when a process accesses a page that is not currently in physical memory, prompting the OS to load it and retry the access.

What does the TLB do?

It caches recent virtual-to-physical translations so the MMU can avoid walking the page table on every memory access.

What is thrashing?

A state where the active working set exceeds physical memory, so the system spends most of its time swapping pages instead of executing instructions.

How does paging eliminate external fragmentation?

Every frame is identical in size, so any free frame satisfies any page request and no unusable gaps form between allocations.

Inside the Druvexaa simulation

The memory simulation shows the page table alongside physical frames, so you can touch a page that is not resident, watch the page fault trap, see the fetch from disk and see the table entry update before the instruction resumes.

Related concepts


093D simulation

What is Multithreading?

Simple definition

Multithreading lets one process run several independent sequences of execution at the same time. Threads share the process's memory, which makes communication between them fast and mistakes between them dangerous.

Fig. 09 — Multithreading
One process — one shared address spaceThread 1 — UIThread 2 — uploadThread 3 — saveOwn stack and registers each — shared heap, files and globalsSharing is what makes threads fast, and what makes them need locks

Swipe sideways to see the whole diagram →

Step by step

  1. What a thread owns

    Its own program counter, registers and stack. That is the entire private state of a thread.

  2. What a thread shares

    The heap, global variables, open files and code — everything else belongs to the process and is visible to every thread in it.

  3. Concurrency versus parallelism

    Concurrency is several tasks in progress at once. Parallelism is several genuinely executing at the same instant, which needs multiple cores.

  4. Cheaper switching

    Switching between threads of one process does not change the memory map, so it costs noticeably less than a full process switch.

  5. Shared state needs protection

    Because the heap is shared, two threads writing the same variable will corrupt it unless a lock enforces order.

  6. Thread pools

    Creating a thread per task does not scale. Real systems keep a fixed pool of threads and hand them work from a queue.

Real-world example

A file upload runs on a background thread while the interface stays responsive on the main thread. Both live in the same process and share the same progress variable — which is exactly why that variable needs a lock.

Where people get this wrong

Adding threads is treated as a way to make code faster. On a single core, threads that are all CPU-bound make things slower, because the switching overhead is added to the same total work. Threads help when tasks spend time waiting — on disk, network or user input — which is a completely different situation from needing more computation.

Common interview questions

What is the difference between a process and a thread?

A process has its own address space. Threads live inside a process and share that address space, keeping only their stack and registers private.

Why is thread switching cheaper than process switching?

The memory mapping does not change, so the page tables and much of the cache remain valid for the incoming thread.

What is a race condition in a multithreaded program?

Two threads accessing shared data concurrently where the result depends on which one happens to run first.

Why use a thread pool instead of creating threads on demand?

Thread creation is expensive and unbounded creation exhausts memory. A pool caps concurrency and reuses threads across many tasks.

Inside the Druvexaa simulation

The context switching simulation lets you compare switching between threads of one process against switching between separate processes, with the saved and restored state shown in each case so the cost difference is visible rather than asserted.

Related concepts


103D simulation

What is the difference between a Semaphore and a Mutex?

Simple definition

A mutex is a lock with an owner — whoever locked it must be the one to unlock it, and only one holder is allowed. A semaphore is a counter that permits up to a set number of holders and has no concept of ownership.

Fig. 10 — Difference between a Semaphore and a Mutex
MutexOne holder at a timeHas an ownerOnly the owner unlocksProtects a critical sectionLock and unlockUsed for exclusive accessSemaphoreUp to n holdersNo ownerAny thread can signalManages a resource poolWait and signalUsed for counting and signalling

Swipe sideways to see the whole diagram →

Step by step

  1. A mutex enforces exclusivity

    One thread locks it, does its work in the critical section, and unlocks it. Everyone else waits.

  2. Ownership matters

    Because the mutex knows its owner, the runtime can detect a thread trying to unlock a mutex it never locked.

  3. A semaphore counts permits

    Initialised to n, it allows n threads through. Each wait decrements the count; each signal increments it.

  4. A binary semaphore is not a mutex

    It also allows one holder, but any thread may signal it. That difference is what makes it useful for signalling between threads.

  5. Producer and consumer

    The classic use: one semaphore counts filled slots, another counts empty slots, and a mutex protects the buffer itself.

  6. Choose by intent

    Protecting shared data means a mutex. Limiting concurrent access to a pool, or waking one thread from another, means a semaphore.

Real-world example

A download manager allows three simultaneous connections. A semaphore initialised to 3 enforces that limit. The shared list of completed downloads is separately protected by a mutex — two different problems, two different tools.

Where people get this wrong

A binary semaphore is treated as interchangeable with a mutex because both allow one holder. The difference is ownership, and it matters: a thread can signal a semaphore it never waited on, which is a feature when signalling between threads and a serious bug when you meant to protect data. Choosing the wrong one produces code that works in testing and fails unpredictably in production.

Common interview questions

Can a semaphore be released by a thread that did not acquire it?

Yes, and that is the defining difference from a mutex. It is what allows a semaphore to signal between threads.

When would you use a counting semaphore?

To limit concurrent access to a pool of identical resources — database connections, download slots, worker permits.

What is priority inversion?

A low-priority thread holding a lock blocks a high-priority thread. Priority inheritance temporarily raises the holder's priority to resolve it.

What are the two semaphore operations called?

Wait and signal, historically P and V. Wait decrements and blocks at zero; signal increments and may wake a waiter.

Inside the Druvexaa simulation

The synchronisation simulation runs the same producer-consumer workload three ways — with no protection, with a mutex only, and with the correct semaphore plus mutex combination — so you can watch the buffer corrupt, then stall, then run correctly.

Related concepts


113D simulation

What is an Operating System?

Simple definition

An operating system is the layer between hardware and applications. It manages the processor, memory, storage and devices, and gives every program a consistent interface so it does not need to know what hardware it is running on.

Fig. 11 — An Operating System
1ApplicationsBrowser, editor, games2System call interfaceThe boundary programs talk through3KernelScheduler, memory, file system, drivers4HardwareCPU, RAM, disk, network card

Swipe sideways to see the whole diagram →

Step by step

  1. Process management

    It creates processes, schedules them onto cores, and cleans up when they end.

  2. Memory management

    It allocates memory, maps virtual addresses to physical ones, and keeps processes from reading each other's data.

  3. File system

    It turns raw blocks on a disk into named files and directories with permissions.

  4. Device management

    Drivers hide the differences between hardware, so a program writes to a file the same way regardless of the drive underneath.

  5. Protection

    It enforces the boundary between programs and between users, which is the reason one crashing application does not take the machine with it.

Real-world example

A text editor saving a file never touches the disk directly. It makes a system call, and the operating system handles permissions, buffering, the file system layout and the driver — which is why the same editor works on an SSD, a hard disk or a network share.

Where people get this wrong

The operating system is thought of as the desktop you see. The visible interface is an application. The real operating system is the kernel underneath, which is why a server with no screen at all is still running a full one.

Common interview questions

What are the main functions of an operating system?

Process management, memory management, file system management, device management, and protection between users and programs.

What is the kernel?

The core of the operating system that runs in privileged mode and directly controls hardware, memory and scheduling.

Why do applications not access hardware directly?

Protection and portability. Going through the OS prevents programs interfering with each other and lets the same program run on different hardware.

Inside the Druvexaa simulation

The CPU, RAM and OS simulation follows a program from storage into memory and onto the processor, showing where the operating system steps in at each stage rather than leaving it as an invisible middle layer.

Related concepts



More operating systems concepts

These topics are written to the same depth. A dedicated Druvexaa simulation is planned for each — until then, every one links to the closest existing simulation and quiz.

12Simulation planned

What is the difference between Kernel Mode and User Mode?

Simple definition

The processor runs in two privilege levels. Kernel mode can execute any instruction and touch any memory; user mode cannot. This single hardware boundary is what keeps one badly written program from destroying the whole system.

Fig. 12 — Difference between Kernel Mode and User Mode
User mode — applicationsRestricted: no direct hardware, no other process’s memorySystem call — the only legal way acrossKernel mode — the operating systemFull access to every instruction, all memory and all devices

Swipe sideways to see the whole diagram →

Step by step

  1. Two privilege levels in hardware

    The CPU itself enforces this. On x86 they are called ring 0 and ring 3, and the distinction is not something software can bypass.

  2. User mode is deliberately limited

    Applications cannot execute privileged instructions, address hardware, or read memory belonging to another process.

  3. System calls cross the boundary

    When a program needs something privileged it makes a system call, which traps into the kernel at a controlled entry point.

  4. The kernel validates everything

    It checks permissions and arguments before acting, then returns to user mode with the result.

  5. Why crashes stay contained

    A fault in user mode kills one process. A fault in kernel mode has nothing above it to catch the error, which is why it takes down the whole machine.

Real-world example

A blue screen or kernel panic is a failure in kernel mode. An application that simply closes with an error was a user mode fault — the operating system caught it, cleaned up, and kept running.

Where people get this wrong

Running as administrator is confused with running in kernel mode. Administrator is a permissions setting inside user mode; the CPU privilege level is unchanged. This is why a program with full admin rights still cannot corrupt the kernel directly, and why a driver — which does run in kernel mode — is far more dangerous than any ordinary application.

Common interview questions

Why do we need two processor modes?

To enforce isolation in hardware. Without it, any program could touch any memory or device and no protection would be possible.

What happens during a system call?

The CPU traps into kernel mode at a defined entry point, the kernel validates and performs the request, then returns control and the result to user mode.

Why is a kernel crash fatal but an application crash is not?

Nothing sits above the kernel to catch its fault or clean up after it, whereas the kernel can terminate a faulty process and continue.

Inside the Druvexaa simulation

No dedicated simulation yet. The context switching simulation shows the moment control transfers to the operating system, which is the same mechanism a system call uses to cross this boundary.

Related concepts


13Simulation planned

What are System Calls?

Simple definition

A system call is the controlled request an application makes when it needs the operating system to do something it is not allowed to do itself — open a file, send data on the network, or create a process.

Fig. 13 — System Calls
01Program callsread()Ordinary functioncall02Library preparesthe trapArguments intoregisters03CPU switches tokernelPrivilege levelchanges04Kernel does theworkValidates, reads,returns

Swipe sideways to see the whole diagram →

Step by step

  1. The program asks

    Application code calls a normal-looking library function such as read or open.

  2. The library sets it up

    Arguments and a call number are placed in registers, then a special instruction triggers the trap.

  3. Privilege changes

    The CPU switches to kernel mode and jumps to a fixed handler. The application cannot choose where it lands.

  4. Validation and execution

    The kernel checks permissions and argument validity, performs the operation, and prepares a return value.

  5. Return to user mode

    Control returns to the program with the result or an error code. The switch in both directions costs time, which is why heavy system call use is slow.

  6. Common categories

    Process control, file operations, device management, information, and communication between processes.

Real-world example

Reading a file one byte at a time performs one system call per byte and crawls. Reading in 64 KB blocks does the same total work with a fraction of the crossings — which is exactly why buffered I/O exists in every language's standard library.

Where people get this wrong

Library functions and system calls are treated as the same thing. Most library calls never reach the kernel at all — they work from a buffer in user space. Confusing the two leads people to blame the operating system for performance problems that are actually in their own buffering strategy.

Common interview questions

Why are system calls expensive?

Each one changes privilege level, saves and restores state, and disturbs the cache — overhead that dwarfs the work of a small operation.

Name the main categories of system calls.

Process control, file management, device management, information maintenance, and inter-process communication.

What is the difference between a system call and a library function?

A library function is ordinary user-space code. It only becomes a system call when it needs the kernel to do something privileged.

Inside the Druvexaa simulation

No dedicated simulation yet. The context switching simulation shows the state save and restore that a system call performs when it crosses into the kernel and back.

Related concepts


14Simulation planned

What is a File System?

Simple definition

A file system is the structure that turns a flat array of storage blocks into named files and folders. It tracks where each file's data lives, who may access it, and how free space is managed.

Fig. 14 — File System
/home/notes.txtDirectory entryname → inode numberInode / MFT recordsize, owner, block listBlock 91Block 92Block 407Blocks need not be adjacent — that scattering is fragmentation

Swipe sideways to see the whole diagram →

Step by step

  1. Names map to records

    A directory is itself a file, holding a list of names and the record number each one points to.

  2. The record holds the metadata

    An inode on Linux or an MFT record on Windows stores size, owner, permissions, timestamps and the list of data blocks.

  3. Data lives in blocks

    Files occupy whole blocks, typically 4 KB. A 1 KB file still consumes a full block, and the remainder is slack space.

  4. Free space tracking

    The file system maintains a map of which blocks are in use so it can allocate new ones quickly.

  5. Journaling

    Before making a change, the file system records its intent. After a power loss it replays or discards the journal instead of scanning the entire disk.

  6. Different designs

    NTFS on Windows, ext4 and XFS on Linux, APFS on macOS, exFAT for cross-platform removable drives.

Real-world example

Deleting a large file is instant because only the directory entry and the free-space map are updated. The data blocks are untouched, which is exactly why recovery tools can often bring the file back.

Where people get this wrong

Formatting is believed to erase data. A quick format rewrites the file system structures and leaves nearly every data block intact. Selling or discarding a drive after a quick format is one of the most common ways personal data leaks — secure erasure has to overwrite the blocks themselves.

Common interview questions

What is an inode?

A structure holding a file's metadata and the location of its data blocks. The file name lives in the directory, not in the inode.

What is journaling and why does it matter?

The file system logs its intended changes before making them, so an interrupted write can be replayed or rolled back rather than leaving corruption.

Why does a small file still consume a full block?

Allocation happens in whole blocks. The unused remainder is internal fragmentation, or slack space.

Inside the Druvexaa simulation

No dedicated simulation yet. The RAID lab shows the storage layer beneath the file system, including how blocks are distributed across disks and reconstructed after a failure.

Related concepts



Continue to another subject

Everything in the Knowledge Hub is cross-linked, so a concept in one subject always points to the related ones elsewhere.

← Back to the top level Druvexaa Knowledge Hub All 79 concepts across five subjects, in one place.