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 3
OS

Top 50 - Part 3

Practice advanced Operating Systems questions covering memory management, virtual memory, file systems, and analytical concepts.

1. Which of the following correctly pairs a File Allocation Method with its main disadvantage?

Contiguous Allocation → external fragmentation.

Contiguous allocation stores each file in consecutive disk blocks. As files are created and deleted, free space can become divided into small, scattered holes.

Disk:

[File A][Free][File B][Free][Free][File C][Free]



New large file needs:
[      LARGE CONTIGUOUS SPACE      ]

But free space is scattered → external fragmentation

For the other options:

  • Linked allocation — its main disadvantage is poor random access, because blocks must be followed through the pointer chain.
  • Indexed allocation — supports direct/random access, but requires extra space for index blocks.
  • FAT — uses a file allocation table to maintain block chains and supports access to file blocks through the table.

2. What is the primary limitation of a Single-Level Directory Structure?

In a single-level directory, all files share one flat namespace. Therefore, every filename must be unique within the entire directory.

Single-Level Directory

          Root

     ┌─────┼─────┐
     ▼     ▼     ▼
 report.txt  data.txt  photo.jpg

All files are in ONE directory.

With multiple users or a growing system:

  • User A creates report.txt.
  • User B cannot create another report.txt.
  • Naming collisions become common.
  • There is no proper way to organize related files into separate directories.

The solution: hierarchical directories.

Root
├── Alice
│   └── report.txt
└── Bob
    └── report.txt

Same filename is now possible
because the files are in different directories.

3. How does an Access Control Matrix (ACM) define system security?

An Access Control Matrix is a conceptual table where:

  • Rows = subjects (users or processes)
  • Columns = objects (files, devices, programs)
  • Cells = operations a subject can perform on an object
             file1    file2    printer
           ┌────────┬────────┬─────────┐
Alice      │  r/w   │   r    │    -    │
Bob        │   -    │  r/w   │  print  │
Carol      │   r    │  r/w   │  print  │
           └────────┴────────┴─────────┘

For example:

Bob can read/write file2 and use the printer.

Why it matters: the matrix provides a conceptual model for access control.

In practice, the complete matrix is rarely stored because it can be very large and sparse. It is commonly represented using:

  • Access Control Lists (ACLs) — permissions organized by object.
  • Capability Lists — permissions organized by subject.

4. Which File Protection Method is most commonly used in Unix-like systems to control file access?

Unix-like systems traditionally use permission bits organized into three categories:

  • Owner
  • Group
  • Others

Each category can have:

  • r = Read
  • w = Write
  • x = Execute
-rwxr-xr-- 
 │  │  │
 │  │  └── Others: r--
 │  └───── Group:  r-x
 └──────── Owner:  rwx

Example:

-rw-r--r--  alice staff  report.txt

This means:

Owner  → rw-  → read + write
Group  → r--  → read only
Others → r--  → read only

Permissions can also be represented using octal notation:

chmod 755 file

755 means:

Owner  → 7 → rwx
Group  → 5 → r-x
Others → 5 → r-x

5. What physical component of a Hard Disk Drive (HDD) contains a set of tracks that are aligned vertically above each other across all platters?

A cylinder.

        Same track position


Platter 1 ─── (Track 3)
Platter 2 ─── (Track 3)   ← Cylinder
Platter 3 ─── (Track 3)

A cylinder consists of tracks having the same radius/position on different platter surfaces.

When the heads are positioned at that radius, the corresponding tracks across the platters form a cylinder.

Why it’s useful: accessing tracks within the same cylinder historically reduced the need for head movement.


6. What occurs during Low-Level Disk Formatting (Physical Formatting)?

Low-level formatting divides the disk surface into sectors and establishes the physical structure needed by the disk controller.

Conceptually, a sector contains:

┌────────┬───────────────┬────────────┐
│ Header │  Data Area    │ ECC/Other  │
└────────┴───────────────┴────────────┘

The physical layout contains information used to identify sectors and detect/correct errors.

Important distinction:

Low-level formatting

Physical sector structure

Partitioning

Logical partitions

High-level formatting

File system (NTFS, ext4, etc.)

Modern HDDs are normally low-level formatted by the manufacturer. Users generally perform partitioning and file-system formatting rather than true low-level formatting.


7. How does the SCAN (Elevator) disk scheduling algorithm move the disk arm?

SCAN moves the disk arm in one direction, servicing requests along the way. When it reaches the end of the disk, it reverses direction.

0 ──→ 20 ──→ 50 ──→ 80 ──→ 100

                              │ reverse

100 ←── 80 ←── 50 ←── 20 ←── 0

It works like an elevator:

Go up → serve requests → reach end

Go down ← serve requests

Advantages:

  • More predictable than FCFS.
  • Provides better fairness than SSTF.
  • Reduces starvation risk.

Disadvantage:

  • The head may travel toward the physical end even when there are no requests there.

8. What is the defining characteristic of C-SCAN (Circular SCAN) disk scheduling?

C-SCAN services requests in one direction only.

When the head reaches the end, it returns to the beginning without servicing requests during the return trip.

0 ──→ 20 ──→ 50 ──→ 80 ──→ 100

                              │ return

0  ──→ 20 ──→ 50 ──→ 80 ──→ 100

The return is treated as a reset.

Why use C-SCAN?

It provides more uniform waiting times because requests are serviced in one direction rather than alternating between directions.


9. How do the LOOK and C-LOOK disk scheduling algorithms improve upon SCAN and C-SCAN?

LOOK and C-LOOK avoid unnecessary travel to the physical end of the disk.

LOOK:

Requests:

10 ── 30 ── 60 ── 90

Head →→→ 10 → 30 → 60 → 90

                  last request


                    reverse

The head reverses when there are no more requests in the current direction.

SCAN:

Head →→→ requests →→→ physical end

                      reverse

C-LOOK:

10 → 30 → 60 → 90


            jump back to
            lowest request


10 → 30 → 60 → 90

So:

  • LOOK = SCAN, but stops at the last request.
  • C-LOOK = C-SCAN, but jumps between the highest and lowest pending requests instead of going to the physical ends.

10. What is a major vulnerability of the Shortest Seek Time First (SSTF) disk scheduling algorithm?

The major disadvantage of SSTF is possible starvation.

SSTF always selects the request closest to the current head position.

                 Head

0 ──────── 50 ─── 55 ─── 60 ──────── 200

              new requests
              keep arriving

If requests continuously arrive near the current head:

55 → 60 → 52 → 58 → 61 → 54 → ...

Request at 200

may wait for a very long time

SSTF minimizes the next seek distance, but it does not guarantee fairness.


11. What is the main drawback of First-Come, First-Served (FCFS) disk scheduling?

FCFS can cause large and unnecessary head movement because it processes requests strictly in arrival order.

Requests:

5 → 190 → 8 → 180 → 12

Head movement:

5 ─────────────→ 190


                8


                180


                12

The head repeatedly moves back and forth across the disk.

Advantages:

  • Simple.
  • Fair according to arrival order.
  • No starvation.

Disadvantage:

  • Poor average seek performance.

12. How does Indexed Allocation manage file blocks on a disk?

Indexed allocation uses a separate index block containing pointers to the file’s data blocks.

Directory Entry


+-------------+
| Index Block |
+-------------+
   │   │   │   │
   ▼   ▼   ▼   ▼
  B1  B2  B3  B4

The data blocks do not need to be consecutive.

Benefits:

  • Supports direct/random access.
  • No external fragmentation.
  • Files can grow without requiring contiguous space.

Drawbacks:

  • Index blocks consume additional storage.
  • Very large files may require multi-level indexing.

13. What is a key disadvantage of Linked Allocation of disk blocks?

A major disadvantage is poor random access.

Each block contains a pointer to the next block:

[Block 1] → [Block 7] → [Block 3] → [Block 10]

    └── next pointer

To reach Block 10, the system may have to follow the chain:

Block 1

Block 7

Block 3

Block 10

Therefore, accessing the Nth block can require traversing many previous blocks.

Another disadvantage is that pointer corruption can make part of the file inaccessible.

Advantages:

  • Files can grow easily.
  • No external fragmentation.

14. Which statement is true regarding Contiguous Allocation of file blocks?

Contiguous allocation provides excellent sequential and direct access performance because a file occupies consecutive disk blocks.

File:

[10][11][12][13][14]

Start

For sequential access:

10 → 11 → 12 → 13 → 14
       very little movement

For random access, the address of block N can be calculated:

Block address = Starting block + N

Advantages:

  • Excellent sequential access.
  • Excellent random access.
  • Simple address calculation.

Disadvantages:

  • External fragmentation.
  • Difficult file growth if the following blocks are occupied.

  • Hard link — another directory entry referring to the same inode.
  • Soft link (symbolic link) — a separate file containing a path to another file.
Hard Link:

file.txt ─────┐
               ├──> Inode ──> Data
hard.txt ──────┘


Soft Link:

soft.txt ──> "file.txt" ──> Inode ──> Data
Hard linkSoft link
Points toSame inodePathname
Cross filesystemNoYes
Target deletedData remains if another hard link existsLink becomes dangling
Different inode?NoYes

Example:

ln report.txt hardlink.txt
ln -s report.txt softlink.txt

A hard link is essentially another name for the same file data, while a symbolic link acts like a pathname reference.


16. Why is Cache Memory placed between the CPU and main memory (RAM)?

Cache exists primarily to reduce the CPU’s average memory access time.

CPU


L1 Cache   ← fastest


L2 Cache


L3 Cache


RAM        ← slower

The CPU is much faster than main memory. Without cache, the CPU could spend significant time waiting for RAM.

Cache takes advantage of locality:

  • Temporal locality — recently used data is likely to be used again.
  • Spatial locality — data near recently accessed data is likely to be used soon.
CPU requests data


    Cache?
   /      \
 Yes       No
 │          │
Fast       RAM


      Put data in
         cache

17. Which of the following correctly orders Registers, Cache, and RAM from fastest access speed to slowest?

Registers → Cache → RAM

Fastest


Registers

Cache

RAM


Slowest
  • Registers — located inside the CPU and accessed extremely quickly.
  • Cache — very fast SRAM located on/near the CPU.
  • RAM — larger but slower DRAM.

Generally:

Speed:       Registers > Cache > RAM
Capacity:    Registers < Cache < RAM
Cost/bit:    Registers > Cache > RAM

18. What is the difference between a Cold Boot and a Warm Boot?

  • Cold boot — starting the computer from a powered-off state.
  • Warm boot — restarting the computer without completely removing power.
Cold Boot:

Power OFF

Power ON

Firmware initialization / POST

Bootloader

Operating System
Warm Boot:

Running OS

Restart

Firmware/boot process

Operating System starts again

A cold boot involves hardware initialization from a powered-off state. A warm boot restarts the system while power remains on.

Important: the exact amount of hardware testing during a warm boot depends on the firmware and platform; saying that POST is always completely skipped is too absolute.


19. What is the key functional difference between a computer Virus and a Worm?

  • Virus — attaches itself to a host file or program and generally requires some user action or execution of the host to spread.
  • Worm — is self-replicating and can spread automatically, commonly through networks by exploiting vulnerabilities.
Virus:

User runs infected file

Virus executes

Other files become infected

User/system spreads it


Worm:

Machine A

   │ network exploit

Machine B

   │ automatic replication

Machine C

The key distinction is how they replicate:

Virus → usually needs a host + execution
Worm  → self-contained + self-propagating

20. How do Client-Server and Peer-to-Peer (P2P) Operating System architectures differ in network management?

Client-Server architecture uses dedicated servers to provide services to clients.

        Server
       /  |  \
      /   |   \
 Client Client Client

The server may handle:

  • Authentication
  • File storage
  • Resource management
  • Centralized services

Peer-to-Peer (P2P) architecture does not depend on one central server. Each peer can act as both a client and a provider of resources.

      Peer
     /    \
    /      \
 Peer ───── Peer
   \         /
    \       /
      Peer
Client-ServerP2P
ControlMore centralizedDistributed
NodesClient/server rolesPeers can have both roles
ManagementEasier centrallyMore complex
FailureServer can be a central dependencyMore distributed
ExampleWeb/server systemsBitTorrent

Client-server architectures are generally easier to administer centrally, while P2P architectures distribute resources and responsibilities among peers.

My Private Notes

Notes are auto-saved locally to this device.