πŸŽ“ BookMCQ
← Back to 6. CPU Scheduling

πŸ“ Preemptive Scheduling in Operating System (39 MCQs)

πŸ“– From Operating System β€’ 6. CPU Scheduling β€’ 39 questions available

What is Preemptive Scheduling in Operating System?

Definition:
Preemptive scheduling allows the operating system to forcibly remove a running process from the CPU before it completes, typically when a higher priority process arrives or a time quantum qq expires.

Example:
In Round Robin scheduling, if Process X uses its full 10ms time quantum, the OS preempts it and switches to Process Y even if X has not finished its CPU burst.

Reason:
Preemption prevents any single process from monopolizing the CPU, ensuring fair resource distribution and guaranteeing bounded response times for interactive and real-time applications.

7
Easy
8
Medium
24
Hard

πŸ“ All Preemptive Scheduling in Operating System MCQs

Q1. Under which circumstance does scheduling become unavoidable?

A.When a process switches from running to ready
B.When a process switches from waiting to ready
C.When a process switches from running to waiting βœ…
D.When a timer interrupt occurs
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Scheduling is unavoidable when a process switches from running to waiting (due to I/O request or wait() call) because the CPU becomes idle. Unlike other circumstances, there is no choiceβ€”the system must select a new process for execution.

Q2. When a process terminates, what scheduling decision must be made?

A.The CPU becomes idle
B.A new process must be selected βœ…
C.The process is restarted
D.The process moves to waiting state
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: When a process terminates, the CPU becomes available and the scheduler has no choice but to select a new process from the ready queue. This is one of the unavoidable scheduling circumstances.

Q3. What is nonpreemptive scheduling also called?

A.Priority scheduling
B.Cooperative scheduling βœ…
C.Round-robin scheduling
D.Time-sharing scheduling
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Nonpreemptive scheduling is also called cooperative scheduling because processes voluntarily release the CPU by terminating or switching to waiting state. The process cooperates with the scheduler by not holding the CPU indefinitely.

Q4. Which operating system was the first to introduce preemptive scheduling in the Windows family?

A.Windows 3.x
B.Windows 95 βœ…
C.Windows NT
D.Windows 2000
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Windows 95 introduced preemptive scheduling in the Windows operating system family. Earlier versions like Windows 3.x used nonpreemptive scheduling. All subsequent Windows versions have used preemptive scheduling.

Q5. Under nonpreemptive scheduling, how does a process release the CPU?

A.Only through timer interrupts
B.By terminating or switching to waiting state βœ…
C.Only by requesting I/O
D.When a higher priority process arrives
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: In nonpreemptive scheduling, a process keeps the CPU until it releases it either by terminating or by switching to the waiting state. The process voluntarily gives up the CPU rather than being preempted by the scheduler.

Q6. What is a primary disadvantage of preemptive scheduling?

A.It increases CPU idle time
B.It can lead to race conditions βœ…
C.It reduces system responsiveness
D.It requires simpler hardware
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Preemptive scheduling can lead to race conditions when processes share data. If a process is preempted while updating shared data, another process may read inconsistent data, leading to data integrity problems and potential system failures.

Q7. Which scheduling approach does Mac OS X use?

A.Nonpreemptive scheduling
B.Cooperative scheduling
C.Preemptive scheduling βœ…
D.Hybrid scheduling
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Mac OS X uses preemptive scheduling. Previous versions of the Macintosh operating system relied on cooperative scheduling, but the OS X family adopted preemptive scheduling for improved responsiveness and multitasking capabilities.

Q8. What hardware feature is required for preemptive scheduling?

A.Memory management unit
B.Timer βœ…
C.Cache memory
D.DMA controller
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Preemptive scheduling requires a timer to generate interrupts at regular intervals, enabling the operating system to preempt running processes. Cooperative scheduling does not require this special hardware, making it usable on certain hardware platforms without a timer.

Q9. When scheduling occurs under circumstances 2 and 3, what type of scheduling is being used?

A.Nonpreemptive scheduling
B.Preemptive scheduling βœ…
C.Cooperative scheduling
D.Batch scheduling
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: When scheduling decisions occur under circumstances 2 (running to ready) and 3 (waiting to ready), the system is using preemptive scheduling. Circumstances 1 and 4 characterize nonpreemptive scheduling where scheduling is forced by process state changes.

Q10. What problem can occur when a process is preempted during a system call?

A.The process loses all data
B.Kernel data structures may become inconsistent βœ…
C.The system crashes immediately
D.The process becomes unresponsive
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: If a process is preempted during a system call while modifying important kernel data structures, the kernel may access inconsistent data. This can lead to system instability or corruption. Operating systems must design kernels to handle or prevent such scenarios.

Q11. How do most UNIX versions handle potential preemption during system calls?

A.They disable all interrupts
B.They preempt the process immediately
C.They wait for the system call to complete before context switching βœ…
D.They use special hardware to prevent preemption
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: Most UNIX versions wait for a system call to complete or for an I/O block to occur before performing a context switch. This ensures kernel data structures remain consistent and simple, as the kernel won't preempt while data is in an inconsistent state.

Q12. What is the main limitation of the UNIX kernel-execution model regarding system calls?

A.It requires excessive memory
B.It is poor for real-time computing βœ…
C.It uses too much CPU time
D.It cannot handle I/O operations
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The UNIX kernel-execution model, which waits for system calls to complete before context switching, is poor for real-time computing. Real-time tasks must complete within specific time frames, and this model can introduce unacceptable delays in task execution.

Q13. Why must interrupts not always be ignored by the kernel?

A.Input might be lost or output overwritten βœ…
B.The CPU would stop functioning
C.Memory would become corrupted
D.Processes would never terminate
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: The kernel must accept interrupts at almost all times because ignoring them can result in lost input or overwritten output. Interrupts are crucial for handling I/O operations, and failing to process them leads to data loss or system errors.

Q14. How does the kernel protect critical sections from interrupt interference?

A.It ignores all interrupts
B.It disables interrupts at entry and reenables them at exit βœ…
C.It moves critical sections to user space
D.It creates backup copies of data
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The kernel protects critical sections by disabling interrupts at entry and reenabling them at exit. This ensures that these sections are not accessed concurrently by multiple processes or interrupt handlers, preventing data corruption.

Q15. What characteristic do critical sections that disable interrupts typically have?

A.They contain many instructions
B.They are very short and occur infrequently βœ…
C.They are executed in user mode
D.They cannot be interrupted
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Critical sections that disable interrupts typically contain few instructions and do not occur very often. This is by design to minimize the time interrupts are disabled, maintaining system responsiveness while protecting sensitive kernel operations.

Q16. Which scenario would NOT cause a context switch under nonpreemptive scheduling?

A.A process terminates
B.A process requests I/O
C.A timer interrupt occurs βœ…
D.A process invokes wait()
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: Under nonpreemptive scheduling, a timer interrupt does not cause a context switch unless the process voluntarily gives up the CPU. Preemptive scheduling is required for timer-based context switching. Nonpreemptive systems rely on processes to release the CPU.

Q17. What happens to a process's state during preemption?

A.The process terminates immediately
B.The process moves from running to ready state βœ…
C.The process moves to waiting state
D.The process stays in running state
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: During preemption, the process moves from the running state to the ready state. The process is not terminated but is placed back in the ready queue, allowing the CPU to be allocated to another process. This is characteristic of preemptive scheduling.

Q18. When two processes share data and one is preempted mid-update, what data issue arises?

A.Memory leak
B.Deadlock
C.Race condition βœ…
D.Priority inversion
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: When a process is preempted while updating shared data, another process may read the data in an inconsistent state. This race condition occurs because the update operation was not atomic, leading to potential data corruption if the second process uses the inconsistent data.

Q19. What is the primary challenge when designing the kernel for preemptive scheduling?

A.Managing memory allocation
B.Ensuring kernel data structure consistency βœ…
C.Reducing CPU utilization
D.Handling user-level processes
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The primary challenge is ensuring kernel data structure consistency during preemption. The kernel must be designed to handle preemption during system calls without corrupting data, requiring careful synchronization mechanisms and atomic operations.

Q20. Why can't the kernel simply ignore all interrupts to protect critical sections?

A.Ignoring interrupts causes data loss βœ…
B.The CPU stops processing interrupts
C.Processes cannot be scheduled
D.Memory becomes fragmented
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Ignoring all interrupts would cause input loss or output overwritten. Since interrupts are essential for handling I/O operations, the kernel must accept them at almost all times. Instead, it selectively disables interrupts only during short critical sections to maintain system functionality.

Q21. What hardware requirement makes cooperative scheduling preferable on some platforms?

A.No timer hardware available βœ…
B.Limited memory capacity
C.Slow CPU speed
D.Lack of interrupt controllers
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Cooperative scheduling does not require special hardware like a timer, making it usable on hardware platforms without such capabilities. This is the only scheduling method that can work on certain hardware platforms, making it essential for resource-constrained or legacy systems.

Q22. How does preemptive scheduling improve over cooperative scheduling in Windows 95?

A.Reduced memory usage
B.Better responsiveness and multitasking βœ…
C.Simpler kernel design
D.Faster file operations
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Preemptive scheduling in Windows 95 improved responsiveness and multitasking capabilities. Unlike cooperative scheduling where processes must voluntarily release the CPU, preemptive scheduling allows the system to ensure fair CPU allocation and immediate response to high-priority tasks.

Q23. What happens if a system call modifies kernel data structures and a preemption occurs?

A.The system restarts automatically
B.Kernel data may become corrupted βœ…
C.The process is terminated
D.The I/O operation fails
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: If a system call modifies kernel data structures and is preempted, the kernel may have inconsistent data. This can lead to corruption if another process or interrupt handler accesses the same structures before the update is complete, potentially causing system instability.

Q24. In real-time systems, why is the UNIX kernel model inappropriate?

A.It uses too much memory
B.It introduces unpredictable delays βœ…
C.It cannot handle multiple processors
D.It requires too many system calls
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The UNIX kernel model, which waits for system calls to complete before context switching, introduces unpredictable delays. Real-time systems require deterministic behavior where tasks must complete within specific time frames, making this model unsuitable for meeting timing constraints.

Q25. Which of the following is a valid reason for disabling interrupts in the kernel?

A.To improve CPU performance
B.To protect critical sections of code βœ…
C.To reduce memory usage
D.To increase process priority
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Disabling interrupts protects critical sections of code from concurrent access. During these protected sections, the kernel can safely modify shared data structures without risking interruption or data corruption, ensuring system stability and consistency.

Q26. What is the relationship between preemptive scheduling and timer interrupts?

A.Timer interrupts are not related to preemption
B.Timer interrupts cause preemption βœ…
C.Preemption prevents timer interrupts
D.Timer interrupts are disabled during preemption
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Timer interrupts are the mechanism through which preemptive scheduling occurs. When a timer interrupt fires, the scheduler can preempt the current process and select another process for execution, enabling time-sharing and fair CPU allocation among processes.

Q27. Why does cooperative scheduling require processes to behave well?

A.To ensure kernel data consistency
B.To maintain system responsiveness βœ…
C.To prevent memory leaks
D.To optimize CPU usage
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Cooperative scheduling requires processes to behave well because a process that holds the CPU without releasing it can starve other processes. If a process enters an infinite loop or delays releasing the CPU, the entire system becomes unresponsive, highlighting the need for well-behaved processes.

Q28. When a process switches from waiting to ready state, what scheduling decision is made?

A.The process must be selected if preemptive scheduling is used βœ…
B.The process always keeps the CPU
C.A new process must be selected for execution
D.The process is terminated
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: When a process switches from waiting to ready state, the scheduler has a choice to preempt the current process. In preemptive scheduling, this is one of the conditions where scheduling may occur, potentially selecting the newly ready process based on scheduling criteria.

Q29. What prevents race conditions in preemptive scheduling?

A.Disabling preemption during critical sections βœ…
B.Increasing context switch frequency
C.Reducing the number of processes
D.Using only nonpreemptive scheduling
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Race conditions in preemptive scheduling are prevented by disabling preemption during critical sections where shared data is accessed. This ensures atomicity of operations, preventing other processes from accessing inconsistent data during updates, maintaining data integrity.

Q30. How does the kernel determine which sections of code require interrupt protection?

A.All kernel code is protected
B.Only sections accessing shared data structures need protection βœ…
C.Only user-level code needs protection
D.Interrupts are always enabled
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Only sections of code that access shared data structures or critical kernel resources require interrupt protection. These sections disable interrupts briefly at entry and reenable them at exit, protecting only the minimal necessary code to maintain system responsiveness.

Q31. What is the role of the timer in preemptive scheduling?

A.To measure process execution time
B.To maintain system time
C.To generate periodic interrupts for context switching βœ…
D.To track I/O operations
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: The timer in preemptive scheduling generates periodic interrupts that allow the scheduler to take control and potentially preempt the currently running process. This ensures no process monopolizes the CPU and enables time-sharing among multiple processes.

Q32. In cooperative scheduling, what happens if a process enters an infinite loop?

A.The system switches to another process
B.The system becomes unresponsive βœ…
C.The process is automatically terminated
D.The scheduler preempts the process
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: In cooperative scheduling, if a process enters an infinite loop, the system becomes unresponsive because the process never voluntarily releases the CPU. This is a fundamental weakness of cooperative scheduling that preemptive scheduling addresses through timer interrupts.

Q33. What data structure inconsistency can occur during preemption in system calls?

A.I/O queue corruption βœ…
B.File system fragmentation
C.Memory allocation errors
D.Process state corruption
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: During preemption in system calls, I/O queues may become corrupted if the kernel is updating queue structures. If a process is preempted mid-update, queue pointers may be inconsistent, leading to data structure corruption and potential system crashes.

Q34. How do modern operating systems handle kernel preemption?

A.They implement preemption points
B.They disable preemption entirely during system calls
C.They use hardware support for safe preemption
D.All of the above βœ…
πŸ’‘ Difficulty: hard | βœ… Correct: D

πŸ“– Explanation: Modern operating systems use various approaches to handle kernel preemption including preemption points where context switches can safely occur, disabling preemption during critical operations, and leveraging hardware support for safe preemption mechanisms.

Q35. What is the key difference between preemptive and nonpreemptive scheduling regarding process control?

A.Preemptive scheduling gives processes less CPU control
B.Nonpreemptive scheduling requires process cooperation
C.Preemptive scheduling uses timer hardware
D.All of the above βœ…
πŸ’‘ Difficulty: hard | βœ… Correct: D

πŸ“– Explanation: Preemptive scheduling gives processes less CPU control (they can be interrupted at any time), nonpreemptive scheduling requires process cooperation to release the CPU, and preemptive scheduling requires timer hardware for interrupts. These are fundamental distinctions between the two approaches.

Q36. Why might an operating system designer choose nonpreemptive scheduling?

A.To reduce overhead from context switching βœ…
B.To improve system security
C.To support real-time applications
D.To enable better multitasking
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Nonpreemptive scheduling reduces overhead from context switching because processes voluntarily release the CPU, eliminating the need for timer-based preemption interrupts. This simpler approach is beneficial for systems with minimal multitasking requirements or resource-constrained environments.

Q37. What is the impact of preemptive scheduling on real-time systems?

A.It guarantees timing constraints
B.It may introduce unpredictable delays βœ…
C.It eliminates process starvation
D.It improves batch processing
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Preemptive scheduling can introduce unpredictable delays in real-time systems due to context switching overhead and scheduling decisions. While beneficial for general-purpose systems, real-time applications require deterministic scheduling, making preemption challenging to manage predictably.

Q38. How does Windows 95 differ from Windows 3.x regarding process management?

A.Windows 95 uses preemptive scheduling βœ…
B.Windows 95 uses cooperative scheduling
C.Windows 3.x uses preemptive scheduling
D.Both use the same scheduling method
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Windows 95 introduced preemptive scheduling, making it fundamentally different from Windows 3.x which used cooperative scheduling. This improvement allowed better multitasking, system responsiveness, and prevented processes from monopolizing the CPU.

Q39. What condition would prevent preemptive scheduling from being used?

A.Lack of timer hardware βœ…
B.High process count
C.Large memory requirements
D.Slow CPU speed
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Preemptive scheduling requires timer hardware to generate interrupts. Without a timer, cooperative scheduling becomes the only viable method because the operating system cannot interrupt processes to enforce time-sharing or preemption decisions.

πŸ”— Related Topics (MCQs)