Skip to content

Main content

Interrupt Nesting Depth Margin Tool

Compare a candidate against an explicitly ordered preemption stack where smaller priorities preempt larger ones.

Loading tool…

Description

A lower numeric candidate preempts the last active priority; increase depth only when it would preempt and subtract from depthLimit for depthMargin.

Interrupt preemption depends on priority interpretation and current state. Lower numeric values can mean higher urgency, but grouping, masks, and exception rules add further constraints.

A lower numeric candidate preempts the last active priority; increase depth only when it would preempt and subtract from depthLimit for depthMargin.

When to use this tool

Use Interrupt Nesting Depth Margin when you need a simplified explicit priority or nesting calculation.

How to use the tool and how it works

  1. Enter activePriorities, candidatePriority, depthLimit. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read wouldPreempt, resultingDepth, depthMargin. Inspect wouldPreempt before interpreting the associated values.

Require activePriorities to be nonnegative and strictly decreasing. A lower numeric candidate preempts the last active priority; increase depth only when it would preempt and subtract from depthLimit for depthMargin.1

Input fieldMeaning and unitsAccepted input
activePrioritiesActive PrioritiesRequired. Array of safe integer; maximum items 256.
candidatePriorityCandidate PriorityRequired. Safe integer; minimum 0.
depthLimitDepth LimitRequired. Safe integer; minimum 0.
Output fieldInterpretationReturned shape
wouldPreemptWould PreemptRequired. Boolean.
resultingDepthResulting DepthRequired. Safe integer.
depthMarginDepth MarginRequired. Safe integer.
json
{
  "input": {
    "activePriorities": [
      5,
      3
    ],
    "candidatePriority": 1,
    "depthLimit": 4
  },
  "output": {
    "wouldPreempt": true,
    "resultingDepth": 3,
    "depthMargin": 1
  }
}

Limitations and assumptions

  • This simplified numeric-priority model does not include grouping, global masks, exceptions, or actual stack consumption.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Review the interrupt controller's complete priority, masking, and exception model and measure stack requirements.

References

  1. Calculation and input contract: microcontroller/interrupt-nesting-depth-margin — tool.io

Similar or alternative tools