← Back to quizzesFree quiz

Fundamentals of Operating Systems

Operating systems (OS) are the backbone of modern computing, managing hardware resources, providing services to applications, and ensuring system stability. This course distills the…

11 questions~6 min
Fundamentals of Operating Systems — Qwi
0 / 11
Score: 0%
1

Which scheduling algorithm selects the process with the shortest next CPU burst?

2

In a demand paging system, what event occurs when a process accesses a page marked invalid?

3

Which of the following conditions is NOT required for a deadlock to occur?

4

A process in the 'ready' state is waiting for:

5

In a multi-level page table, what does the second-level index (p2) represent?

6

When using the Banker’s algorithm, a request is granted only if:

7

Which file allocation method suffers from external fragmentation but provides fast direct access?

8

In a priority scheduling algorithm, if two processes have equal priority, how are they scheduled?

9

What is the primary purpose of a semaphore’s wait operation in the critical section problem?

10

During a page replacement, which algorithm would replace the page that will not be used for the longest future interval?

11

Which of the following best describes the role of the long‑term scheduler in a multiprogrammed OS?

Fundamentals of Operating Systems: Core Concepts Explained

Operating systems (OS) are the backbone of modern computing, managing hardware resources, providing services to applications, and ensuring system stability. This course distills the essential concepts tested in a typical OS quiz, offering clear explanations, practical examples, and SEO‑optimized content that helps learners master scheduling, memory management, deadlock handling, and file allocation.

1. Process Scheduling Algorithms

Scheduling determines which process gets CPU time and when. Understanding the differences between algorithms is crucial for both academic exams and real‑world system design.

  • Shortest Job First (SJF): Selects the process with the shortest next CPU burst. It minimizes average waiting time but can cause starvation for longer jobs.
  • Priority Scheduling: Assigns a priority value to each process; the highest priority runs first. Ties are usually broken by First Come, First Served (FCFS) order.
  • Round Robin (RR): Gives each ready process a fixed time slice (quantum) in a cyclic order, providing fairness and good response time for interactive systems.
  • First Come, First Served (FCFS): Processes are executed in the order they arrive. Simple but can lead to the "convoy effect" where short jobs wait behind long ones.

When asked which algorithm selects the shortest next CPU burst, the correct answer is Shortest Job First (SJF). Remember the mnemonic "SJF = shortest job first" to quickly recall its purpose.

2. Demand Paging and Page Faults

Demand paging loads pages into memory only when they are needed, conserving RAM. If a process accesses a page marked invalid, the hardware triggers a page fault trap. The operating system then locates the required page on secondary storage, loads it into a free frame, updates the page table, and resumes the process.

  • Page fault → OS handles it → Process continues.
  • Immediate termination or silent ignore are NOT typical behaviors.

Key takeaway: A page fault is a normal part of demand paging, not an error. This concept is essential for understanding virtual memory performance.

3. Deadlock Conditions

A deadlock occurs when a set of processes are each waiting for resources held by the others, creating a circular wait. Four necessary conditions must hold simultaneously:

  • Mutual Exclusion: At least one resource cannot be shared.
  • Hold and Wait: Processes hold resources while requesting new ones.
  • No Preemption: Resources cannot be forcibly taken away.
  • Circular Wait: A closed chain of processes exists, each waiting for a resource held by the next.

In the quiz, the condition "Preemption" is NOT required for a deadlock, making it the correct answer. Understanding this helps when designing deadlock avoidance or detection mechanisms.

4. Process States: Ready vs. Running

Operating systems classify processes into distinct states. A process in the ready state has all necessary resources except the CPU. It is waiting for CPU allocation to transition to the running state.

  • Ready → Waiting for CPU.
  • Running → Currently executing on the CPU.
  • Blocked (or Waiting) → Awaiting I/O or other events.
  • Terminated → Completed execution.

Thus, the correct answer to "A process in the 'ready' state is waiting for" is CPU allocation.

5. Multi‑Level Page Tables: Understanding the Second‑Level Index (p2)

Modern 64‑bit systems use hierarchical page tables to reduce memory overhead. A two‑level scheme consists of an outer (first‑level) table and an inner (second‑level) table. The second‑level index, often denoted p2, selects an entry within the inner page‑table page.

  • What p2 represents: The displacement (offset) inside the page that holds the second‑level entries.
  • It is not the physical frame number, nor the index of the outer table.
  • Think of the outer index as choosing a chapter in a book, while p2 points to a line within that chapter.

Mnemonic tip: "p2 = pointer inside page 2" – the “2” reminds you that you are inside the second‑level page.

6. Banker’s Algorithm for Deadlock Avoidance

The Banker’s algorithm evaluates resource requests against the system’s safe state. A request is granted only if:

  • It does not exceed the process’s remaining Need (maximum claim minus allocated resources).
  • After provisional allocation, the system can still find a sequence of processes that can finish – i.e., the state remains safe.

If either condition fails, the request is denied to avoid entering an unsafe (potential deadlock) state. This principle is vital for designing robust resource‑allocation policies.

7. File Allocation Methods

File systems decide how to map logical file blocks to physical storage. Four classic methods exist:

  • Contiguous Allocation: Stores a file in consecutive blocks. It provides fast direct access but suffers from external fragmentation because free space may be split into small pieces.
  • Linked Allocation: Uses pointers in each block to the next, eliminating external fragmentation but requiring sequential access.
  • Indexed Allocation: Maintains an index block containing pointers to all file blocks, supporting random access without fragmentation.
  • Dynamic Allocation: A generic term often referring to linked or indexed schemes.

Therefore, the method that "suffers from external fragmentation but provides fast direct access" is Contiguous Allocation.

8. Priority Scheduling with Equal Priorities

When two processes share the same priority, most OS implementations fall back to a secondary rule. The most common tie‑breaker is First Come, First Served (FCFS) order, preserving fairness without additional overhead.

  • Random selection, Round Robin, or Shortest Remaining Time First are not standard tie‑breakers for pure priority scheduling.

Thus, equal‑priority processes are scheduled in FCFS order.

9. Summary of Key Points

  • Scheduling: SJF selects the shortest next burst; priority ties use FCFS.
  • Demand Paging: Invalid page access triggers a page‑fault trap.
  • Deadlock: Preemption is NOT a required condition.
  • Process States: Ready processes await CPU allocation.
  • Multi‑Level Page Tables: p2 is the offset within the inner page‑table page.
  • Banker’s Algorithm: Grant requests only if they satisfy Need and keep the system safe.
  • File Allocation: Contiguous allocation causes external fragmentation but enables fast direct access.
  • Priority Scheduling: Equal priorities resolve to FCFS order.

10. Frequently Asked Questions (FAQ)

Q: Why does SJF cause starvation?

A: Because longer jobs may never get CPU time if shorter jobs keep arriving.

Q: How can a system recover from a deadlock?

A: By preempting resources, terminating processes, or rolling back transactions to break the circular wait.

Q: What is the performance impact of a page fault?

A: A page fault incurs disk I/O latency, often orders of magnitude slower than memory access, affecting overall throughput.

11. Further Reading and Resources

  • Operating System Overview – Wikipedia
  • Operating Systems: Three Easy Pieces (OSTEP)
  • Process Scheduling Tutorial – TutorialsPoint
  • Deadlock Concepts – GeeksforGeeks