π Priority Based Scheduling in Real Time CPU Scheduling (41 MCQs)
π From Operating System β’ 6. CPU Scheduling β’ 41 questions available
What is Priority Based Scheduling in Real Time CPU Scheduling?
Definition:
Real-time priority scheduling assigns static priorities based on timing constraints rather than importance, often using rate-monotonic or deadline-monotonic assignments where priority .
Example:
A 10ms periodic sensor task receives higher priority than a 50ms logging task because shorter periods imply stricter timing requirements under RM theory.
Reason:
Static priority assignment enables offline schedulability analysis using utilization bounds, providing mathematical guarantees that dynamic schemes cannot offer for hard real-time verification.
π All Priority Based Scheduling in Real Time CPU Scheduling MCQs
Q1. What is the most important feature of a real-time operating system's scheduler?
π Explanation: Real-time systems require immediate response to high-priority tasks. A priority-based scheduler with preemption ensures that the CPU is always allocated to the highest-priority ready process, allowing critical tasks to run as soon as they need the CPU.
Q2. In a priority-based scheduling system, how are priorities typically assigned to processes?
π Explanation: Priority-based scheduling assigns each process a priority level. More important tasks, such as those with strict timing requirements or critical system functions, are given higher priorities to ensure they receive preferential access to the CPU.
Q3. Which of the following is true about priority-based scheduling with preemption?
π Explanation: Preemption is a key feature. If a higher-priority process becomes available, the scheduler will immediately preempt (interrupt) the currently running lower-priority process and allocate the CPU to the higher-priority one, ensuring timely execution for critical tasks.
Q4. In Windows, which priority levels are reserved for real-time processes?
π Explanation: Windows uses a 32-level priority scheme. The highest levels, from 16 to 31, are specifically reserved for real-time processes. This ensures that time-critical applications receive the highest priority and can preempt other, less critical system and user processes.
Q5. What does a preemptive, priority-based scheduler alone guarantee in a real-time system?
π Explanation: While a preemptive, priority-based scheduler is essential for real-time systems, it only provides soft real-time functionality. This means high-priority tasks are prioritized but without strict guarantees on meeting deadlines, which is the domain of hard real-time systems.
Q6. What additional features are required for hard real-time systems beyond a preemptive, priority-based scheduler?
π Explanation: Hard real-time systems must provide strict guarantees that tasks will complete by their deadlines. This requires additional scheduling features like admission control and deadline-based scheduling, not just basic preemptive priority scheduling.
Q7. What is a periodic process in the context of real-time scheduling?
π Explanation: A periodic process is one that executes repeatedly at fixed, regular intervals called periods. Real-time systems often deal with such processes, which have predictable patterns that schedulers can exploit to guarantee timely execution.
Q8. What is the relationship between processing time (t), deadline (d), and period (p) for a periodic real-time process?
π Explanation: For a valid periodic task, the processing time (t) must be less than or equal to the deadline (d), which in turn must be less than or equal to the period (p). This ensures the task can complete its work before the next period starts.
Q9. In a priority-based real-time system, what is the role of an admission-control algorithm?
π Explanation: Admission control is used when a process announces its deadline requirements. The scheduler then checks if it can guarantee completion without missing existing deadlines. It either admits the process with a guarantee or rejects it if the guarantee cannot be made.
Q10. Which operating systems are cited as examples that implement soft real-time scheduling features?
π Explanation: The text specifically mentions Linux, Windows, and Solaris as examples of operating systems that provide soft real-time scheduling features. Each of these systems assigns the highest scheduling priorities to real-time processes, demonstrating their capability for time-sensitive applications.
Q11. If a periodic process has a processing time of 5ms, a deadline of 10ms, and a period of 20ms, what is its rate?
π Explanation: The rate of a periodic process is defined as 1/p, where p is the period. With a period of 20ms, the rate is 1/20ms, which is 0.05 tasks per millisecond. This represents the frequency at which the process arrives and needs CPU time.
Q12. What happens when a process announces its deadline requirements to a real-time scheduler?
π Explanation: When a process announces its deadline, the scheduler evaluates if it can meet that deadline along with all other guaranteed tasks. Using an admission-control algorithm, it either accepts the process (guaranteeing its completion) or rejects it if the system cannot provide the necessary guarantee.
Q13. What is the significance of the relationship 0 β€ t β€ d β€ p for a periodic process?
π Explanation: This inequality defines the valid range of parameters for a schedulable periodic task. It ensures the processing time (t) is less than or equal to the deadline (d), which in turn is less than or equal to the period (p), preventing impossible scheduling scenarios where a task needs more time than is available.
Q14. Why are priority-based schedulers with preemption suitable for real-time systems?
π Explanation: The combination of priorities and preemption ensures that when a high-priority process becomes ready, it can immediately preempt any lower-priority process. This direct access to the CPU is crucial for meeting the timing requirements of critical real-time tasks.
Q15. In Solaris, what is the characteristic of real-time processes regarding scheduling priority?
π Explanation: Solaris, like Linux and Windows, assigns real-time processes the highest scheduling priority. This ensures that time-sensitive applications are given precedence over other system and user processes, providing the necessary responsiveness for real-time workloads.
Q16. What is the rate of a periodic process with a period of 50ms?
π Explanation: The rate of a periodic task is the reciprocal of its period. For a period of 50ms, the rate is 1/50ms = 0.02 tasks per millisecond. This rate is used in some scheduling algorithms to determine a task's priority or bandwidth requirement.
Q17. A real-time system scheduler rejects a new process request. What is the most likely reason?
π Explanation: In an admission-control system, rejection occurs when the scheduler cannot guarantee the new process's deadline along with existing commitments. This is a deliberate decision to prevent deadline misses and maintain system predictability, even if it means rejecting the request.
Q18. Which of the following is a key characteristic of a periodic process that schedulers can exploit?
π Explanation: Periodic processes have predictable parameters: a fixed processing time (t), a deadline (d), and a period (p). Schedulers can use these known parameters to calculate feasibility and assign priorities to ensure all tasks meet their deadlines.
Q19. What priority levels are used for real-time processes in Windows?
π Explanation: Windows reserves the top 16 priority levels (16-31) for real-time processes. This ensures that real-time threads can always preempt lower-priority system and user threads, providing the immediate response required for time-critical applications.
Q20. What is the primary distinction between soft and hard real-time systems in terms of scheduling?
π Explanation: The key distinction is the guarantee. Hard real-time systems must provide a deterministic guarantee that all tasks will meet their deadlines. Soft real-time systems only prioritize real-time tasks without providing strict guarantees, accepting that occasional deadline misses might occur.
Q21. A periodic process has t=2ms, d=5ms, and p=10ms. A scheduler using admission control receives a new process with t=3ms, d=4ms, and p=15ms. What must the scheduler determine?
π Explanation: Admission control requires the scheduler to analyze the feasibility of the new set of tasks. It must consider whether the new task can be scheduled with the existing one without any deadline misses. This involves calculating the utilization or using another feasibility test to determine if a guarantee can be made.
Q22. Why can't a simple preemptive priority-based scheduler alone provide hard real-time guarantees?
π Explanation: A simple preemptive priority-based scheduler ensures high-priority tasks run first but doesn't guarantee their deadlines. Hard real-time requires additional features like admission control to accept only schedulable tasks and deadline-based scheduling algorithms to ensure all accepted tasks complete before their deadlines.
Q23. In a hard real-time system using admission control, what happens to a process if the scheduler cannot guarantee its deadline?
π Explanation: Admission control in hard real-time systems is strict. If the scheduler cannot guarantee a process will meet its deadline without causing other tasks to miss theirs, the process is rejected. This ensures the system maintains its deterministic behavior and prevents overload conditions.
Q24. What is the significance of a process having to 'announce its deadline requirements' to the scheduler?
π Explanation: Announcing deadline requirements is a prerequisite for admission control. By knowing the deadline, processing time, and period, the scheduler can perform a feasibility analysis. This allows the system to provide a guarantee of completion, which is the defining characteristic of hard real-time scheduling.
Q25. Consider a system with three periodic tasks. Task A has a period of 10ms, Task B has a period of 20ms, and Task C has a period of 30ms. What is the total rate of these tasks?
π Explanation: The rate of a task is 1/period. The total rate is the sum of individual rates: 1/10ms = 0.1, 1/20ms = 0.05, 1/30ms = 0.033. The sum is approximately 0.183 tasks per millisecond. This cumulative rate is a key metric in admission control for checking CPU utilization.
Q26. What is the likely result of admitting a process that cannot be guaranteed by the scheduler?
π Explanation: Admitting an unschedulable process can lead to resource contention. In a real-time system, this will likely cause one or more processes to miss their deadlines, which could be catastrophic in a hard real-time environment. This is why admission control is crucial.
Q27. Which scheduling approach is appropriate for hard real-time systems based on the provided text?
π Explanation: Hard real-time systems require more than just priority. They use algorithms that explicitly consider a process's deadline or rate requirements, such as earliest-deadline-first or rate-monotonic scheduling. These algorithms, combined with admission control, can provide the necessary guarantees.
Q28. A system is using a preemptive priority-based scheduler. A high-priority process becomes ready while a low-priority process is executing. What is the immediate action?
π Explanation: The scheduler will immediately preempt the current low-priority process. The context of the low-priority process is saved, and the CPU is allocated to the newly ready high-priority process. This is the core of preemptive priority scheduling, ensuring critical tasks get instant CPU access.
Q29. Which of the following is NOT a characteristic of a periodic process?
π Explanation: By definition, a periodic process has a constant period (p) at which it requires the CPU. A variable period would make it an aperiodic or sporadic process, not a periodic one. The other characteristicsβconstant intervals, fixed processing time, and deadlineβare all defining features of periodic tasks.
Q30. What is the rate of a periodic task with a period of 100ms?
π Explanation: The rate of a periodic task is calculated as 1 divided by its period. For a period of 100ms, the rate is 1/100 = 0.01 tasks per millisecond. This means the task arrives once every 100ms, or 10 times per second.
Q31. In a priority-based scheduler, which process is selected to run next?
π Explanation: The fundamental rule of priority-based scheduling is that the CPU is allocated to the ready process with the highest priority. This ensures that the most important tasks get CPU time first, regardless of how long they have been waiting.
Q32. What does preemption allow a priority-based scheduler to do?
π Explanation: Preemption gives the scheduler the power to interrupt a currently executing process. This is used to enforce priority rules; if a higher-priority process becomes ready, the scheduler can preempt the current one and immediately allocate the CPU to the higher-priority task.
Q33. What are the three operating systems mentioned in the text that assign real-time processes the highest scheduling priority?
π Explanation: The text explicitly lists Linux, Windows, and Solaris as examples of operating systems that support soft real-time scheduling by reserving the highest priority levels for real-time processes. This demonstrates a common design pattern in modern OSs.
Q34. What is the primary purpose of an admission-control algorithm in a real-time scheduler?
π Explanation: Admission control acts as a gatekeeper. It prevents the system from accepting more real-time tasks than it can handle. By rejecting tasks that would cause an overload, it ensures that the accepted tasks can all meet their deadlines, maintaining the system's predictability and reliability.
Q35. A real-time task has a deadline of 20ms. It requires 5ms of CPU time. What must be true about its period for it to be a valid periodic task?
π Explanation: For a valid periodic task, the period (p) must be at least as large as the deadline (d). Since the deadline is 20ms, the period must be β₯ 20ms. The processing time (5ms) must also be β€ the deadline (20ms), so the condition 0 β€ 5 β€ 20 β€ p holds.
Q36. Which of the following is an example of a scheduling algorithm appropriate for hard real-time systems?
π Explanation: Earliest-deadline-first (EDF) is a classic hard real-time scheduling algorithm. It assigns priority based on the deadline: the task with the earliest deadline is given the highest priority. Combined with admission control, EDF can provide guarantees that all tasks will meet their deadlines.
Q37. What is the relationship between the deadline and the period of a periodic task?
π Explanation: For a periodic task, the deadline (d) must be less than or equal to the period (p). This ensures the task can complete its work before the next period begins. If the deadline were greater than the period, the task would never be able to keep up with its arrival rate.
Q38. What is the fundamental reason a preemptive priority scheduler can provide better responsiveness than a non-preemptive one for real-time tasks?
π Explanation: Preemption allows the scheduler to interrupt a lower-priority task and start a higher-priority one immediately. This is key for responsiveness, as the high-priority task doesn't have to wait for the current task to voluntarily yield the CPU, which could take a long time.
Q39. What is the rate of a periodic process with a period of 2ms?
π Explanation: The rate is 1 divided by the period. A period of 2ms gives a rate of 0.5 tasks per millisecond. This means the process arrives or needs to be executed 0.5 times per millisecond, which is equivalent to 500 times per second.
Q40. What is the primary function of the scheduler in a real-time operating system?
π Explanation: The scheduler's main job in a real-time OS is to ensure timely execution. It must be able to immediately respond to and allocate the CPU to real-time processes when they need it, ensuring that time-critical tasks are not delayed by other activities.
Q41. Why is it important for a real-time scheduler to support preemption?
π Explanation: Preemption is the mechanism that enforces priority. It allows the scheduler to immediately halt a lower-priority process and give the CPU to a newly ready higher-priority process. This ensures the highest-priority ready task is always executing, which is essential for meeting real-time requirements.