Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Top 50 - Part 1
OS

Top 50 - Part 1

Practice core Operating Systems questions covering fundamental concepts, processes, scheduling, and frequently tested interview topics.

1. What is the difference between a Zombie Process and an Orphan Process?

  • Zombie — a process that has finished executing but still has an entry in the process table. It lingers because its parent hasn’t called wait() to read its exit status yet.
  • Orphan — a process that is still running but whose parent has terminated. The OS re-parents it to init/systemd (PID 1), which cleans it up when it finishes.
Zombie:
Parent ──wait()──> Child
                     X
                finished
                but entry
                remains

Orphan:
Parent ──X (dies)

Child ──────────────> PID 1
        still running
ZombieOrphan
StatusFinished, entry remainsStill running
ParentAlive but hasn’t wait()edDead
FixParent calls wait()Adopted by PID 1

A zombie doesn’t consume CPU — just a table entry. An orphan keeps running normally under its new parent.


2. What is the primary benefit of Direct Memory Access (DMA)?

DMA lets I/O devices (disk controllers, network cards) transfer data directly to/from main memory without the CPU copying every byte.

Without DMA:

I/O Device → CPU → RAM

        CPU handles data


With DMA:

I/O Device ─────────→ RAM
             DMA

        CPU only sets
        up the transfer

How it works:

  1. The CPU sets up the transfer (source, destination, length).
  2. The DMA controller moves the data.
  3. When done, it sends an interrupt — and the CPU resumes.

The benefit: during a large transfer, the CPU is free to do real work instead of babysitting the I/O. Without DMA, the CPU would have to move each byte, wasting enormous processing time on mechanical I/O.


3. What is the key architectural difference between Virtual Machines (VMs) and Containers?

The difference is what they virtualize.

  • VM — a hypervisor creates virtualized hardware, and each VM runs a complete guest OS on top of it. Heavy: each VM carries its own kernel, drivers, and libraries.
  • Container — shares the host OS kernel. It packages only the application and its dependencies, isolating the user space.
Virtual Machine:

+-------------+
|     App     |
+-------------+
|  Guest OS   |
+-------------+
|  Hypervisor |
+-------------+
|   Hardware  |
+-------------+


Container:

+-------------+
|     App     |
+-------------+
|  Container  |
+-------------+
| Host Kernel |
+-------------+
|   Hardware  |
+-------------+

Containers use far less memory and start in seconds. VMs give stronger isolation (separate kernels).


4. How do Type 1 and Type 2 Hypervisors differ?

  • Type 1 (bare-metal) — runs directly on the hardware, with no host OS underneath. High performance and security. Examples: VMware ESXi, Proxmox, Hyper-V.
  • Type 2 (hosted) — runs as a normal application on top of an existing OS. Easier to set up, but with the host OS in between there’s extra overhead. Examples: VirtualBox, VMware Workstation.
Type 1:

VM ──┐
VM ──┼──> Hypervisor ──> Hardware
VM ──┘


Type 2:

VM ──┐
VM ──┼──> Hypervisor ──> Host OS ──> Hardware
VM ──┘
Type 1Type 2
Runs onBare metalHost OS
PerformanceHighLower (extra layer)
Typical useData centersDesktops, testing

5. What is Belady’s Anomaly in operating systems?

Belady’s Anomaly is the counter-intuitive finding that adding more page frames can increase page faults under FIFO page replacement.

More frames

You expect:
Fewer page faults

But with FIFO:

More frames

MORE page faults

Example (classic): reference string 1,2,3,4,1,2,5,1,2,3,4,5.

  • With 3 frames, FIFO produces more faults than with 4 frames.

The reason: FIFO evicts the oldest page, which may be a page that would be needed very soon. More frames change which pages get evicted, and sometimes that’s worse.

Belady’s Anomaly doesn’t occur with LRU or Optimal — it’s specific to FIFO.


6. In access control security mechanisms, how do DAC, MAC, and RBAC differ?

  • DAC (Discretionary Access Control) — the resource owner decides who gets access. Flexible, but a user can accidentally (or maliciously) grant access to others.
  • MAC (Mandatory Access Control) — a central system policy decides, based on security clearances and data classifications. Users can’t override it — common in military/government systems.
  • RBAC (Role-Based Access Control) — permissions are tied to organizational roles, not individuals. A user gets the permissions of their role(s).
DAC:
Owner ──> decides ──> User access


MAC:
System Policy

      ├──> User
      └──> Resource


RBAC:
User ──> Role ──> Permissions
             └──> Resources
ModelWho decidesExample
DACResource ownerUnix file permissions
MACSystem policySELinux, military
RBACRolesEmployee → HR access

7. What is the primary operational difference between Symmetric and Asymmetric Encryption?

  • Symmetric encryption — one shared key both encrypts and decrypts. Fast (AES, DES). Problem: how do you securely share the key?
  • Asymmetric encryption — a public/private key pair. The public key encrypts, the private key decrypts. Slower, but solves key distribution (RSA, ECC).
Symmetric:

        Same Key
       ┌─────────┐
Data ──> Encrypt ──> Ciphertext


                  Decrypt


                      Data


Asymmetric:

Public Key                 Private Key
    │                           │
    ▼                           ▼
Encrypt ──> Ciphertext ──> Decrypt
SymmetricAsymmetric
KeysOne shared keyPublic + private
SpeedFastSlow
UseBulk dataKey exchange, signatures

Real systems use both: asymmetric to securely exchange the symmetric key, then symmetric for the actual data.


8. In high-availability clustering, what characterizes an Asymmetric Clustering setup?

In asymmetric clustering, only one node is active — running the applications. The other node is a passive standby that just monitors the active one and takes over if it fails.

             Heartbeat
        ┌─────────────────┐
        │                 │
        ▼                 ▼
+---------------+   +----------------+
| Active Node   |   | Passive Node   |
|               |   |    Standby     |
| Runs apps     |   | Monitors       |
+---------------+   +----------------+

        │ failure

   Standby takes over

If the active node fails, the standby detects it via heartbeat and takes over.

This contrasts with symmetric clustering, where all nodes run workloads simultaneously and share the load.


9. Which of the following best defines a Distributed Operating System?

A distributed OS manages a group of independent, networked computers and presents them to users as one unified system.

        Distributed OS

       ┌──────┼──────┐
       ▼      ▼      ▼
     Node 1  Node 2  Node 3
       │      │      │
       └──────┼──────┘

           Network

User sees:
      "One system"

Key characteristics:

  • Nodes are physically separate machines, possibly heterogeneous.
  • They’re connected by a network.
  • Resource scheduling, file access, and process management are coordinated as a single system.
  • The user doesn’t see “server A” and “server B” — they see one computer.

Under the hood, a cluster of machines works together seamlessly; from the outside, it behaves like a single powerful machine.


10. How is a Resource Allocation Graph (RAG) used to detect deadlocks?

A RAG has two kinds of nodes (processes and resources) and two kinds of edges:

  • Request edge — process → resource (process wants it).
  • Assignment edge — resource → process (resource is held by it).
Request:
Process ───────> Resource
        wants it

Assignment:
Process <─────── Resource
        holds it

Simple deadlock example:

P1 ──request──> R2
▲              │
│              │ assigned
│              ▼
R1 <────────── P2
     request

P1 → R2 → P2 → R1 → P1

       CYCLE

Detection rule:

  • If every resource type has one instance: a cycle in the graph = deadlock, guaranteed.
  • If resources have multiple instances: a cycle indicates a potential deadlock, but not definite — it must be analyzed further.

A cycle with multi-unit resources might be breakable, because a process in the cycle could be satisfied by an available instance without waiting forever.


11. What is the purpose of a Precedence Graph in concurrent processing?

A precedence graph is a directed acyclic graph (DAG) that shows which tasks must finish before others can start.

A ─────> B ─────> D
          \
           ─────> C

A must finish before B.
B must finish before C/D.
  • Nodes = tasks or statements.
  • Edge A → B = A must complete before B runs.

Why it matters: it encodes the dependencies between operations, so parallel execution doesn’t violate ordering. If two statements have no dependency path between them, they can run concurrently; if there’s an edge, they can’t.

It’s the tool for detecting race conditions at the design stage — before the code runs.


12. In computer architecture, what does Cycle Stealing refer to?

Cycle stealing is a DMA transfer mode. Instead of grabbing the bus for a long block transfer, the DMA controller requests the bus for one clock cycle at a time to move a byte or word.

CPU:  [work][work][work][work][work]

DMA:       [I/O]       [I/O]
             ↑           ↑
       steals 1 cycle at a time

Cycle stealing:

CPU → CPU → DMA → CPU → CPU → DMA → CPU
             ↑               ↑
          1 cycle          1 cycle

It “steals” individual CPU cycles for I/O rather than monopolizing the bus. The result: I/O happens in the background with minimal disruption to the CPU’s own work — at the cost of slower overall transfer than block mode.


13. How is Effective Access Time (EAT) calculated in memory management?

EAT is the average time to access data, mixing fast hits and slow misses:

                 ┌── Hit ──> Fast access
Access ──────────┤
                 └── Miss ─> Page fault ─> Disk ─> Slow access
EAT =
(Hit Ratio × Memory Access Time)
+
(Miss Ratio × Page Fault Overhead)
  • Hit ratio — how often the page is found in memory/cache.
  • Miss ratio = 1 − hit ratio — how often it’s not (causing a page fault + disk read).

Example: access time 100ns, page fault overhead 10,000,000ns, hit ratio 0.99:

EAT = 0.99 × 100 + 0.01 × 10,000,000
    ≈ 100,099 ns

The formula shows why even a 1% miss rate dominates — which is why systems push the hit ratio as close to 1 as possible.


14. Which of the following correctly describes the relationship between speed and capacity in the Memory Hierarchy?

Moving down the hierarchy (Registers → Cache → RAM → Storage):

        FASTEST


      Registers

         Cache

          RAM

      SSD / HDD


        SLOWEST

Capacity:
  Small ───────────────> Large

Cost per bit:
  High ────────────────> Low
  • Speed decreases
  • Capacity increases
  • Cost per bit decreases
LevelSpeedCapacityCost/bit
RegistersFastestTinyHighest
L1/L2/L3 cacheVery fastSmallHigh
RAMFastMediumMedium
SSD/HDDSlowMassiveLowest

The hierarchy exists to balance cost and performance: fast memory is small and expensive, so we keep only the hottest data there, and use big slow storage for everything else.


15. What happens during memory Swapping in an operating system?

Swapping moves entire processes between RAM and disk to manage memory pressure.

             RAM
      +----------------+
      |   Process A    |
      |   Process B    |
      |   Process C    |
      +----------------+

           Swap out

      +----------------+
      |  Disk / Swap   |
      |   Process C    |
      +----------------+

           Swap in

             RAM
  • Roll out — an inactive or blocked process is moved from RAM to a swap partition/file on disk.
  • Roll in — another process is brought from disk into the freed RAM.

Why it’s used: when RAM is limited, swapping lets more processes run than would physically fit. The freed memory goes to active processes, keeping the CPU busy.

The cost: moving whole processes to disk is slow. If the system swaps constantly, you get thrashing — the machine spends more time swapping than working.

Normal:
CPU → Work → Work → Work

Thrashing:
CPU → Swap → Swap → Swap → Swap

   Very little
   useful work

My Private Notes

Notes are auto-saved locally to this device.