Skip to content

Add interrupt masking primitives#359

Draft
abelstuker wants to merge 12 commits intoTOPLLab:mainfrom
abelstuker:feat/interrupts_concurrency
Draft

Add interrupt masking primitives#359
abelstuker wants to merge 12 commits intoTOPLLab:mainfrom
abelstuker:feat/interrupts_concurrency

Conversation

@abelstuker
Copy link
Copy Markdown
Contributor

@abelstuker abelstuker commented Apr 27, 2026

This PR introduces interrupt masking primitives.
Concretely, the functions mask_interrupts and unmask_interrupts are exposed as primitives to the source program.
These allow the developer to temporarily disable or discard events during critical sections of the code.

Two types of masking behaviour exist:

  • discard mode (pass 1 to mask_interrupts): prevent events from being queued
  • temporarily disable mode (pass 0 to mask_interrupts): allow events to enqueue, but block resolution until unmaksed

Masks are identified and distinguished by their key, returned by the mask_interrupts function. This key must be used to later call unmask_interrupts. This allows for multiple (nested) masks to exist at the same time.

Events are now grouped by EventGroups (INTERRUPT_EVENT, MQTT_EVENT). These groups are also exposed as i32 primitive globals (event_group_interrupt or event_group_mqtt, and additionally event_groups_all), so they can be used in the mask_interrupts call to selectively disable one or all groups of events.

An example can be found in tutorials/wat/main/interrupt_masking.wast.

@abelstuker
Copy link
Copy Markdown
Contributor Author

Note: the current PR defines primitive globals, resulting in CI errors as described in #357, and can therefore only pass CI when this issue is resolved and the corresponding changes are merged into this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant