Programming & Compilers
How kernel preemption waits for a legal switching boundary
Separate urgent eligibility, reschedule notification and permitted task switching, then compare identical priorities under different protected-region bounds.

A higher-priority task can become eligible while the current task is executing a region where switching is prohibited. The scheduler can prefer the urgent task without yet having permission to replace the running one.
kernel preemption therefore requires both a selection rule and a legal switching boundary. Changing which task wins the selection does not automatically shorten the current execution region that must finish first.
The example below defines hypothetical priorities, boundaries and time units. It does not describe an operating system's configuration or a measured laptop response bound.
Define nonpreemptible regions in an explicit model
Use one execution context with current task C and urgent task H. The model selects the eligible task with the smallest priority number when a permitted scheduling decision occurs.
Give C priority 10 and H priority 1. Once H becomes eligible, it is the preferred next task under that rule. Assume no other eligible task has precedence over H during the illustrated interval. C can enter protected region R, where the model prohibits task switching. Notification of a scheduling need is still permitted, but the task-switch action must wait until C reaches R's specified exit boundary.
Outside R, the model has defined switching opportunities and a stated context-switch cost. Those permissions and costs are assumptions rather than consequences of the priority numbers.
The shared-invariant guide gives a protection comparison for nonpreemptible regions. It requires a whole state-transition protocol, rather than relying on individual atomic operations. If R protects a stated intermediate-state obligation in this model, admitting new task interleavings requires another correctness argument for that obligation.
This comparison does not claim that disabling preemption automatically protects every multicore shared invariant. The actual protected state and execution scope must be defined.
Trace urgent eligibility before a legal switch
Let C enter R at time zero and leave it at time eight. H becomes eligible at time one, and the scheduling need is recorded at that same time in the initial timeline.
Between times one and eight, the model knows H is preferred. C nevertheless continues because R does not permit a task switch. H remains preferred throughout that interval; the switching prohibition keeps C executing. At time eight, C reaches the legal exit boundary. The scheduling action selects H under the stated rule. With a stipulated switch cost of one time unit, H begins executing at time nine.
The eligibility-to-first-execution delay is eight time units for this history. It includes seven units waiting for the boundary and one unit of switching. The notification delay is zero in this particular example.
Making H's priority number smaller than one would not change R's exit at eight. H already wins the selection. The remaining delay lies at the switching permission and cost boundary.
Separate notification from the scheduling action
A flag or other event indicating a need to reschedule can be recorded before the switch is allowed. That record supplies evidence of notification, not evidence that H started running.
The scheduling decision also has its own timing. A system can know the preferred task during R and act on that preference at the exit, or apply its specified selection at the boundary. The model must identify which event its status describes.
If notification itself is delayed under another stipulated execution path, the eligibility time and notification time differ. That delay needs its own cause and bound; it cannot be silently included in a claim that the protected region is the only obstacle.
Likewise, reaching a permitted boundary does not make switching cost zero. The dispatch and state-change work required by the model still belongs in the first-execution timeline.
A complete record should therefore separate H's eligibility, notification, legal boundary, selection and first execution. One urgent task pending badge cannot identify which interval remains open.
Compare the same priorities under different region durations
Use another version of the model with the same priorities and switch cost, but C's protected region ends at time two. H again becomes eligible and is notified at time one.
The legal switch begins at two, and H executes at three. Its illustrated delay is two units rather than eight. The selection preference did not change; the protected execution duration did. This comparison identifies a property that can reduce the blocking boundary. Shorter permitted regions or additional legal switching points can change when the scheduler may act under a correctly revised model.
Changing only a priority or selection heuristic cannot establish the same reduction when R's nonpreemptible interval remains fixed. The preferred next task and the first permissible switch are different inputs.
The duration needs a genuine bound if it will support a worst-case claim. Observing one region finish in two units does not establish that every possible execution of that region finishes within two.
Protected duration can include nested or delayed work
Suppose R enters another protected portion before it reaches its switching boundary. The bound relevant to H covers the remaining unswitchable path, not merely the short interval associated with one nested label.
If completing that path depends on an event with no bounded arrival under the model, the initial finite region-duration assumption no longer holds. Assigning H the highest precedence cannot derive a finite first-execution bound from that missing assumption.
Other execution interference can also change the timeline if the platform model permits it. The additional cost must be stated and accounted for rather than attributed automatically to H's priority.
The example makes no claim about a particular interrupt mechanism or kernel path. It identifies which parts of the actual protected interval require evidence before the duration can be used.
A proposed improvement should say whether it shortens protected work, changes switching permission, reduces notification delay or reduces dispatch work. Each change needs evidence for the interval or permission it alters.
Moving a switching boundary needs a state-correctness argument
If R temporarily leaves a CPU-local structure in an intermediate state, a task switch inside R can expose that state to another task under the stipulated access rules. Removing the prohibition without another protocol changes the correctness assumptions. A redesign can supply a valid intermediate representation, stronger access protection or another state-transition mechanism. Its suitability depends on the specific model, not simply on the desirability of prompt execution.
The revised switching points must therefore be checked against both state preservation and the new latency account. A smaller timing number is not enough if the added interleaving violates the protected operation's contract.
A verified redesign can make a previously prohibited switching point legal when its original blocking condition has been removed. The evidence must identify that condition and show how the revised state and access rules satisfy it. The new boundary then belongs in the latency account.
This article does not prescribe changing kernel options or provide a general lock-owner priority-donation remedy. It isolates the permission boundary imposed by the named execution model.
How rescheduling latency depends on additional bounds
The cancellation-safety guide supplies a permitted-action comparison for rescheduling latency. Its cooperative cancellation request can be recorded while interruption is deferred through a small protected commitment transition. The recorded request and actual honored boundary remain separate events. Our scheduler likewise distinguishes knowing that H is preferred from having permission to switch. Document commitment and task dispatch use different contracts; the peer establishes no operating-system response bound.
For a conservative first-execution upper account, define maximum notification delay N, maximum remaining nonpreemptible work B, maximum boundary-handling cost G and maximum switch cost S. Under the stated highest-precedence and execution assumptions, their sum can provide an upper account.
The terms must actually cover the applicable path. If another eligible task can legitimately precede H, its interference is another required assumption or allowance. If any listed term lacks a bound, the finite sum cannot establish the claim.
Completion of H's requested work requires further execution and interference information after H starts. A bound for first dispatch cannot be reported as a bound for the entire operation.
For another purely numerical account, stipulate N equal to 2, B equal to 8, G equal to 1 and S equal to 1. Their conservative sum is 12 time units under the stated assumptions. Omitting notification would produce 10 and leave two permitted delay units unaccounted for. In the first concrete history, N is zero, remaining protected work is seven, boundary handling is zero and switching is one, reproducing the observed delay eight. Neither set of numbers establishes an actual platform bound without evidence for every term.
The numerical examples supply particular histories, while the symbolic account names the missing worst-case evidence. Neither is a measured implementation guarantee.
Verify what changed before reporting improved preemption
Preserve the priority rule, preemption permissions and switching boundaries. Record H's eligibility and notification, C's protected-region entry and exit, the decision and the actual first-execution time.
The eight-unit and two-unit histories differ in the region boundary. A report attributing that change only to priority would contradict their identical selection inputs.
For a worst-case claim, inspect every term and execution assumption that permits the finite bound. A preferred-task status or a fast sample cannot supply an unobserved maximum protected duration.
Keep eligibility, notification and the protected-region exit in different columns on the Lenovo IdeaPad touch laptop, whose listed screen is a 15.6-inch FHD touchscreen. Its product description pairs an i5-1334U with 16GB DDR4 and 512GB PCIe SSD storage. Record H eligible at 1, the legal boundary at 8 and first execution at 9. That worksheet separates seven units of waiting from one switching unit. A hardware description supplies no bound for a real kernel's protected path.
For reviewing the shorter-region comparison, the ASUS Vivobook 14 FHD laptop is described with 16GB DDR4 and a Core 5 120U processor. Keep the same priorities beside the revised boundary at 2 and first execution at 3. Add the separate N, B, G and S terms before making any worst-case claim. Those records concern the declared model; the listed machine has no verified timing guarantee here.