Skip to content
Skills Library
Programming · Building & coding

meddev-interrupt-handling

/meddev-interrupt-handling

Define safe interrupt design: short ISRs, deferred work, priority assignment, critical section management, and testing strategies. Use when working on interrupt handling in medical device software.

Licence
MIT
Last repository change
19.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 19.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Define safe interrupt design: short ISRs, deferred work, priority assignment, critical section management, and testing strategies. Use when working on interrupt handling in medical device software.

Original author description

Define safe interrupt design: short ISRs, deferred work, priority assignment, critical section management, and testing strategies. Use when working on interrupt handling in medical device software.

How it works

  1. Purpose
  2. When to Apply
  3. Requirements (testable)
  4. Recommended Practices
  5. Patterns
  6. Anti-Patterns (risks)
  7. Verification Checklist
  8. Traceability
  9. References
  10. Changelog
Original SKILL.md headings · 83 lines, 444 words
SKILL.md preview
---
name: meddev-interrupt-handling
description: 'Define safe interrupt design: short ISRs, deferred work, priority assignment, critical section management, and testing strategies. Use when working on interrupt handling in medical device software.'
license: MIT
metadata:
  skill_id: FW-INTERRUPTS
  version: 1.0.0
  last_updated: '2026-01-04'
  applies_to: Class A, Class B, Class C
  jurisdiction: Global
  prerequisites: FW-EMBEDDED-C
  category: firmware
---

# Interrupt Handling in Medical Devices

## Purpose
Define safe interrupt design: short ISRs, deferred work, priority assignment, critical section management, and testing strategies.

## When to Apply
- Any ISR or interrupt-driven feature; safety-relevant timing/response paths.

## Requirements (testable)
1. ISR Minimalism: ISRs do minimal, non-blocking work; defer processing to tasks; no dynamic allocation. Rationale: predictability and latency.
2. Priority Scheme: Assign priorities to meet safety/timing; avoid unintentional preemption of critical tasks; document scheme. Rationale: correct responsiveness.
3. Shared Data Protection: Use atomic ops or proper locks (or disable interrupts briefly) for shared data; `volatile` for flags shared with ISRs. Rationale: data consistency.
4. Critical Sections: Keep interrupt masking short and bounded; no masking around unbounded loops. Rationale: latency control.
5. Reentrancy: ISR-invoked functions must be reentrant or protected; no non-reentrant libc calls in ISRs. Rationale: avoid corruption.
6. Testing: Provide ISR unit/integration tests where feasible; measure latency and service time; fault injection for missed/rapid interrupts. Rationale: verification.

## Recommended Practices
- Use double-buffering for ISR-produced data.
- Keep ISR code in fast memory if available; minimize branching.
- Provide statistics (count, overrun) for diagnostics.
- Avoid long chains of interrupt enabling/disabling; prefer fine-grained critical sections.

## Patterns
Deferred work:
```c
// REQ-INT-ISR-01; TEST-INT-03
volatile bool g_rx_ready = false;
void UART_IRQHandler(void) {
    clear_uart_irq();
    g_rx_ready = true; // defer to task
}
```

Atomic flag update:
```c
// REQ-INT-SHARED-02; TEST-INT-05
void set_flag_from_isr(void) {
    atomic_store_explicit(&g_flag, 1, memory_order_release);
}
```

Bounded critical section:
```c
// REQ-INT-CRIT-03; TEST-INT-07
uint32_t read_counter_atomic(void) {
    uint32_t primask = disable_irq();
    uint32_t v = g_counter;
    restore_irq(primask);
    return v;
}
```

## Anti-Patterns (risks)
- Heavy processing or blocking in ISR -> risk: latency, missed deadlines.
- Calling non-reentrant functions (e.g., printf) from ISR -> risk: corruption.
- Long interrupt masking -> risk: jitter and missed time-critical events.
- Shared data without synchronization -> risk: race conditions.

## Verification Checklist
- [ ] ISRs minimal, non-blocking, no heap; defer work to tasks.
- [ ] Interrupt priorities assigned/documented; critical ISRs prioritized appropriately.
- [ ] Shared data protected; volatile flags/atomics used; no data races.
- [ ] Critical sections short and bounded; masking limited.
- [ ] ISR-invoked functions reentrant or protected.
- [ ] Latency/service time measured; tests/fault injection performed.

## Traceability
- Use `REQ-INT-###`; link to tests `TEST-INT-###`; keep timing measurements with artifacts.

## References
- MCU vendor interrupt guidance; CMSIS recommendations.
- IEC 62304 timing and design expectations.

## Changelog
- 1.0.0 (2026-01-04): Initial interrupt handling skill with ISR minimalism, priority, and testing guidance.

## Audit History
- **2026-01-04**: Audit performed. Verified:
  - CMSIS recommendations accurately represented
  - ISR patterns follow embedded best practices
  - Atomic operations correctly used in examples

Versions

The database has no other skills named meddev-interrupt-handling.

Database snapshot: 13.11.2026 · package version 2ae0b885e9ef (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90interrupt-safe-code
    Write ISRs that stay minimal, share data through volatile-correct handoffs, and defer real work safely. Use when writing interrupt handlers or debugging corruption that only happens sometimes.
  • 90esp32-deferred-interrupt-work
    Use when designing, reviewing, debugging or validating deferred interrupt work for ESP32 firmware; apply target-specific constraints, failure analysis and measurable verification before release.
  • 100interrupts-and-exceptions-baremetal
    Bare-metal interrupt and exception skill for Cortex-M NVIC. Use when writing ISRs, configuring priorities, handling HardFault, or measuring interrupt latency. Activates on queries about NVIC, ISR, vector table, HardFault, tail-chaining, or interrupt priority.
  • 100meddev-authentication
    Define secure user/device authentication, session management, and RBAC suitable for medical device risk profiles. Use when working on authentication in medical device software.
  • 100meddev-power-management
    Define safe power management patterns: sleep modes, wake sources, power budget, battery monitoring, graceful shutdown, and data preservation. Use when working on power management in medical device software.
  • 90isr-latency-and-critical-section-audit
    Use when interrupt watchdog fires, peripheral timing jitters or system tasks starve during high-rate interrupt activity. Establish target-specific constraints, evidence, failure analysis and measurable verification before release.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.