Skip to content
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Home
  • Download Now!
  • GeMRTOS
    • License
    • Download
    • GeMRTOS Documentation
      • Documentation Browser
      • GeMRTOS Manuals
    • GeMRTOS repository
  • Log in
  • Contact us
Search
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Download Now!!!
  • GeMRTOS
    • License
    • Download now!
    • GeMRTOS documentation
    • GeMRTOS repository
  • Login
  • Contact us
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
  • Challenges
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Home
  • Download Now!
  • GeMRTOS
    • License
    • Download
    • GeMRTOS Documentation
      • Documentation Browser
      • GeMRTOS Manuals
    • GeMRTOS repository
  • Log in
  • Contact us
Search
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Download Now!!!
  • GeMRTOS
    • License
    • Download now!
    • GeMRTOS documentation
    • GeMRTOS repository
  • Login
  • Contact us
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
  • Challenges

GeMRTOS - Getting started

  • Introduction to GeMRTOS
  • Getting Started with GeMRTOS: Multiprocessor RTOS for Altera FPGA (Nios II & Nios V)
  • API references
  • Platform Designer Flow for GeMRTOS Nios V FPGA Development
  • GeMRTOS RTOS Task Periods: Infinite Loop vs Periodic Tasks
  • Install Quartus Prime and WSL for GeMRTOS Nios V on Windows

GeMRTOS - Features

  • GeMRTOS Mutex and Critical Sections in Multiprocessor RTOS
  • GeMRTOS Signals: Runtime Exception Handling for Nios V RTOS
  • GeMRTOS System Architecture – Multiprocessor Design with Altera Nios V Processors
  • Hybrid Partition Scheduling in GeMRTOS, Multiprocessor RTOS for Altera FPGA
  • GeMRTOS Scheduling Lists: EDF and Fixed Priority RTOS Guide
  • GeMRTOS Tasks: Types, Creation, and Scheduling for Nios V
  • GeMRTOS Trigger Resources: Event Handling Beyond Interrupts
  • GeMRTOS Controller: Complete FPGA RTOS Hardware Guide
  • Data Structures in GeMRTOS: Control Blocks and Linked Lists
  • GeMRTOS Semaphores: Binary and Counting API for Nios V RTOS

General

  • Error (16031): Current Internal Configuration mode does not support memory initialization or ROM. Select Internal Configuration mode with ERAM.
  • newlib Thread Safety in GeMRTOS Nios V Multiprocessor RTOS
  • Set Up Questa-Intel FPGA Edition License for GeMRTOS Nios V
  • Installing Nios II Software Built Tools (SBT) for Eclipse in Quartus Prime starting from version 19.1
  • Fix Quartus Prime 23.1 Fatal Error When Creating ALTPLL IP
  • Fix Missing SDRAM Controller IP in Quartus Prime for GeMRTOS
  • GeMRTOS Nios: Fix 256MB Compile Boundary with -relax-all
  • Questa Simulation Setup for GeMRTOS Nios V: Two Common Fixes
  • Quartus Warning 113015: mem_init.hex Width Mismatch BSP Fix
  • GeMRTOS Secondary Processors Not Booting: nios2-download Fix
  • Fix Quartus Prime System Console: jvm.dll and awt.dll Errors
  • Eclipse does not start after full Quartus Prime instalation
  • Home
  • GeMRTOS KnowledgeBase
  • GeMRTOS
  • GeMRTOS Trigger Resources: Event Handling Beyond Interrupts

GeMRTOS Trigger Resources: Event Handling Beyond Interrupts

In GeMRTOS multiprocessor RTOS applications on Altera FPGA platforms with Nios V processors, a trigger resource generalizes the concept of a hardware interrupt — allowing one or more tasks to be resumed or restarted when a specific event occurs. Unlike traditional interrupt service routines limited to a single handler, trigger resources let multiple independent tasks register against the same event and respond concurrently, each acting as its own ISR. Trigger resources can be associated with hardware interrupts or activated programmatically from task code.

What Are GeMRTOS Trigger Resources? #

A trigger resource is created with gu_TriggerCreate and optionally linked to a hardware interrupt. Tasks are registered with the trigger using gu_TriggerRegisterTask. When the trigger fires, all registered tasks that are in a waiting state are resumed or restarted simultaneously. The trigger resource is automatically disabled until every registered task transitions back to a waiting state — either by completing execution or by calling gu_TriggerWait explicitly. This mechanism prevents re-triggering while tasks are still processing the previous event.

Trigger resources can also be activated from task code using gu_TriggerRelease, enabling software-driven event signalling independent of hardware interrupts. The gu_TriggerEnable and gu_TriggerDisable functions control whether a trigger resource responds to activation requests.

Trigger Flexibility: Handling Complex Hardware Events #

Trigger resources overcome a key limitation of traditional interrupts. Consider a UART device: like many peripherals, a UART typically maps multiple internal events (input buffer full, output buffer empty) to a single hardware interrupt line. Normally, an ISR must inspect the device to determine which event fired and dispatch accordingly — adding complexity to the interrupt handler.

With trigger resources, a single trigger resource is associated with the UART interrupt. The registered task checks which event occurred. If the input buffer is full, the corresponding trigger resource is activated, resuming all tasks registered for reading. This approach allows an arbitrary number of independent reader and writer tasks to operate concurrently without interfering with each other.

GeMRTOS trigger resource diagram showing hardware interrupt association and task registration

If the output buffer is empty, a separate trigger resource associated with writing tasks is activated. Each trigger resource defines hook functions to enable and disable its specific sub-event (input buffer full, output buffer empty). This virtualizes and generalizes both internal and external events, eliminating complex dispatch logic from the interrupt handler and improving modularity.

Enable and Disable Hook Functions #

GeMRTOS allows hook functions to be executed when trigger resources are enabled or disabled. gu_TriggerEnableHook registers a callback to run before the trigger resource is enabled; gu_TriggerDisableHook registers a callback to run after the trigger resource is disabled. These hooks are typically used to configure or de-configure the hardware device associated with the trigger — for example, enabling or masking a specific interrupt source on a peripheral.

Trigger Resource API Reference #

Creating a Trigger Resource #

Create and initialize a new trigger resource with:

GS_RCB *gu_TriggerCreate(int irq_id, G_UINT64 ticks_to_wait);

The gu_TriggerCreate function allocates a new trigger resource and optionally associates it with a hardware interrupt.

ParameterDescription
irq_idHardware interrupt number to associate with the trigger resource. Pass -1 for a software-only trigger with no hardware interrupt association.
ticks_to_waitTimeout for the trigger, in system ticks. Combined with gu_TriggerSetTimeoutType it determines what happens when the trigger does not fire within that time.

Returns: pointer to the newly created trigger resource (GS_RCB). This pointer must be used in all subsequent trigger-related function calls.

Registering a Task with a Trigger Resource #

Associate a task with a trigger resource using:

G_UINT32 gu_TriggerRegisterTask(struct gs_tcb *ptcb, GS_RCB *ptrigger);

The gu_TriggerRegisterTask function registers a task so that it is resumed or restarted whenever the trigger resource fires.

ParameterDescription
ptcbPointer to the GS_TCB structure of the task to register.
irq_nbrEither the IRQ number of the associated hardware interrupt, or the pointer returned by gu_TriggerCreate cast to int.

Returns: G_TRUE if registration succeeded, G_FALSE otherwise.

Enabling a Trigger Resource #

Allow a trigger resource to respond to activation with:

G_UINT32 gu_TriggerEnable(GS_RCB *ptrigger);

The gu_TriggerEnable function enables the trigger resource, allowing it to be activated by either gu_TriggerRelease or its associated hardware interrupt.

ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.

Returns: G_TRUE if the operation succeeded.

Disabling a Trigger Resource #

Prevent a trigger resource from responding to activation with:

G_UINT32 gu_TriggerDisable(GS_RCB *ptrigger);

The gu_TriggerDisable function disables the trigger resource, preventing activation by gu_TriggerRelease or its associated hardware interrupt.

ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.

Returns: G_TRUE if the operation succeeded.

Waiting for a Trigger #

Place the current task into a waiting state for its trigger resource with:

GS_TRGStatus gu_TriggerWait(void);

The gu_TriggerWait function suspends the calling task until its registered trigger resource fires again. It can be called anywhere in task code. The same effect occurs automatically when a non-infinite-loop task completes execution. No parameters are required — the task waits for the trigger resource it was registered to.

Returns: G_TRUE when called from task code, G_FALSE when called from main code.

Releasing a Trigger Resource #

Activate a trigger resource from task code with:

GS_TRGStatus gu_TriggerRelease(GS_RCB *ptrigger);

The gu_TriggerRelease function activates the trigger resource. If the resource is enabled and all registered tasks are in a waiting state, those tasks are immediately resumed or restarted.

ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.

Returns: G_TRUE if the trigger was successfully activated, G_FALSE otherwise.

Enable Hook Function #

Register a callback to execute before a trigger resource is enabled:

G_UINT32 gu_TriggerEnableHook(GS_RCB *ptrigger, void (*code_callback)(void *), void *p_arg);

The gu_TriggerEnableHook function sets the hook called immediately before the trigger resource is enabled.

ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.
code_callbackPointer to the hook function to execute when the trigger is enabled.
p_argArgument passed to the hook function, allowing the same callback to serve multiple trigger resources.

Returns: G_TRUE if the hook was successfully configured, G_FALSE otherwise.

Disable Hook Function #

Register a callback to execute after a trigger resource is disabled:

G_UINT32 gu_TriggerDisableHook(GS_RCB *ptrigger, void (*code_callback)(void *), void *p_arg);

The gu_TriggerDisableHook function sets the hook called immediately after the trigger resource is disabled.

ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.
code_callbackPointer to the hook function to execute when the trigger is disabled.
p_argArgument passed to the hook function, allowing the same callback to serve multiple trigger resources.

Returns: G_TRUE if the hook was successfully configured, G_FALSE otherwise.

T_TRIGGER_RESOURCE Structure #

The T_TRIGGER_RESOURCE structure is embedded as the trigger field within a GS_RCB resource. Access its fields using: (GS_RCB *)->trigger.<field>

Setting the Timeout Behaviour #

Control what happens when a trigger does not fire within its timeout:

G_UINT32 gu_TriggerSetTimeoutType(GS_RCB *ptrigger, GS_TRGTimeOutType type);
ValueDescription
GS_TRGTimeOutType_disabledNo timeout: the task waits indefinitely for the trigger.
GS_TRGTimeOutType_no_restartThe timeout elapses once and is not restarted.
GS_TRGTimeOutType_restart_when_enableThe timeout restarts when the trigger resource is enabled.
GS_TRGTimeOutType_restart_when_timeoutThe timeout restarts each time it expires, giving a periodic timeout.

Returns: G_TRUE if the operation succeeded.

gu_TriggerWait returns a GS_TRGStatus value, which is how a task
distinguishes a real trigger from a timeout.

Destroying a Trigger Resource #

Release a trigger resource and its timeout event back to the free pool:

G_UINT32 gu_TriggerDestroy(GS_RCB *ptrigger);
ParameterDescription
ptriggerPointer to the trigger resource, as returned by gu_TriggerCreate.

Returns: G_TRUE if the operation succeeded.

Key Takeaways #

  • GeMRTOS trigger resources generalize hardware interrupts for Nios V FPGA RTOS — multiple independent tasks can register against a single event and each act as a dedicated ISR.
  • A trigger is automatically disabled after firing and re-enabled only once all registered tasks return to their waiting state, preventing event re-entry before processing is complete.
  • The UART example illustrates how a single hardware interrupt can drive multiple independent trigger resources — one per sub-event — eliminating complex dispatch logic from the ISR.
  • Enable/disable hook functions (gu_TriggerEnableHook / gu_TriggerDisableHook) allow peripheral-specific setup and teardown to run automatically around each trigger activation cycle.
  • Triggers can be fired from task code via gu_TriggerRelease, making them equally useful for pure software event signalling without any hardware interrupt involvement.
Avalon MM, GeMRTOS, Nios 2, Nios V, RISC-V
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • What Are GeMRTOS Trigger Resources?
  • Trigger Flexibility: Handling Complex Hardware Events
  • Enable and Disable Hook Functions
  • Trigger Resource API Reference
    • Creating a Trigger Resource
    • Registering a Task with a Trigger Resource
    • Enabling a Trigger Resource
    • Disabling a Trigger Resource
    • Waiting for a Trigger
    • Releasing a Trigger Resource
    • Enable Hook Function
    • Disable Hook Function
  • T_TRIGGER_RESOURCE Structure
    • Setting the Timeout Behaviour
    • Destroying a Trigger Resource
  • Key Takeaways

Copyright © 2026 - contact us - Dorrego 287 - B8000FLE - Bahía Blanca - Argentina - +542914311867  GeMRTOS

Nios II, Nios V, Quartus Prime, ModelsSim are property of their respective companies.
GeMRTOS is property of R. Cayssials.
**All contact forms on this site are protected by reCAPTCHA. Google Privacy

GeMRTOS joins Intel Partner Alliance as Gold member.