1 GeMRTOS API Functions categories

1.1 Critical Section category ˆˆEˆˆL

The Critical Section category in GeMRTOS provides essential macros for protecting shared data structures during concurrent task execution. These macros are specifically designed to manage access to GeMRTOS data structures, ensuring that operations on shared resources are executed atomically to prevent race conditions and maintain data integrity. Proper implementation of these critical section macros is crucial for protecting GeMRTOS-specific data structures from unexpected behaviors that may arise from simultaneous access by multiple tasks or processors. This category empowers developers to create secure and efficient real-time applications by ensuring that critical operations on data structures are performed without interruption or conflict.

gm_GeMRTOSCriticalSectionEnter
gm_GeMRTOSCriticalSectionExit

1.2 Frozen Mode category ˆˆEˆˆL

The Frozen Mode category in GeMRTOS includes functions and macros that manage system behavior during critical operational states. This mode allows the system to temporarily suspend certain tasks and processes to preserve resources and maintain stability under specific conditions. By entering Frozen Mode, developers can prevent unwanted interruptions and manage timing more effectively, particularly in scenarios that require precise timing or resource allocation. Functions related to Frozen Mode enable the configuration of thresholds and control mechanisms, allowing for efficient activation and deactivation of this mode as needed. This capability is essential for optimizing performance and ensuring system reliability in real-time applications.

gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet

1.3 IRQ Management category ˆˆEˆˆL

The IRQ Management category in GeMRTOS encompasses functions and macros designed to handle interrupt requests (IRQs) efficiently within the real-time operating system. This category provides essential tools for enabling, disabling, and managing interrupts, allowing tasks to respond promptly to external events and system signals. Effective IRQ management is crucial for optimizing system performance, as it facilitates the prioritization of tasks and ensures that critical events are addressed in a timely manner.

gm_IrqDisable
gm_IrqEnable
gk_NextOccTimeProcessor
gm_TriggerPrcIRQ

1.4 Message Queue category ˆˆEˆˆL

The Message Queue category in GeMRTOS provides essential functions and macros for implementing inter-task communication through message passing mechanisms. This category enables tasks to exchange data and synchronize their operations efficiently, facilitating seamless collaboration within a real-time system.
By utilizing the Message Queue category, developers can create, send, and receive messages between tasks, allowing for asynchronous communication that enhances system responsiveness. The functions within this category support various operations, including message queue creation, message enqueuing and dequeuing to ensure robust data exchange.
With the capability to configure message priorities and handling, the Message Queue category not only streamlines communication but also aids in managing task dependencies and resource sharing. This is particularly important in complex applications where timely and reliable message transfer is critical. By ensuring effective inter-task communication, the Message Queue category plays a vital role in optimizing performance and contributing to the overall reliability of the GeMRTOS environment.

gu_MessageQueueCreate
gu_MessageQueuePrintf
gu_MessageQueueReceive
gu_MessageQueueReceiveTimeout
gu_MessageQueueSend
gu_MessageQueueSubscribe

1.5 Processor category ˆˆEˆˆL

The Processor category in GeMRTOS includes functions and macros that provide critical tools for managing processor-level operations and configurations within the real-time operating system. This category facilitates the control of individual processors, allowing developers to optimize task scheduling, interrupt handling, and overall system performance. Functions in this category enable manipulation of processor states, including halting, resuming, and managing processor interrupts, as well as retrieving processor-specific information. The Processor category is essential for developing robust real-time applications that require precise control over processing resources, promoting responsiveness, and achieving effective synchronization between tasks and hardware components.

gm_PrcInterruptDisable
gm_PrcInterruptEnable
gm_ProcessorHalt
gm_ProcessorId
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq

1.6 Scheduling List category ˆˆEˆˆL

The Scheduling List category in GeMRTOS encompasses functions and macros designed to facilitate the management and manipulation of hybrid scheduling lists within the real-time operating system. These tools provide essential data structure capabilities that allow developers to create, modify, and traverse collections of tasks efficiently, enabling dynamic and flexible scheduling approaches.
By using the Scheduling List category functions, developers can implement effective algorithms for task prioritization, resource allocation, and event handling, all while maintaining high performance and minimal overhead. The functions within this category support various operations such as adding and removing tasks, adjusting priorities, and specifying scheduling criteria. Notably, the configuration of scheduling list exclusions can help prevent real-time anomalies, ensuring that critical tasks receive the attention they need while balancing processor loads effectively.
Integration of the Scheduling List category into real-time applications enhances task organization and scheduling efficiency, enabling the system to respond rapidly to changes in workload and processor availability. This capability is critical for applications where timing, responsiveness, and resource management are paramount.

gu_SchedulingListAssociateProcessor
gu_SchedulingListAssociateTask
gu_SchedulingListCreate
gu_SchedulingListExclusionSet

1.7 Semaphore and Mutex category ˆˆEˆˆL

The Semaphore and Mutex category in GeMRTOS encompasses functions and macros designed to facilitate synchronization and resource management among concurrent tasks within the real-time operating system. Semaphores and mutexes are essential for controlling access to shared resources, preventing race conditions, and ensuring data integrity by regulating how tasks interact with one another.
By utilizing the Semaphore and Mutex category, developers can create and manage both binary and counting semaphores, and mutexes, allowing for fine-grained control over task execution and resource allocation. The functions within this category enable operations such as semaphore and mutex creation, waiting, and signaling, effectively coordinating task activities and synchronizing their behavior.
The use of semaphores and mutexes is crucial in environments where multiple tasks need to access shared resources without conflict, as it helps maintain system stability and performance. Additionally, by leveraging semaphores and mutexes, developers can enhance the efficiency of their applications, ensuring that critical tasks are executed in a timely manner while preventing task starvation and optimizing resource utilization.

gu_SemaphoreCreateBinary
gu_SemaphoreCreateMutex
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGetCount
gu_SemaphoreGive
gu_SemaphoreTake

1.8 Signal category ˆˆEˆˆL

The Signal category in GeMRTOS provides essential functions and macros for implementing event-driven synchronization mechanisms between tasks within the real-time operating system. Signals serve as lightweight notification tools that allow tasks to communicate important state changes, alerts, or operational events efficiently.
By utilizing the Signal category, developers can create and manage signals that facilitate asynchronous task coordination, enabling tasks to respond promptly to specific events without polling or constant checking. Functions within this category support operations such as signal creation, allowing tasks to seamlessly be notified when critical actions need to take place.

gu_SignalCreate
gu_SignalDestroy

1.9 System category ˆˆEˆˆL

The System category in GeMRTOS encompasses critical functions and macros that provide core capabilities for managing and configuring the operating environment. This category is vital for overseeing system-level operations, resource management, and overall application behavior within the real-time operating system.
By utilizing the System category, developers can access functions that facilitate system initialization, configuration of kernel parameters, and management of system states.

gm_ERETAddressSet
gm_MutexNestedValue
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_fprintf
gu_printf

1.10 Task category ˆˆEˆˆL

The Task category in GeMRTOS includes essential functions and macros for creating, managing, and scheduling tasks within the real-time operating system. This category is fundamental for implementing multitasking, allowing applications to perform multiple operations concurrently and efficiently utilize system resources.
By leveraging the Task category, developers can create tasks with specified priority levels, resource requirements, and execution parameters, enabling fine control over how tasks are executed and scheduled. Functions within this category support a wide range of operations, including task creation, and suspension, as well as priority management.
The flexibility offered by the Task category supports responsive applications that can adapt to dynamic conditions in real-time environments. The Task category is crucial for building robust, efficient, and responsive applications in the GeMRTOS ecosystem, facilitating the seamless management of concurrent operations in complex real-time systems.

gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet

1.11 Time Management category ˆˆEˆˆL

In GeMRTOS, the core time management tasks revolve around manipulating system times and time intervals to support precise task synchronization and scheduling. These functions enable setting, reading, and adjusting system clocks, as well as defining time intervals for specific operations. Through effective time manipulation, developers can coordinate task execution and ensure activities occur at exact moments, maintaining the system’s deterministic behavior.

gm_StatusCountingTimeGet
gm_StatusResetCountingTimeGet
gm_SystemTimePrescaleGet
gm_SystemTimePrescaleSet
gu_SystemTotalTimeGet

1.12 Trigger category ˆˆEˆˆL

The Trigger category in GeMRTOS encompasses functions and macros that facilitate event-driven mechanisms within the real-time operating system. These functions enable tasks to respond to specific events, interrupts, or conditions, enhancing the system's interactivity and responsiveness. Triggers play a crucial role in synchronization, allowing tasks to be activated based on the occurrence of defined events, thereby optimizing resource utilization and improving overall system efficiency.

gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait

1.13 Watchdog category ˆˆEˆˆL

The Watchdog category in GeMRTOS covers two independent fault-detection mechanisms, both fail-stop with diagnostics rather than silent: a per-processor watchdog that resets a processor which stops halting (a hung task, by design – it cannot see a processor that hangs inside a critical section, since its counter does not decrement while the GeMRTOS Mutex is held), and a mutex-hold watchdog that covers exactly that other case, resetting the processor holding the mutex if it holds it too long while leaving the mutex granted to it, so every other processor blocks and the system freezes for diagnosis. Both report through an optional application-supplied handler, called after a built-in diagnostic report has already been printed.

gm_WatchdogTimeoutSet
gm_PrcWatchdogEnable
gm_PrcWatchdogDisable
gu_WatchdogHandlerSet
gm_MutexWatchdogFieldGet
gm_MutexWatchdogTimeoutSet
gm_MutexWatchdogDisable
gm_MutexWatchdogFiredGet
gu_MutexWatchdogHandlerSet

2 GeMRTOS Functions

__________________________________________________________________

2.1 gm_GeMRTOSCriticalSectionEnter

Prototype
void gm_GeMRTOSCriticalSectionEnter;

Description: The gm_GeMRTOSCriticalSectionEnter macro defines the entry point into a critical section for the management of kernel data. It is designed to ensure that modifications to shared kernel resources occur safely, although it may be interrupted while waiting for the GeMRTOS controller mutex. This macro should be utilized whenever there is a need to modify kernel data to prevent data corruption and maintain system stability.

Parameters
The gm_GeMRTOSCriticalSectionEnter macro does not accept any parameters.

Returns
The gm_GeMRTOSCriticalSectionEnter macro does not return any value but blocks the code execution until the GeMRTOS controller mutex is granted.

Thread-safety
Blocking — waits until the hardware mutex is granted. Not reentrant unless nested mutex is enabled.

Error conditions
None returned; execution blocks indefinitely if mutex is never released.

Preconditions
Must not already hold the GeMRTOS mutex (unless nested mutex is active via gm_MutexNestedValue).

Postconditions
The calling processor holds the GeMRTOS controller hardware mutex.

See also
gm_GeMRTOSCriticalSectionExit
gm_IrqDisable
gm_IrqEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.2 gm_GeMRTOSCriticalSectionExit

Prototype
void gm_GeMRTOSCriticalSectionExit;

Description: The gm_GeMRTOSCriticalSectionExit macro exits the critical section from the current processor, allowing other processors to enter. It is essential to use this macro in all user functions that execute kernel functions or modify kernel data, ensuring that the critical section is properly released and preventing potential deadlocks or resource contention.

Parameters
The gm_GeMRTOSCriticalSectionExit macro does not accept any parameters.

Returns
The gm_GeMRTOSCriticalSectionExit macro does not return any value.

Thread-safety
Must be called by the processor that called gm_GeMRTOSCriticalSectionEnter.

Error conditions
Undefined behavior if called without a prior matching Enter.

Preconditions
The calling processor must hold the GeMRTOS mutex.

Postconditions
The GeMRTOS mutex is released; other processors may acquire it.

See also
gm_GeMRTOSCriticalSectionEnter
gm_IrqDisable
gm_IrqEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.3 gm_FrozenModeDisable

Prototype
static inline void gm_FrozenModeDisable(void);

Description: The gm_FrozenModeDisable function disables the frozen mode event. By default, the frozen mode starts in a disabled state.

Parameters
The gm_FrozenModeDisable function does not accept any parameters.

Returns
The gm_FrozenModeDisable function does not return any value.

Thread-safety
Must be called within a critical section (GeMRTOS mutex held).

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
Frozen mode is disabled; system stays in non-frozen mode regardless of time threshold.

See also
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.4 gm_FrozenModeEnable

Prototype
static inline void gm_FrozenModeEnable(void);

Description: The gm_FrozenModeEnable function enables the frozen mode event. By default, the frozen mode starts in a disabled state. Before invoking this function, ensure that the frozen threshold is properly configured using the gu_FrozenModeThresholdSet function. The gm_FrozenModeDisable function disables the frozen mode.

Parameters
The gm_FrozenModeEnable function does not accept any parameters.

Returns
The gm_FrozenModeEnable function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held. Frozen threshold (gu_FrozenModeThresholdSet) should be configured first.

Postconditions
Frozen mode is enabled; controller will switch to frozen mode when system time exceeds the next event by the threshold.

See also
gm_FrozenModeDisable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.5 gm_GatedClockDisable

Prototype
static inline void gm_GatedClockDisable(void);

Description: The gm_GatedClockDisable function disables the output clock of the the GeMRTOS controller. It may be used in special applications.

Parameters
The gm_GatedClockDisable function does not accept any parameters.

Returns
The gm_GatedClockDisable function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
The gated clock output port of the GeMRTOS controller is driven low.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.6 gm_GatedClockEnable

Prototype
static inline void gm_GatedClockEnable(void);

Description: The gm_GatedClockEnable function enables the output clock of the the GeMRTOS controller. It may be used in special applications.

Parameters
The gm_GatedClockEnable function does not accept any parameters.

Returns
The gm_GatedClockEnable function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
The gated clock output port mirrors the GeMRTOS controller input clock.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.7 gm_StatusFrozenModeEnableGet

Prototype
static inline G_UINT32 gm_StatusFrozenModeEnableGet(void);

Description: gm_StatusFrozenModeEnableGet returns the status of the enable of the frozen mode (G_TRUE if enabled, G_FALSE if disabled). The execution of gm_FrozenModeEnable enables the frozen mode. The execution of gm_FrozenModeDisable disables the frozen mode.

Parameters
gm_StatusFrozenModeEnableGet has no parameter.

Returns
The gm_StatusFrozenModeEnableGet function returns G_TRUE if frozen mode is enabled, G_FALSE if disabled.

Thread-safety
Read-only; safe to call within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex should be held for a consistent read.

Postconditions
None.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.8 gm_SystemReset

Prototype
static inline void gm_SystemReset(void);

Description: The gm_SystemReset function resets the GeMRTOS controller. Is is executed only by the GeMRTOS kernel.

Parameters
The gm_SystemReset function does not accept any parameters.

Returns
The gm_SystemReset function does not return any value.

Thread-safety
Resets the entire GeMRTOS controller; all state is lost.

Error conditions
Does not return; system restarts.

Preconditions
GeMRTOS mutex must be held.

Postconditions
All GeMRTOS controller registers are reset to their initial state.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.9 gm_TimeCountersReset

Prototype
static inline void gm_TimeCountersReset(void);

Description: The gm_TimeCountersReset function resets and holds reset the time counters. Is is executed only by the GeMRTOS kernel.

Parameters
The gm_TimeCountersReset function does not accept any parameters.

Returns
The gm_TimeCountersReset function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
Called at system startup before gm_TimeCountersUnreset.

Postconditions
System time counters are reset and held at zero.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.10 gm_TimeCountersHold

Prototype
static inline void gm_TimeCountersHold(void);

Description: The gm_TimeCountersHold function holds the time counters. Is is executed only by the GeMRTOS kernel.

Parameters
The gm_TimeCountersHold function does not accept any parameters.

Returns
The gm_TimeCountersHold function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
All time counters are frozen at their current values.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.11 gm_TimeCountersUnhold

Prototype
static inline void gm_TimeCountersUnhold(void);

Description: The gm_TimeCountersUnhold function unholds the time counters running from its current state. Is is executed only by the GeMRTOS kernel.

Parameters
The gm_TimeCountersUnhold function does not accept any parameters.

Returns
The gm_TimeCountersUnhold function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held. gm_TimeCountersHold must have been called first.

Postconditions
Time counters resume incrementing from the held values.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.12 gm_TimeCountersUnreset

Prototype
static inline void gm_TimeCountersUnreset(void);

Description: The gm_TimeCountersUnreset function unresets theSystemTime Register for running. Is is executed only by the GeMRTOS kernel.

Parameters
The gm_TimeCountersUnreset function does not accept any parameters.

Returns
The gm_TimeCountersUnreset function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
gm_TimeCountersReset must have been called first. GeMRTOS mutex must be held.

Postconditions
Time counters are released and begin incrementing.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.13 gu_FrozenModeThresholdGet

Prototype
G_UINT64 gu_FrozenModeThresholdGet(void);  /* reads FRZ_THR register pair */

Description: The gu_FrozenModeThresholdGet function retrieves the value of the Frozen Time Threshold register from the GeMRTOS controller (R_FRZ_TM_THR). By default, the frozen mode is disabled, and the frozen threshold is set to zero. This function is useful for determining the current threshold value, which is critical for managing the activation of frozen mode.

Parameters
The gu_FrozenModeThresholdGet function does not accept any parameters

Returns
The gu_FrozenModeThresholdGet function returns the current value of the Frozen Time Threshold register in the GeMRTOS controller.

Thread-safety
Safe to call from task context; acquires mutex internally.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdSet
gu_FrozenModeTimeGet
__________________________________________________________________

2.14 gu_FrozenModeThresholdSet

Prototype
G_Status gu_FrozenModeThresholdSet(G_UINT64 time_set);

Description: The gu_FrozenModeThresholdSet function sets the value of the Frozen Time Threshold register in the GeMRTOS controller. By default, the frozen mode is disabled, and the frozen threshold is initialized to zero. This function is essential for configuring the threshold that determines when the frozen mode becomes active when it is enabled.

Parameters
The gu_FrozenModeThresholdSet function accepts the following parameter:

Returns
Always G_OK.

Thread-safety
Safe to call from task context; acquires mutex internally.

Error conditions
None.

Preconditions
None.

Postconditions
The frozen threshold is updated; frozen mode will activate when system time exceeds the next event time by this threshold.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeTimeGet
__________________________________________________________________

2.15 gu_FrozenModeTimeGet

Prototype
G_UINT64 gu_FrozenModeTimeGet(void);  /* reads FRZ_TM register pair */

Description: gu_FrozenModeTimeGet returns the accumulated time the system was in Frozen Mode. This time is hold in the R_FRZ_CNT register of the GeMRTOS controller.

Parameters
The gu_FrozenModeTimeGet function has no parameter.

Returns
The gu_FrozenModeTimeGet function returns the accumulated time the system was in Frozen Mode, hold in the the R_FRZ_CNT register of the GeMRTOS controller.

Thread-safety
Safe from task context.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_FrozenModeDisable
gm_FrozenModeEnable
gm_GatedClockDisable
gm_GatedClockEnable
gm_StatusFrozenModeEnableGet
gm_SystemReset
gm_TimeCountersReset
gm_TimeCountersHold
gm_TimeCountersUnhold
gm_TimeCountersUnreset
gu_FrozenModeThresholdGet
gu_FrozenModeThresholdSet
__________________________________________________________________

2.16 gm_IrqDisable

Prototype
static inline void gm_IrqDisable(G_UINT32 irq);

Description: The gm_IrqDisable function disables the specified device interrupt request event (IRQ) in the GeMRTOS controller. The gm_IrqEnable(irq)function enables the irq external interrupt in the GeMRTOS controller. This function is essential for managing interrupt handling and preventing specified DIRQs from triggering.

Parameters
The gm_IrqDisable function accepts the following parameter:

Returns
The gm_IrqDisable function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined behavior if irq is out of range [1, ALT_NIRQ].

Preconditions
GeMRTOS mutex must be held. irq must be a valid IRQ index.

Postconditions
The specified device interrupt request is disabled in the GeMRTOS controller.

See also
gm_IrqEnable
gk_NextOccTimeProcessor
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_TriggerPrcIRQ
__________________________________________________________________

2.17 gm_IrqEnable

Prototype
static inline void gm_IrqEnable(G_UINT32 irq);

Description: The gm_IrqEnable function enables the specified device interrupt request event (DIRQ) in the GeMRTOS controller. This function is crucial for allowing specified DIRQ to trigger. The gm_IrqDisable(irq)function disables the irq external interrupt in the GeMRTOS controller.

Parameters
The gm_IrqEnable function accepts the following parameter:

Returns
The gm_IrqEnable function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined behavior if irq is out of range.

Preconditions
GeMRTOS mutex must be held. A trigger must be associated with this IRQ via gu_TriggerCreate.

Postconditions
The specified device interrupt request will trigger a processor interrupt when the device asserts it.

See also
gm_IrqDisable
gk_NextOccTimeProcessor
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
gm_TriggerPrcIRQ
__________________________________________________________________

2.18 gk_NextOccTimeProcessor

Prototype
void gk_NextOccTimeProcessor(void);  /* kernel-internal, static inline */

Description: The gk_NextOccTimeProcessor function reads the Kernel Control Block to determine which processor is associated with the next occurrence-time task, then sets the Next Occurrence Time Processor field in the GRTOS controller (or 0 if no such task is executing). Kernel-internal: not part of the public API, must be called with the mutex already held.

Parameters
None.

Returns
The gk_NextOccTimeProcessor function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined behavior if processor is not a valid CPUID.

Preconditions
GeMRTOS mutex must be held.

Postconditions
The GeMRTOS controller knows which processor executes the next timed event; it will interrupt that processor when the event occurs.

See also
gm_IrqDisable
gm_IrqEnable
gm_TriggerPrcIRQ
__________________________________________________________________

2.19 gm_TriggerPrcIRQ

Prototype
static inline void gm_TriggerPrcIRQ(G_UINT32 proc);

Description: The gm_TriggerPrcIRQ function interrupts the processor proc. If proc interrupt is enabled in the GRTOS controller, then the processor is interrupted.

Parameters
The gm_TriggerPrcIRQ function accepts the following parameter:

Returns
The gm_TriggerPrcIRQ function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined behavior if proc is not a valid CPUID.

Preconditions
GeMRTOS mutex must be held. Target processor must have interrupts enabled.

Postconditions
The target processor is interrupted and enters its interrupt handler.

See also
gm_IrqDisable
gm_IrqEnable
gk_NextOccTimeProcessor
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.20 gu_MessageQueueCreate

Prototype
GS_RCB *gu_MessageQueueCreate(void);

Description: The gu_MessageQueueCreate function creates a new message queue resource. This resource is implemented using a GS_RCB structure, extended with fields from aT_QUEUE_RESOURCEstructure. The created queue includes event lists for producers (waiting to send) and MQreceivers (waiting to receive) messages. Producer tasks add themselves to the producer event list when they are waiting to send a message. This function can be called from either the main application code or from within a task. If called within a task, it must be called before any message send or receive operations; otherwise, an error will occur.

Parameters
The gu_MessageQueueCreate function takes no parameters.

Returns
The gu_MessageQueueCreate function returns a pointer ( GS_RCB *) to the newly created message queue resource. This pointer is essential for all subsequent operations in the queue. A NULL pointer is returned if there is insufficient memory to create the queue or if no more queue resources are available.

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free RCB is available.

Preconditions
GeMRTOS must be initialized.

Postconditions
A new message queue RCB is allocated. Subscribers must be added with gu_MessageQueueSubscribe before sending.

See also
gu_MessageQueuePrintf
gu_MessageQueueReceive
gu_MessageQueueSend
gu_MessageQueueSubscribe
__________________________________________________________________

2.21 gu_MessageQueuePrintf

Prototype
G_Status gu_MessageQueuePrintf(GS_RCB *prcb, const char *format, ...);

Description: The gu_MessageQueuePrintf function sends a formatted message to a message queue. The calling task will block until the message is successfully delivered to all MQreceivers subscribed to the queue.

Parameters
The function accepts the following parameters:

Returns
G_OK if at least one receiver took the message; G_ERR otherwise.

Thread-safety
Safe from task context.

Error conditions
G_ERR: the queue has no subscriber, no event was free to queue the message, or nothing was delivered.

Preconditions
prcb must point to a valid message queue RCB created by gu_MessageQueueCreate.

Postconditions
A formatted string message is enqueued for delivery to all subscribers.

See also
gu_MessageQueueCreate
gu_MessageQueueReceive
gu_MessageQueueSend
gu_MessageQueueSubscribe
__________________________________________________________________

2.22 gu_MessageQueueReceive

Prototype
int gu_MessageQueueReceive(GS_RCB *prcb);

Description: The gu_MessageQueueReceive function retrieves the next message from a message queue. The calling task must have previously subscribed to the queue using gu_MessageQueueSubscribe. The received message is copied into the buffer specified by buffer_msg. If the message is larger than buffer_length, it will be truncated to fit the buffer.

Parameters
The function takes three parameters:

Returns
The gu_MessageQueueReceive function returns an integer representing the number of bytes actually received. This value may be less than buffer_length if the received message was shorter than the buffer or if the message was truncated due to buffer size limitations.

Thread-safety
Task context only; blocks until a message arrives.

Error conditions
Returns 0 if timeout or no message; returns message length on success.

Preconditions
The calling task must have subscribed via gu_MessageQueueSubscribe. buffer_msg must point to a buffer of at least buffer_length bytes.

Postconditions
The message is copied into buffer_msg; the task resumes.

See also
gu_MessageQueueCreate
gu_MessageQueuePrintf
gu_MessageQueueReceiveTimeout
gu_MessageQueueSend
gu_MessageQueueSubscribe
__________________________________________________________________

2.23 gu_MessageQueueReceiveTimeout

Prototype
int gu_MessageQueueReceiveTimeout(GS_RCB *prcb, G_UINT64 timeout);

Description: The gu_MessageQueueReceiveTimeout function retrieves the next message from a message queue, waiting for it no longer than timeout. It is gu_MessageQueueReceive with a bounded wait; a message that is already pending is returned at once. The calling task must have previously subscribed to the queue using gu_MessageQueueSubscribe. If the message is larger than the subscription buffer, it is truncated to fit the buffer.

Parameters
The function takes two parameters:

Returns
As gu_MessageQueueReceive: the number of bytes actually received, or G_ERR_RECEIVE_ABORT if the receive was aborted; plus G_ERR_RECEIVE_TIMEOUT when no message arrived within the time-out. The calling task stays subscribed and loses no message when the time-out expires.

Thread-safety
Task context only; blocks until a message arrives or the time-out expires.

Error conditions
Returns G_ERR_RECEIVE_TIMEOUT if no message arrived in time; returns G_ERR_RECEIVE_NOT_SUBSCRIBED if the calling task has not subscribed to the queue.

Preconditions
The calling task must have subscribed via gu_MessageQueueSubscribe.

Postconditions
On success the message is copied into the subscription buffer and the task resumes. On time-out the task resumes without a message and may call the function again.

See also
gu_MessageQueueReceive
gu_MessageQueueSend
gu_MessageQueueSubscribe
__________________________________________________________________

2.24 gu_MessageQueueSend

Prototype
int gu_MessageQueueSend(GS_RCB *prcb, const char *pmsg, int msg_length, G_UINT64 timeout);

Description: The gu_MessageQueueSend function transmits a message to a message queue. The sending task blocks until the message has been successfully delivered to all subscribed MQreceivers or until a timeout occurs.

Parameters
The function uses the following parameters:

Returns
The number of receivers that got the message (positive) when it was delivered before the timeout; minus the number of receivers that already had it (zero or negative) when the timeout was served first.

Thread-safety
Safe from task context.

Error conditions
The result is a count, not a status code. 0 does not tell the cases apart: refused arguments, no subscriber, no free event or request block, or timeout before any receiver took the message. A caller that needs delivery in time tests for a positive result.

Preconditions
prcb must be a valid queue. pmsg must not be NULL. msg_length must be positive.

Postconditions
Message is delivered to all active subscribers; sender blocks until all consumers receive it or timeout expires.

See also
gu_MessageQueueCreate
gu_MessageQueuePrintf
gu_MessageQueueReceive
gu_MessageQueueSubscribe
__________________________________________________________________

2.25 gu_MessageQueueSubscribe

Prototype
GS_ECB *gu_MessageQueueSubscribe(GS_TCB *ptcb, GS_RCB *presource, void *buffer_msg, G_UINT32 buffer_length);

Description: The gu_MessageQueueSubscribe function subscribes the task to a message queue resource. This subscription is crucial for message delivery; a consumer task must be subscribed to a queue before it can receive messages using gu_MessageQueueReceive. Furthermore, the execution of this function for each receiving task allows the message queue to track the number of MQreceivers subscribed. This count is essential for producers; a producer message is only considered fully delivered when it has been received by every subscribed consumer. The message queue must have been previously created using gu_MessageQueueCreate.

Parameters
The function uses the following parameters:

Returns
The gu_MessageQueueSubscribe function returns a pointer to theGS_ECBstructure associated with the message queue resource. A NULL return value likely indicates an error.

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free ECB is available.

Preconditions
ptcb and presource must be valid pointers. Typically called before the queue is used.

Postconditions
The task is registered as a consumer; it will receive all future messages sent to the queue.

See also
gu_MessageQueueCreate
gu_MessageQueuePrintf
gu_MessageQueueReceive
gu_MessageQueueSend
__________________________________________________________________

2.26 gm_PrcInterruptDisable

Prototype
static inline void gm_PrcInterruptDisable(void);

Description: The gm_PrcInterruptDisable function disables the processor interrupt from the GeMRTOS controller.

Parameters
The gm_PrcInterruptDisable function does not require any parameters.

Returns
The gm_PrcInterruptDisable function does not return any value; it writes the processor interrupt-disable bit directly and returns immediately.

Thread-safety
Affects only the calling processor’s interrupt enable in the GeMRTOS controller.

Error conditions
None.

Preconditions
None.

Postconditions
The GeMRTOS controller will not generate processor interrupt requests for the calling processor.

See also
gm_PrcInterruptEnable
gm_ProcessorHalt
gm_ProcessorId
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.27 gm_PrcInterruptEnable

Prototype
static inline void gm_PrcInterruptEnable(void);

Description: The gm_PrcInterruptEnable function enables the processor interrupt from the GeMRTOS controller.

Parameters
The gm_PrcInterruptEnable function does not require any parameters.

Returns
The gm_PrcInterruptEnable function does not return any value; it writes the processor interrupt-enable bit directly and returns immediately.

Thread-safety
Affects only the calling processor.

Error conditions
None.

Preconditions
None.

Postconditions
The GeMRTOS controller is enabled to interrupt the calling processor on events.

See also
gm_PrcInterruptDisable
gm_ProcessorHalt
gm_ProcessorId
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.28 gm_ProcessorHalt

Prototype
void gm_ProcessorHalt;

Description: The gm_ProcessorHalt macro places the processor into halt mode, effectively stopping its execution until an interrupt is issued for this processor by the GeMRTOS controller. This mode is often used to conserve power or to wait for external events before resuming normal operation. When G_DEBUG_WAITING_LOOP is defined equal to 0, gm_ProcessorHalt is implemented by arming the idle-halt latch (gm_HaltIdlePrcSet, PRC_IDL_ENB_BIT of ADDR_REG_1) and then writing a 1 to PRC_HLT_ENB_BIT of ADDR_REG_0 in the processor memory of the GeMRTOS controller: the controller answers that write with the waitrequest signal, stalling the processor until it is interrupted or granted the mutex. When G_DEBUG_WAITING_LOOP is defined not equal to 0, gm_ProcessorHalt is implemented as a waiting loop reading the the wait bit of ADDR_REG_0 address in the processor memory of the GeMRTOS controller in order to be complilance with debugging tools that does not support processor halted with waitrequest signal.

Parameters
The gm_ProcessorHalt macro does not require any parameters.

Returns
The gm_ProcessorHalt macro returns control to the calling function when the processor is interrupted and the ISR routine executed, allowing it to resume execution.

Thread-safety
Halts the calling processor; execution resumes on next interrupt.

Error conditions
None.

Preconditions
None.

Postconditions
Processor is in halt/idle state until the next interrupt fires.

See also
gm_PrcInterruptDisable
gm_PrcInterruptEnable
gm_ProcessorId
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.29 gm_ProcessorId

Prototype
static inline G_UINT32 gm_ProcessorId(void);

Description: The gm_ProcessorId function retrieves the ID of the current processor. This function is useful for identifying the processor.

Parameters
The gm_ProcessorId function does not accept any parameters.

Returns
The gm_ProcessorId function returns the ID of the current processor.

Thread-safety
Safe to call from any context; reads a processor-specific register.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_PrcInterruptDisable
gm_PrcInterruptEnable
gm_ProcessorHalt
gm_ProcessorInterrupt
gu_ProcessorWaitForIrq
__________________________________________________________________

2.30 gm_ProcessorInterrupt

Prototype
static inline void gm_ProcessorInterrupt(G_UINT32 proc);

Description: gm_ProcessorInterrupt issues an interrupt for the processor with the specified ID and waits until it reaches the ISR and disables its interrupt in the GeMRTOS controller.

Parameters
The gm_ProcessorInterrupt function accepts the following parameter:

Returns
The gm_ProcessorInterrupt function returns when the target processor disables its interrupt in the GeMRTOS controller.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined if proc is an invalid CPUID.

Preconditions
GeMRTOS mutex must be held. Target processor must be running and have interrupts enabled.

Postconditions
The target processor is interrupted; the caller waits until the target enters its IRQ handler.

See also
gm_PrcInterruptDisable
gm_PrcInterruptEnable
gm_ProcessorHalt
gm_ProcessorId
gu_ProcessorWaitForIrq
__________________________________________________________________

2.31 gu_ProcessorWaitForIrq

Prototype
static inline G_UINT32 gu_ProcessorWaitForIrq(G_UINT32 irq_mask);

Description: Halts the calling processor, with no busy loop, until one of the DIRQs named in irq_mask is asserted, then returns it to normal task scheduling. Useful for a user task or driver that wants to wait on a specific interrupt subset, rather than the kernel’s own generic gm_ProcessorHalt, which halts until any interrupt. See §?? for the full register-level design, including why no per-processor claim or ownership state is needed in the controller even when several processors wait on the same DIRQ.

Parameters
irq_mask — mask of the DIRQs to wait for; bit k selects external IRQ k. Every DIRQ named in the mask must already be disabled (gm_IrqDisable) before this call: the controller releases the wait from the raw, unsynchronised DIRQ line, not the normal enabled/vectored interrupt path – this is also what guarantees the same event is never delivered as an ordinary interrupt to a different processor while this one is waiting on it. Bit PRC_HLT_ENB_BIT (bit 0) of the underlying ADDR_REG_0 write selects gm_ProcessorHalt instead of this wait, so the function always clears bit 0 of irq_mask itself before the write – IRQ 0 (the system timer) can therefore never be named. A mask of all zero, after that bit is cleared, is ignored by the controller: it never halts.

Returns
The masked, currently-asserted subset of irq_mask: (irq_mask with bit 0 cleared) AND the raw synchronised DIRQ-line register DIRQI_synch (read via gm_GetDIRQI(), ADDR_DIRQI, the controller’s testing region – an internal accessor, not itself a documented API entry), sampled immediately after the wait resolves. Nonzero identifies which awaited DIRQ(s) are asserted right now; 0 means none of them is – the wait ended for another reason (for example, one of them was enabled instead of arriving). ADDR_IRQ_RQS/R_IRQ_PND is deliberately not used for this: that register is gated by IRQ enable and never sets for a disabled DIRQ, the precondition this function requires (§??).

Thread-safety
Manages the GeMRTOS Mutex internally (enters and exits its own critical section) – the defining trait of a gu_ function (§??). Renamed from a gm_ProcessorWaitForIrq macro on 2026-08-16 for exactly this reason: unlike a gm_ primitive, it must not be called with the mutex already held.

Error conditions
None reported to the caller. Naming a DIRQ that is not disabled – or one that is already enabled or already pending – is a misuse the controller does not detect from software; §?? gives the exact release condition for that case.

Preconditions
Every DIRQ named in irq_mask must already be disabled (gm_IrqDisable). Must not be called from within a critical section.

Postconditions
On return, one of the masked DIRQs has been asserted (or the mask was empty, in which case the call is an immediate no-op). This processor’s PCB has already been restored to GS_PCBType_AVAILABLE and re-entered into scheduling (gk_SetLowestProcessor()) – the caller does not need to do either.

See also
gm_IrqDisable
gm_IrqEnable
gm_PrcInterruptDisable
gm_PrcInterruptEnable
gm_ProcessorHalt
gm_ProcessorId
gm_ProcessorInterrupt
__________________________________________________________________

2.32 gu_SchedulingListAssociateProcessor

Prototype
G_Status gu_SchedulingListAssociateProcessor(GS_LCB *plcb, G_UINT32 cpu_id, G_UINT32 priority);

Description: The gu_SchedulingListAssociateProcessor function associates a system processor with a specified scheduling list. The priority is assigned to the association between the processor and the scheduling list. When tasks are ready to execute, the processor will select and execute the task from the highest priority scheduling list that it is associated with. The association with the lowest numerical value indicates the highest priority, ensuring that tasks in the most critical scheduling lists are prioritized for execution.

Parameters
The following parameters are required for the gu_SchedulingListAssociateProcessor function:

Returns
G_OK if the processor was associated with the list.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if plcb is not a valid scheduling list or cpu_id is out of range (1 to the number of processors). G_ERR_NO_MEMORY if no association block is free. G_ERR_STATE if the processor is already associated with that list, at any priority; nothing is changed.

Preconditions
plcb must have been created by gu_SchedulingListCreate. cpu_id must be a valid processor ID.

Postconditions
The processor with the given cpu_id will service tasks in plcb at the specified priority.

See also
gu_SchedulingListAssociateTask
gu_SchedulingListCreate
gu_SchedulingListExclusionSet
__________________________________________________________________

2.33 gu_SchedulingListAssociateTask

Prototype
G_Status gu_SchedulingListAssociateTask(struct gs_tcb *ptcb, struct gs_lcb *plcb);

Description: The gu_SchedulingListAssociateTask function assigns a task to a specific scheduling list. Once assigned, the task will be scheduled according to the priority discipline defined for that scheduling list.

Parameters
The function accepts two parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if plcb is not a valid scheduling list or ptcb is not a valid task.

Preconditions
Both ptcb and plcb must be valid. Task should be in Waiting state.

Postconditions
The task is assigned to the scheduling list; it will compete for processors associated with that list.

See also
gu_SchedulingListAssociateProcessor
gu_SchedulingListCreate
gu_SchedulingListExclusionSet
__________________________________________________________________

2.34 gu_SchedulingListCreate

Prototype
GS_LCB *gu_SchedulingListCreate(enum lcbtype lcb_type);

Description: The gu_SchedulingListCreate function creates a new scheduling list. The type of scheduling discipline used by the list is determined by the lcbtype parameter.

Parameters
The function accepts one parameter:

Returns
The gu_SchedulingListCreate function returns a pointer (GS_LCB*) to the newly createdGS_LCBstructure. This pointer is essential for all subsequent operations involving this specific scheduling list. A '(GS_LCB*) 0' return value indicates failure to create the scheduling list.

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free LCB is available.

Preconditions
lcbtype must be GS_LCBTypeFP (fixed priority) or GS_LCBTypeEDF (earliest deadline first).

Postconditions
A new scheduling list is allocated and linked into the kernel LCB list.

See also
gu_SchedulingListAssociateProcessor
gu_SchedulingListAssociateTask
gu_SchedulingListExclusionSet
__________________________________________________________________

2.35 gu_SchedulingListExclusionSet

Prototype
G_Status gu_SchedulingListExclusionSet(GS_LCB *plcb, G_UINT32 exclusion);

Description: The gu_SchedulingListExclusionSet function sets the exclusion level for a scheduling list. The exclusion level limits the number of tasks from that list that can be simultaneously in the execution state. This mechanism can be used for load balancing or to ensure real-time properties by protecting against multiprocessor anomalies. Setting the exclusion to 1 can help safeguard real-time task scheduling from anomalies within the scheduling list.

Parameters
The function accepts two parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if plcb is not a valid scheduling list.

Preconditions
plcb must be a valid scheduling list. exclusion must be ≥ 0 (0 means no limit).

Postconditions
At most exclusion processors may simultaneously execute tasks from this list (prevents real-time anomalies).

See also
gu_SchedulingListAssociateProcessor
gu_SchedulingListAssociateTask
gu_SchedulingListCreate
__________________________________________________________________

2.36 gu_SemaphoreCreateBinary

Prototype
GS_RCB *gu_SemaphoreCreateBinary(G_UINT32 initial_count);

Description: Creates a binary semaphore, and returns a handle by which the semaphore can be referenced. The semaphore is created in the 'empty' state, meaning the semaphore must first be given using the gu_SemaphoreGive()

Parameters
The following parameter is required.

Returns
If the semaphore is created successfully then a handle to the semaphore is returned, NULL otherwise

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free RCB is available.

Preconditions
None.

Postconditions
A binary semaphore (initial count 1) is allocated. Use gu_SemaphoreTake/gu_SemaphoreGive to operate it.

See also
gu_SemaphoreCreateMutex
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGetCount
gu_SemaphoreGive
gu_SemaphoreTake
__________________________________________________________________

2.37 gu_SemaphoreCreateMutex

Prototype
GS_RCB *gu_SemaphoreCreateMutex(void);

Description: Creates a mutex, and returns a handle by which the created mutex can be referenced. Mutexes are taken using gu_SemaphoreTake(), and given using gu_SemaphoreGive().

Parameters
The function takes no parameters.

Returns
If the mutex type semaphore was created successfully then a handle to the created mutex is returned, NULL otherwise

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free RCB is available.

Preconditions
None.

Postconditions
A non-recursive mutex semaphore is allocated with initial count 1.

See also
gu_SemaphoreCreateBinary
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGetCount
gu_SemaphoreGive
gu_SemaphoreTake
__________________________________________________________________

2.38 gu_SemaphoreCreateRecursiveMutex

Prototype
GS_RCB *gu_SemaphoreCreateRecursiveMutex(void);

Description: Creates a recursive mutex, and returns a handle by which the mutex can be referenced. Recursive mutexes are 'taken' (obtained) using the gu_SemaphoreTakeRecursive() and given (released) using the gu_SemaphoreGiveRecursive() API functions respectively.

Parameters
The function takes no parameters.

Returns
If the mutex type semaphore was created successfully then a handle to the created mutex is returned, NULL otherwise

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free RCB is available.

Preconditions
None.

Postconditions
A recursive mutex is allocated; the same task may take it multiple times without deadlock.

See also
gu_SemaphoreCreateBinary
gu_SemaphoreCreateMutex
gu_SemaphoreGetCount
gu_SemaphoreGive
gu_SemaphoreTake
__________________________________________________________________

2.39 gu_SemaphoreGetCount

Prototype
G_UINT32 gu_SemaphoreGetCount(const GS_RCB *presource);

Description: Returns the count of a semaphore. The semaphore must have previously been created with a call to gu_SemaphoreCreateBinary(), gu_SemaphoreCreateMutex()orgu_SemaphoreCreateCounting().

Parameters
The function takes the following parameters.

Returns
If the semaphore is a counting semaphore then the semaphores current count value is returned. If the semaphore is a binary semaphore then 1 is returned if the semaphore is available, and 0 is returned if the semaphore is not available.

Thread-safety
Read-only; consistent result requires holding the mutex.

Error conditions
Undefined if presource is NULL.

Preconditions
presource must be a valid semaphore RCB.

Postconditions
None.

See also
gu_SemaphoreCreateBinary
gu_SemaphoreCreateMutex
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGive
gu_SemaphoreTake
__________________________________________________________________

2.40 gu_SemaphoreGive

Prototype
G_Status gu_SemaphoreGive(GS_RCB *presource);

Description: The gu_SemaphoreGive function releases a semaphore or mutex previously acquired. If tasks are waiting to acquire the resource, the highest-priority waiting task will be granted the resource. If no tasks are waiting, the semaphore's internal count is incremented.

Parameters
The function accepts one parameter:

Returns
G_OK if the semaphore was released.

Thread-safety
Safe from task context.

Error conditions
G_ERR_STATE if the caller does not hold the mutex, or the count of a binary or counting semaphore is already at its maximum. G_ERR_PARAM if the handle is not a semaphore.

Preconditions
presource must be a valid semaphore. The calling task should currently hold the semaphore (for mutex use).

Postconditions
The semaphore is released (a recursive mutex once every take has been given back) and the highest-priority waiting task, if any, is granted it.

See also
gu_SemaphoreCreateBinary
gu_SemaphoreCreateMutex
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGetCount
gu_SemaphoreTake
__________________________________________________________________

2.41 gu_SemaphoreTake

Prototype
G_Status gu_SemaphoreTake(GS_RCB *presource, G_UINT64 ticks_to_wait);

Description: Acquires a semaphore or mutex. If its count is greater than zero it is granted at once. Otherwise the calling task waits at most ticks_to_wait system time units: 0 returns immediately and G_LATEST_TIME waits indefinitely. A task that already holds a recursive mutex takes it again.

Parameters
The function uses the following parameters:

Returns
G_OK if the semaphore was granted, at once or after waiting.

Thread-safety
Task context only; may block.

Error conditions
G_ERR_TIMEOUT if it was not available within ticks_to_wait (also with ticks_to_wait 0). G_ERR_NO_MEMORY if the event pool is empty. G_ERR_STATE if the caller already holds a non-recursive mutex. G_ERR_PARAM if the handle is not a semaphore.

Preconditions
Must be called from a task. presource must be a valid semaphore RCB.

Postconditions
On G_OK the caller holds the mutex, or the count of the semaphore has been decremented.

See also
gu_SemaphoreCreateBinary
gu_SemaphoreCreateMutex
gu_SemaphoreCreateRecursiveMutex
gu_SemaphoreGetCount
gu_SemaphoreGive
__________________________________________________________________

2.42 gu_SignalCreate

Prototype
GS_SCB *gu_SignalCreate(enum scbtype type, G_UINT32 priority, void *pxcb, G_TaskCode signal_code, void *signal_arg);

Description: The gu_SignalCreate function creates a signal of a specified type and associates it with a task or other system entity. The signal's priority determines its execution order when multiple signals are pending.

Parameters
The function takes the following parameters:

Returns
The gu_SignalCreate function returns a pointer to the newly createdGS_SCBstructure. A NULL return indicates failure.

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free SCB is available.

Preconditions
Signal_Code must be a valid function pointer. pxcb must point to the control block (TCB, RCB, ECB, or KCB) to associate the signal with.

Postconditions
A signal is created and linked to the specified control block. It executes Signal_Code when the signal condition occurs.

See also
gu_SignalDestroy
__________________________________________________________________

2.43 gu_SignalDestroy

Prototype
G_Status gu_SignalDestroy(GS_SCB *pscb);

Description: The gu_SignalDestroy function removes a signal from a control block. This disassociates the signal from its associated task or system entity, preventing further execution of the signal's handler.

Parameters
The function accepts one parameter:

Returns
G_OK on success.

Thread-safety
Safe from task context.

Error conditions
G_ERR_PARAM if pscb is not a valid signal. G_ERR_STATE if the signal is not linked to a task or to the kernel, for example when it was already destroyed.

Preconditions
pscb must be a valid signal control block previously created.

Postconditions
The signal is unlinked from its associated control block and its SCB is returned to the free pool.

See also
gu_SignalCreate
__________________________________________________________________

2.44 gm_ERETAddressSet

Prototype
static inline void gm_ERETAddressSet(G_UINT32 value);

Description: The gm_ERETAddressSet function writes R_ERET_REG, the controller register (written through the Global Region, ADDR_CTRL_STATUS) that holds an offset in the GeMRTOS code-memory region. When a processor reads that offset, it is executing the return from the GeMRTOS critical section and consequently the GeMRTOS controller Mutex is released, if it is not nested.

Parameters
The gm_ERETAddressSet has no parameter.

Returns
The gm_ERETAddressSet function does not return any value.

Thread-safety
Kernel use only; must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held. For kernel initialization only.

Postconditions
When the processor reads this address, the GeMRTOS controller automatically releases the mutex (unless nested).

See also
gm_MutexNestedValue
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_fprintf
gu_printf
__________________________________________________________________

2.45 gm_MutexNestedValue

Prototype
static inline void gm_MutexNestedValue(G_UINT32 data);

Description: The gm_MutexNestedValue function sets the GeMRTOS controller Mutex nested parameter according to the value. If value is equal to 0, the Mutex is released next time a released is performed. Otherwise, if value is not 0, the the Mutex is not released.

Parameters
The gm_MutexNestedValue has one parameter:

Returns
The gm_MutexNestedValue function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
Mutex nesting behavior updated; allows the same processor to re-enter the critical section without deadlock when value > 0.

See also
gm_ERETAddressSet
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_fprintf
gu_printf
__________________________________________________________________

2.46 gm_ReadInputs

Prototype
static inline G_UINT32 gm_ReadInputs(void);

Description: The gm_ReadInputs function transfer the data from the gemrtos_phy input conduit of GeMRTOS controller.

Parameters
The gm_ReadInputs function does not require any parameter.

Returns
The gm_ReadInputs does returns the data from the gemrtos_phy input conduit of GeMRTOS controller.

Thread-safety
Read-only; safe within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex should be held for a consistent read.

Postconditions
None.

See also
gm_ERETAddressSet
gm_MutexNestedValue
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_fprintf
gu_printf
__________________________________________________________________

2.47 gm_StatusFrozenModeActiveGet

Prototype
static inline G_UINT32 gm_StatusFrozenModeActiveGet(void);

Description: gm_StatusFrozenModeActiveGet returns the status of the frozen mode event (G_TRUE if active, G_FALSE if inactive).

Parameters
gm_StatusFrozenModeActiveGet has no parameter.

Returns
The gm_StatusFrozenModeActiveGet function returns G_TRUE if the frozen mode event is active, G_FALSE if inactive.

Thread-safety
Read-only.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_ERETAddressSet
gm_MutexNestedValue
gm_ReadInputs
gm_WriteOutputs
gu_fprintf
gu_printf
__________________________________________________________________

2.48 gm_WriteOutputs

Prototype
static inline void gm_WriteOutputs(G_UINT32 data);

Description: The gm_WriteOutputs function transfer the data input to the gemrtos_phy output conduit of GeMRTOS controller.

Parameters
The gm_WriteOutputs function requires the following parameter:

Returns
The gm_WriteOutputs function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
The INOUTS register output bits are updated with data.

See also
gm_ERETAddressSet
gm_MutexNestedValue
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gu_fprintf
gu_printf
__________________________________________________________________

2.49 gu_fprintf

Prototype
void gu_fprintf(const char *format, ...);

Description: The gu_fprintf function formats text and writes it to standard error output (stderr).

Parameters
The following parameter is required for the gu_fprintf function:

Returns
None. The gu_fprintf function returns void.

Thread-safety
Thread-safe. Serialized by the global GeMRTOS mutex, which the function acquires and releases around the write, so a message is never interleaved with output from another processor.

Blocking behaviour
Never blocks, in any build configuration. The JTAG UART is shared by every processor and a console write necessarily holds the global mutex, so a blocking write would stall the whole system — see Section ??.

Error conditions
None returned. Output that the JTAG UART FIFO cannot accept while the host is not draining it is discarded rather than waited for; discarded bytes are counted. See Section ??.

Preconditions
JTAG UART for STDERR must be included in the Platform Designer project.

Postconditions
Formatted string sent to STDERR JTAG UART.

See also
gm_ERETAddressSet
gm_MutexNestedValue
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_printf
__________________________________________________________________

2.50 gu_printf

Prototype
void gu_printf(const char *format, ...);

Description: The gu_printf function formats text and writes it to standard output.

Parameters
The following parameter is required for the gu_printf function:

Returns
None. The gu_printf function returns void.

Thread-safety
Thread-safe. Serialized by the global GeMRTOS mutex, which the function acquires and releases around the write, so a message is never interleaved with output from another processor.

Blocking behaviour
Never blocks, in any build configuration. The JTAG UART is shared by every processor and a console write necessarily holds the global mutex, so a blocking write would stall the whole system — see Section ??.

Error conditions
None returned. Output that the JTAG UART FIFO cannot accept while the host is not draining it is discarded rather than waited for; discarded bytes are counted. See Section ??.

Preconditions
JTAG UART for STDIO must be included in the Platform Designer project.

Postconditions
Formatted string sent to STDIO JTAG UART.

See also
gm_ERETAddressSet
gm_MutexNestedValue
gm_ReadInputs
gm_StatusFrozenModeActiveGet
gm_WriteOutputs
gu_fprintf
__________________________________________________________________

2.51 gu_TaskCreate

Prototype
void *gu_TaskCreate(G_TaskCode task_code, void *p_arg, const char *format, ...);

Description: The gu_TaskCreate function creates a task with default settings and returns a pointer to its GS_TCB structure.Taskparameters can be modified before creation by adjusting default settings or after creation using task-related functions. While the function requires only TaskCode and p_arg, it allows for optional task description formatting using a printf-style format string and arguments.

Parameters
The function uses the following parameters:

Returns
The gu_TaskCreate function returns a pointer to the GS_TCB structure of the newly created task. This pointer should be used in all subsequent calls related to that task. A NULL return indicates task creation failure.

Thread-safety
Safe from main() or task context.

Error conditions
Returns NULL if no free TCB or stack memory is available.

Preconditions
GeMRTOS must be initialized. TaskCode must be a valid function pointer. Stack size is set by the G_TASK_STACKSIZE compile-time constant (default 4096 bytes).

Postconditions
A new TCB is allocated; task is placed in Waiting state. Call gu_TaskTypeSet, gu_SchedulingListAssociateTask, and gu_TaskReadyPrioritySet to configure it before its first release.

See also
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.52 gu_TaskCreateNamed

Prototype
void *gu_TaskCreateNamed(G_TaskCode task_code, void *p_arg, const char *name);

Description: Creates a task like gu_TaskCreate, but takes the task description as a plain string instead of a printf-style format with variable arguments. It is the function the kernel itself uses, and the one to prefer when the name is a constant.

Parameters
task_code: the task function. p_arg: the argument passed to it. name: the description, copied as plain text and cut at the description size; NULL gives an empty description.

Returns
A pointer to the GS_TCB of the new task, or NULL.

Error conditions
Returns NULL if no free TCB or stack memory is available.

See also
gu_TaskCreate __________________________________________________________________

2.53 gu_TaskDelay

Prototype
G_Status gu_TaskDelay(G_UINT32 hours, G_UINT32 minutes, G_UINT32 seconds, G_UINT32 ms);

Description: The gu_TaskDelay function suspends the execution of the currently running task for a specified time interval. This function is useful within the infinite loop of a task to create periodic behavior.

Parameters
The function uses the following parameters to define the sleep interval:

Returns
G_OK once the delay has elapsed.

Thread-safety
Task context only; suspends the calling task.

Error conditions
G_ERR_NO_MEMORY if the event pool is empty; the task is then not delayed.

Preconditions
Must be called from a task. The time arguments must form a valid duration (e.g., seconds < 60).

Postconditions
Calling task is moved to Waiting state and released after the specified duration.

See also
gu_TaskCreate
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.54 gu_TaskDelayTime

Prototype
G_Status gu_TaskDelayTime(gt_time ticks);

Description: The gu_TaskDelayTime function suspends the execution of the current task for a specified number of system clock ticks. This function provides a more direct way to specify sleep duration compared to gu_TaskDelay, using the system's time units directly.

Parameters
The function takes one parameter:

Returns
G_OK once the delay has elapsed.

Thread-safety
Task context only.

Error conditions
G_ERR_NO_MEMORY if the event pool is empty; the task is then not delayed.

Preconditions
Must be called from a task.

Postconditions
Calling task is suspended for ticks system-time units.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.55 gu_TaskGetCurrentTCB

Prototype
GS_TCB *gu_TaskGetCurrentTCB(void);

Description: The gu_TaskGetCurrentTCB function retrieves a pointer to theTaskControl Block ( GS_TCB ) of the currently executing task.

Parameters
This function takes no parameters.

Returns
The gu_TaskGetCurrentTCB function returns a pointer to the GS_TCB structure of the currently running task.

Thread-safety
Safe from task context.

Error conditions
Returns NULL if called from initialization context before any task is running.

Preconditions
None.

Postconditions
None.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.56 gu_TaskKill

Prototype
G_Status gu_TaskKill(GS_TCB *ptcb);

Description: The gu_TaskKill function terminates a task and releases all associated resources, returning them to the free lists.

Parameters
The function takes one parameter:

Returns
G_OK if the task was destroyed.

Thread-safety
Safe from task context.

Error conditions
G_ERR_PARAM if ptcb is not a valid task. G_ERR_STATE if ptcb is the calling task or the task cannot be destroyed in its present condition.

Preconditions
ptcb is a valid task other than the caller. Killing a task that holds a mutex may cause deadlock; release its resources first.

Postconditions
The task is destroyed in any state; its TCB and stack are freed.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.57 gu_TaskPeriodSet

Prototype
G_Status gu_TaskPeriodSet(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms);

Description: The gu_TaskPeriodSet function sets the period for the next invocation of a task. The current task invocation period remains unaffected; the new period will apply only to subsequent invocations.

Parameters
The function uses the following parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task or the period is zero.

Preconditions
ptcb must be valid. Task type should be G_TCBType_Periodic (or G_TCBType_Periodic_Skip).

Postconditions
The task period is updated; the next release time is recalculated.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.58 gu_TaskReadyPrioritySet

Prototype
G_Status gu_TaskReadyPrioritySet(struct gs_tcb *ptcb, G_UINT64 priority);

Description: The gu_TaskReadyPrioritySet function sets the ready priority of a task. This priority determines the task's position in the ready queue and influences its scheduling order. Note that larger values of priority represent lower priority; smaller values indicate higher priority.

Parameters
The function takes two parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task.

Preconditions
ptcb must be valid. Lower priority value means higher scheduling priority.

Postconditions
The task’s ready-state priority is updated.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.59 gu_TaskResume

Prototype
G_Status gu_TaskResume(GS_TCB *ptcb);

Description: The gu_TaskResume function resumes a task that is currently in a waiting state.

Parameters
The function takes one parameter:

Returns
G_OK if the task was resumed.

Thread-safety
Safe from task context.

Error conditions
G_ERR_PARAM if ptcb is not a valid task. G_ERR_STATE if the task is not waiting, or the events it waits for do not allow it to be resumed.

Preconditions
ptcb must be a valid TCB in Waiting state.

Postconditions
Task is moved to Ready state and may be dispatched to a processor.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.60 gu_TaskRunPrioritySet

Prototype
G_Status gu_TaskRunPrioritySet(struct gs_tcb *ptcb, G_UINT64 priority);

Description: The gu_TaskRunPrioritySet function sets the run-time priority of a task. This priority determines the task's execution order when it is running. Larger values of priority represent lower priority; smaller values represent higher priority.

Parameters
The function takes these parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task.

Preconditions
ptcb must be valid.

Postconditions
The task’s running-state (execution) priority is updated.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskStartWithOffset
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.61 gu_TaskStartWithOffset

Prototype
G_Status gu_TaskStartWithOffset(GS_TCB *ptcb,unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms);

Description: The gu_TaskStartWithOffset function starts a previously created task for execution, allowing the specification of a time offset for the task's first execution. This offset determines when the task will begin running relative to the time the function is called.

Parameters
The function uses the following parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task. G_ERR_STATE if the task was already started. G_ERR_NO_MEMORY if a kernel block it needs is not free.

Preconditions
ptcb is a task that has been created and not yet started.

Postconditions
Task is scheduled for its first release at current_time + offset.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskSuspend
gu_TaskTypeSet
__________________________________________________________________

2.62 gu_TaskSuspend

Prototype
G_Status gu_TaskSuspend(GS_TCB *ptcb);

Description: The gu_TaskSuspend function suspends a task, changing its state to waiting.

Parameters
The function takes one parameter:

Returns
G_OK if the task was suspended.

Thread-safety
Safe from task context (including self-suspension).

Error conditions
G_ERR_PARAM if ptcb is not a valid task. G_ERR_STATE if the task is neither ready nor running, or cannot be suspended.

Preconditions
ptcb must be valid. Task must be in Running or Ready state.

Postconditions
Task is moved to Waiting state; a new task is dispatched to the freed processor.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskTypeSet
__________________________________________________________________

2.63 gu_TaskTypeSet

Prototype
G_Status gu_TaskTypeSet(struct gs_tcb *ptcb, enum tcbtype type);

Description: Sets the type of a task: G_TCBType_OneShot, G_TCBType_Periodic or G_TCBType_Periodic_Skip. Interrupt service tasks get their type from gu_TriggerRegisterTask.

Parameters
The function takes these parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task, or type is not G_TCBType_OneShot, G_TCBType_Periodic or G_TCBType_Periodic_Skip.

Preconditions
type is one of G_TCBType_OneShot, G_TCBType_Periodic or G_TCBType_Periodic_Skip.

Postconditions
Task type is set; this affects scheduling and completion behavior.

See also
gu_TaskCreate
gu_TaskDelay
gu_TaskDelayTime
gu_TaskGetCurrentTCB
gu_TaskKill
gu_TaskPeriodSet
gu_TaskReadyPrioritySet
gu_TaskResume
gu_TaskRunPrioritySet
gu_TaskStartWithOffset
gu_TaskSuspend
__________________________________________________________________

2.64 gm_StatusCountingTimeGet

Prototype
static inline G_UINT32 gm_StatusCountingTimeGet(void);

Description: gm_StatusCountingTimeGet returns the status of the TIME_HOLD bit (G_TRUE or G_FALSE). The execution of gm_TimeCountersHold holds the time counters in its current state. The execution of gm_TimeCountersUnhold unholds the time counters.

Parameters
gm_StatusCountingTimeGet has no parameter.

Returns
The gm_StatusCountingTimeGet function returns G_TRUE if the TIME_HOLD bit is set, G_FALSE otherwise.

Thread-safety
Read-only; safe to call within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held for a meaningful reading.

Postconditions
None; this is a read-only status query.

See also
gm_StatusResetCountingTimeGet
gm_SystemTimePrescaleGet
gm_SystemTimePrescaleSet
gu_SystemTotalTimeGet
__________________________________________________________________

2.65 gm_StatusResetCountingTimeGet

Prototype
static inline G_UINT32 gm_StatusResetCountingTimeGet(void);

Description: gm_StatusResetCountingTimeGet return the status of the time reset counter bit (G_TRUE or G_FALSE). When G_TRUE, the time counters are reset and hold. The time counters are reset and hold reset, when executing gm_TimeCountersReset. The time counters are release to run again when execution gm_TimeCountersUnreset.

Parameters
The gm_StatusResetCountingTimeGet function has no parameter.

Returns
The gm_StatusResetCountingTimeGet function returns G_TRUE if the time counters are held in reset, G_FALSE otherwise.

Thread-safety
Read-only; safe to call within a critical section.

Error conditions
None.

Preconditions
GeMRTOS mutex must be held.

Postconditions
None; this is a read-only status query.

See also
gm_StatusCountingTimeGet
gm_SystemTimePrescaleGet
gm_SystemTimePrescaleSet
gu_SystemTotalTimeGet
__________________________________________________________________

2.66 gm_SystemTimePrescaleGet

Prototype
static inline G_UINT32 gm_SystemTimePrescaleGet(void);

Description: The gm_SystemTimePrescaleGet function returns the time prescale. This prescale is used to obtaine the system time unit from the system clock.

Parameters
The gm_SystemTimePrescaleGet function has no parameter.

Returns
The gm_SystemTimePrescaleGet function returns the time prescale.

Thread-safety
Read-only; safe within a critical section.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_StatusCountingTimeGet
gm_StatusResetCountingTimeGet
gm_SystemTimePrescaleSet
gu_SystemTotalTimeGet
__________________________________________________________________

2.67 gm_SystemTimePrescaleSet

Prototype
static inline void gm_SystemTimePrescaleSet(G_UINT32 scale);

Description: The gm_SystemTimePrescaleSet function sets the system clock prescale to get the system time unit. By default, the prescale is set to configure a 10MHz frecuency for system time units. The gm_SystemTimePrescaleGet function returns the time prescale.

Parameters
The gm_SystemTimePrescaleSet has one parameter:

Returns
The gm_SystemTimePrescaleSet function does not return any value.

Thread-safety
Must be called within a critical section.

Error conditions
Undefined if scale is 0.

Preconditions
GeMRTOS mutex must be held. Typically set during initialization to achieve 10 MHz ticks from the system clock.

Postconditions
System time counter increments every scale clock cycles.

See also
gm_StatusCountingTimeGet
gm_StatusResetCountingTimeGet
gm_SystemTimePrescaleGet
gu_SystemTotalTimeGet
__________________________________________________________________

2.68 gu_SystemTotalTimeGet

Prototype
G_UINT64 gu_SystemTotalTimeGet(void);

Description: gu_SystemTotalTimeGet returns the total system time. It is the time in non frozen mode plus the time in frozen mode.

Parameters
The gu_SystemTotalTimeGet function has no parameter. It has to be noted that temporal constraints (deadline, period) are related to system time, obtained using the gu_SystemTimeGet function, which is the time in non frozen mode.

Returns
The gu_SystemTotalTimeGet function returns the total system time.

Thread-safety
Safe from task context.

Error conditions
None.

Preconditions
None.

Postconditions
None.

See also
gm_StatusCountingTimeGet
gm_StatusResetCountingTimeGet
gm_SystemTimePrescaleGet
gm_SystemTimePrescaleSet
__________________________________________________________________

2.69 gu_TriggerCreate

Prototype
GS_RCB *gu_TriggerCreate(G_UINT32 irq_id, G_UINT64 ticks_to_wait);

Description: The function creates a trigger resource. It accepts an irq_id argument to allow associating the trigger resource with a hardware interrupt.

Parameters
The trigger is created and initilized with the following paramenters:

Returns
The gu_TriggerCreate function returns a pointer to the newly created trigger resource. This pointer must be used to reference the trigger resource in all subsequent trigger-related functions.

Thread-safety
Safe from task context or initialization.

Error conditions
Returns NULL if no free RCB is available or irq_id is out of range.

Preconditions
irq_id must be in [0, ALT_NIRQ-1]. The IRQ must be connected in Platform Designer.

Postconditions
A trigger RCB is allocated and associated with irq_id. Call gu_TriggerRegisterTask to associate tasks.

See also
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.70 gu_TriggerDisable

Prototype
G_Status gu_TriggerDisable(GS_RCB *ptrigger);

Description: The gu_TriggerDisable function disables the trigger resource, preventing it from being activated using either the gu_TriggerRelease function or the associated hardware interrupt.

Parameters
The disabling of the trigger resource is performed with the following parameter:

Returns
G_OK on success.

Thread-safety
Safe from task context.

Error conditions
G_ERR_PARAM if the handle is not a trigger.

Preconditions
Trigger must have been created with gu_TriggerCreate.

Postconditions
The IRQ is disabled; the trigger will not fire until re-enabled.

See also
gu_TriggerCreate
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.71 gu_TriggerDisableHook

Prototype
G_Status gu_TriggerDisableHook(GS_RCB *ptrigger, void (*code_callback)(void *), void *p_arg);

Description: The gu_TriggerDisableHook function sets the hook function to be called after the trigger resource is disabled.

Parameters
The disable hook function is specified using the following parameters:

Returns
G_OK if the hook was configured.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if the handle is not a trigger.

Preconditions
Trigger must exist. code_callback must be a valid function pointer or NULL.

Postconditions
code_callback is called (with p_arg) each time this trigger is disabled.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.72 gu_TriggerEnable

Prototype
G_Status gu_TriggerEnable(GS_RCB *ptrigger);

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

Parameters
The enabling of the trigger resource is performed with the following parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context.

Error conditions
G_ERR_PARAM if the handle is not a trigger.

Preconditions
Trigger must have been created. Typically called after gu_TriggerWait returns to re-arm the trigger.

Postconditions
The IRQ is enabled; the next device interrupt will release registered tasks.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.73 gu_TriggerEnableHook

Prototype
G_Status gu_TriggerEnableHook(GS_RCB *ptrigger, void (*code_callback)(void *), void *p_arg);

Description: The gu_TriggerEnableHook sets the hook function to be called before the trigger resource is enabled.

Parameters
The gu_TriggerEnableHook function requires the following paramenters:

Returns
G_OK if the hook was configured.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if the handle is not a trigger.

Preconditions
Trigger must exist. code_callback must be a valid function pointer or NULL.

Postconditions
code_callback is called (with p_arg) each time this trigger is enabled.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.74 gu_TriggerRegisterTask

Prototype
G_Status gu_TriggerRegisterTask(struct gs_tcb *ptcb, GS_RCB *ptrigger);

Description: The gu_TriggerRegisterTask function associates a task with a trigger resource.

Parameters
The task registration with the trigger resource is performed using the following parameters:

Returns
G_OK if the task was registered.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if ptcb is not a valid task or ptrigger is not a trigger. G_ERR_STATE if the task is already registered to that trigger. G_ERR_NO_MEMORY if the event pool is empty.

Preconditions
ptrigger must exist (created by gu_TriggerCreate). ptcb must be valid.

Postconditions
The task is registered; when the trigger fires it will be released.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRelease
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.75 gu_TriggerRelease

Prototype
GS_TRGStatus gu_TriggerRelease(GS_RCB *ptrigger);

Description: The function activates a trigger resource. If the trigger resource is enabled and all associated tasks are in a waiting state for the trigger, then the tasks are resumed or restarted.

Parameters
The trigger resource is activated using the following parameter:

Returns
Returns the trigger status after activation (GS_TRGStatus).

Thread-safety
Safe from task context.

Error conditions
A handle that is not a trigger is refused with G_TRGStatus_not_valid.

Preconditions
Trigger must exist.

Postconditions
All tasks registered to this trigger are moved from Waiting to Ready state.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerSetTimeoutType
gu_TriggerWait
__________________________________________________________________

2.76 gu_TriggerSetTimeoutType

Prototype
G_Status gu_TriggerSetTimeoutType(GS_RCB *ptrigger, GS_TRGTimeOutType type);

Description: Sets the trigger timeout type for a givenTrigger. This function assigns the specified timeout type to the trigger's TRGType member.

Parameters
The gu_TriggerSetTimeoutType requires the following parameters:

Returns
G_OK on success.

Thread-safety
Safe from task context or initialization.

Error conditions
G_ERR_PARAM if the handle is not a trigger or the timeout type is not valid.

Preconditions
ptrigger must be a valid trigger RCB. Use before the first gu_TriggerWait.

Postconditions
The timeout behavior for waiting tasks is configured.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerWait
__________________________________________________________________

2.77 gu_TriggerWait

Prototype
GS_TRGStatus gu_TriggerWait(void);

Description: The gu_TriggerWait function places the task into a waiting state for the trigger resource it is registered to. It can be executed anywhere in the task's code, and the same effect occurs when the task completes its execution (assuming it's not an infinite loop).

Parameters
The gu_TriggerWait function does not require any parameters, as the task automatically waits for the trigger resource it is associated with.

Returns
Returns a GS_TRGStatus value: G_TRGStatus_triggered if the trigger fired, or G_TRGStatus_timeout if a timeout occurred.

Thread-safety
Task context only; suspends the calling task.

Error conditions
Returns status code indicating whether trigger fired (G_TRGStatus_triggered) or timed out.

Preconditions
Calling task must be registered to a trigger via gu_TriggerRegisterTask. Must be called from task context.

Postconditions
Task is moved to Waiting state; resumes when its registered trigger fires or a timeout occurs.

See also
gu_TriggerCreate
gu_TriggerDisable
gu_TriggerDisableHook
gu_TriggerEnable
gu_TriggerEnableHook
gu_TriggerRegisterTask
gu_TriggerRelease
gu_TriggerSetTimeoutType
__________________________________________________________________

__________________________________________________________________

2.78 gu_ConvertTime

Prototype
G_UINT64 gu_ConvertTime(unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms);

Description: Converts a wall-clock duration into the system tick value used by every GeMRTOS timeout and period argument. Use it wherever a function expects a G_UINT64 tick count instead of computing ticks by hand.

Parameters  

Returns  The equivalent duration expressed in system ticks.

___________

2.79 gu_SemaphoreCreateCounting

Prototype
GS_RCB *gu_SemaphoreCreateCounting(G_UINT32 max_count, G_UINT32 initial_count);

Description: Creates a counting semaphore and returns a handle by which it can be referenced. A counting semaphore grants up to max_count simultaneous holders, which suits pools of interchangeable resources.

Parameters  

Returns  Handle to the new semaphore, or 0 if it could not be created.

__

2.80 gu_SemaphoreDestroy

Prototype
G_Status gu_SemaphoreDestroy(GS_RCB *psemaphore);

Description: Destroys a semaphore and returns its resource control block to the free pool.

Parameters  

Returns  G_OK if the semaphore was destroyed. G_ERR_PARAM if the handle is not a semaphore or was already destroyed. G_ERR_STATE while it is held or a task waits for it.

_____________________________________________________________

2.81 gu_MessageQueueDestroy

Prototype
G_Status gu_MessageQueueDestroy(GS_RCB *pqueue);

Description: Destroys a message queue and returns its resource control block to the free pool.

Parameters  

Returns  G_OK if the queue was destroyed. G_ERR_PARAM if the handle is not a queue. G_ERR_STATE while it has subscribers or messages or tasks pending.

___________________________________________________________

2.82 gu_TriggerDestroy

Prototype
G_Status gu_TriggerDestroy(GS_RCB *ptrigger);

Description: Destroys a trigger resource, returning its resource control block and its timeout event to the free pool.

Parameters  

Returns  G_OK if the trigger was destroyed. G_ERR_PARAM if the handle is not a trigger. G_ERR_STATE while tasks are registered or waiting.

__________________________________________________________________

2.83 gm_WatchdogTimeoutSet

Prototype
static inline void gm_WatchdogTimeoutSet(G_UINT32 timeout);

Description: Configures the per-processor watchdog timeout value, written to CTRL_WATCHDOG_BIT in the Control Register (§??). The name is spelled Watchog, not Watchdog – the real primitive name, not a typo introduced by this reference. Setting the timeout alone does not arm the watchdog; gm_PrcWatchdogEnable must also be called. See §?? for the full design.

Parameters
timeout — raw timeout value; only bits [G_WATCHDOG_TIMEOUT_SHIFT+11 : G_WATCHDOG_TIMEOUT_SHIFT] (12 bits, shifted right by G_WATCHDOG_TIMEOUT_SHIFT = 16 before being written) reach the hardware register. At the shared 10MHz tick base, this gives a representable range of approximately 6.55ms (register value 1) to 26.8s (register value 0xFFF).

Returns
Does not return a value.

Thread-safety
Affects only the calling processor’s own watchdog configuration; safe to call without the GeMRTOS mutex.

Error conditions
None – values outside the representable range are silently truncated to the low 12 bits of the shifted result.

Preconditions
None.

Postconditions
The processor’s configured watchdog timeout is updated. The countdown itself does not start unless gm_PrcWatchdogEnable has also been called (independently, in either order).

See also
gm_PrcWatchdogEnable
gm_PrcWatchdogDisable
gu_WatchdogHandlerSet
__________________________________________________________________

2.84 gm_PrcWatchdogEnable

Prototype
static inline void gm_PrcWatchdogEnable(void);

Description: Arms the calling processor’s own watchdog countdown, using whatever timeout was last configured via gm_WatchdogTimeoutSet. The countdown reloads to the full timeout continuously while the processor is halted or disabled, and only counts down while both enabled and actively running – there is no explicit software “pet” call. See §??.

Parameters
The gm_PrcWatchdogEnable function does not accept any parameters.

Returns
Does not return a value.

Thread-safety
Affects only the calling processor’s own watchdog state; safe to call without the GeMRTOS mutex. Not meaningful to call on behalf of another processor – always applies to gm_ProcessorId() of the caller.

Error conditions
None.

Preconditions
An application-appropriate timeout should already be configured via gm_WatchdogTimeoutSet – enabling with the power-up default timeout value arms at that default instead. Never call this from a task running on processor 1, on real embedded hardware – confirmed 2026-08-26, a processor-1 watchdog reset hangs the entire board (see §??). Safe on processors 2 through N, and on the Windows simulation for any processor including 1.

Postconditions
The calling processor’s watchdog countdown is active. If it is not halted again, or explicitly disabled, before the configured timeout elapses, the processor is reset by the controller.

See also
gm_WatchdogTimeoutSet
gm_PrcWatchdogDisable
gu_WatchdogHandlerSet
__________________________________________________________________

2.85 gm_PrcWatchdogDisable

Prototype
static inline void gm_PrcWatchdogDisable(void);

Description: Stops the calling processor’s watchdog countdown without clearing its configured timeout value – a later gm_PrcWatchdogEnable reuses the same timeout unless gm_WatchdogTimeoutSet is called again first.

Parameters
The gm_PrcWatchdogDisable function does not accept any parameters.

Returns
Does not return a value.

Thread-safety
Affects only the calling processor’s own watchdog state; safe to call without the GeMRTOS mutex.

Error conditions
None.

Preconditions
None – safe to call even if the watchdog is already disabled.

Postconditions
The calling processor’s watchdog countdown is stopped; the configured timeout value is unchanged.

See also
gm_WatchdogTimeoutSet
gm_PrcWatchdogEnable
gu_WatchdogHandlerSet
__________________________________________________________________

2.86 gu_WatchdogHandlerSet

Prototype
void gu_WatchdogHandlerSet(G_WatchdogHandler handler);

Description: Registers (or, passed NULL, uninstalls) the system-wide watchdog-recovery handler, invoked after a watchdog-triggered processor reset – but only after the kernel has already restored its own invariants (the abandoned task unlinked and freed, or IDLE’s state left untouched if it was the abandoned task). The handler receives a read-only snapshot, never a live pointer into kernel structures, and chooses whether the system continues normally or halts. See §?? for the full usage pattern with a worked example.

Parameters
handler — function to install, matching enum g_watchdog_action (*)(const struct g_watchdog_report *report); or NULL to uninstall (restores the default: always G_WATCHDOG_ACTION_RESUME, the same behavior as before this feature existed).

Returns
Does not return a value.

Thread-safety
Not synchronized against a concurrent call to gu_WatchdogHandlerSet from another processor. Intended to be set once during application initialization, before any processor’s watchdog is armed.

Error conditions
None.

Preconditions
None, though setting this before arming any processor’s watchdog (rather than after) is the only usage pattern that guarantees no recovery is missed.

Postconditions
The registered handler (or no handler, if NULL) is invoked on every subsequent watchdog recovery, on any processor – one global handler, not per-processor; report->CPUID distinguishes which processor recovered if the application needs to react differently per processor.

See also
gm_WatchdogTimeoutSet
gm_PrcWatchdogEnable
gm_PrcWatchdogDisable
__________________________________________________________________

2.87 gm_MutexWatchdogFieldGet

Prototype
static inline G_UINT32 gm_MutexWatchdogFieldGet(G_UINT32 ticks);

Description: Pure helper: computes the 12-bit mutex-hold-watchdog timeout field (an 8-bit magnitude in bits 11:4, a 4-bit multiplier in bits 3:0) for a timeout of at least ticks system-time ticks. The controller decrements the magnitude once every 2multiplier system-time ticks, so the represented timeout is magnitude × 2multiplier ticks; the smallest multiplier that fits ticks in a magnitude of 1..255 is chosen, so the result always rounds up (never shorter than requested), to within one part in 128 once ticks exceeds 255. Used internally by gm_MutexWatchdogTimeoutSet; exposed separately for code that needs the raw field value (for example, to predict the actual timeout that will be armed before arming it).

Parameters
ticks — requested minimum timeout in system-time ticks (see gu_ConvertTime). Zero is treated as one tick, since a magnitude of zero would fire as soon as the mutex is taken.

Returns
The 12-bit field to write with CTRL_MTX_WDT_BIT. A ticks value beyond the representable range saturates at the longest usable timeout (255 × 214 ticks, field 0xFFE); the field 0xFFF is reserved for “disabled” and is never returned by this function.

Thread-safety
Pure function – no shared state, no hardware access. Safe to call from anywhere, with or without the GeMRTOS mutex.

Error conditions
None – every input maps to a valid field value.

Preconditions
None.

Postconditions
None (no side effects).

See also
gm_MutexWatchdogTimeoutSet
gm_MutexWatchdogDisable
__________________________________________________________________

2.88 gm_MutexWatchdogTimeoutSet

Prototype
static inline void gm_MutexWatchdogTimeoutSet(G_UINT32 ticks);

Description: Arms the mutex-hold watchdog: if any processor holds the GeMRTOS Mutex longer than ticks, the controller resets that processor through the same reset-request handshake as the per-processor watchdog, but leaves the mutex granted to it – every other processor blocks and the system freezes while the reset processor prints a diagnostic report and stops, so the system can be examined afterwards (for example over JTAG). Unlike the per-processor watchdog, this is one system-wide setting, not per-processor. See §?? for the full design.

Parameters
ticks — timeout in system-time ticks; use gu_ConvertTime to convert from hours/minutes/seconds/milliseconds. Rounded up to the nearest representable (magnitude, multiplier) pair (see gm_MutexWatchdogFieldGet) – the armed timeout is never shorter than requested.

Returns
Does not return a value.

Thread-safety
One shared, system-wide setting – not synchronized against a concurrent call from another processor. Intended to be set once during application initialization, before the watchdog matters.

Error conditions
None – a ticks value beyond the representable range saturates rather than failing (see gm_MutexWatchdogFieldGet).

Preconditions
None, though choosing a timeout well above the longest legitimate critical section is the only usage pattern that avoids false positives – a kernel entry executing from uncached external memory alone can take tens of microseconds.

Postconditions
The mutex-hold watchdog is armed at the rounded-up timeout. Because it counts system-time ticks, holding the time counters (CTRL_TM_CNTS_HLD_BIT) or freezing the avalon_monitor pauses the countdown, same as it pauses every other system-time-driven mechanism.

See also
gm_MutexWatchdogDisable
gm_MutexWatchdogFiredGet
gu_MutexWatchdogHandlerSet
gm_MutexWatchdogFieldGet
__________________________________________________________________

2.89 gm_MutexWatchdogDisable

Prototype
static inline void gm_MutexWatchdogDisable(void);

Description: Disables the mutex-hold watchdog – the controller’s reset state, so this call is only needed to turn one back off after gm_MutexWatchdogTimeoutSet armed it.

Parameters
The gm_MutexWatchdogDisable function does not accept any parameters.

Returns
Does not return a value.

Thread-safety
One shared, system-wide setting – not synchronized against a concurrent call from another processor.

Error conditions
None.

Preconditions
None – safe to call even if the watchdog is already disabled.

Postconditions
The mutex-hold watchdog no longer resets any processor, regardless of how long the mutex is held.

See also
gm_MutexWatchdogTimeoutSet
__________________________________________________________________

2.90 gm_MutexWatchdogFiredGet

Prototype
static inline G_UINT32 gm_MutexWatchdogFiredGet(void);

Description: Reads the calling processor’s own sticky “fired” bit (ADDR_REG_0 bit 6, PRC_STA_MTX_WDT_FIRED_BIT): non-zero if this processor was reset by the mutex-hold watchdog. The bit survives the reset that set it – only a controller reset clears it – which is what lets gk_START_KERNEL test it before the reset processor contends for the mutex it still holds, and route into the “blue screen” (§??) instead of resuming normally.

Parameters
The gm_MutexWatchdogFiredGet function does not accept any parameters.

Returns
1 if the mutex-hold watchdog reset this processor since the last controller reset, 0 otherwise. A controller build without the watchdog reads 0.

Thread-safety
Reads only the calling processor’s own status bit; safe to call without the GeMRTOS mutex, from any processor about itself.

Error conditions
None.

Preconditions
None.

Postconditions
None (read-only).

See also
gm_MutexWatchdogTimeoutSet
gu_MutexWatchdogHandlerSet
__________________________________________________________________

2.91 gu_MutexWatchdogHandlerSet

Prototype
void gu_MutexWatchdogHandlerSet(G_MutexWatchdogHandler handler);

Description: Registers (or, passed NULL, uninstalls) the optional mutex-hold-watchdog handler. The built-in report is always printed first, through gk_MutexWatchdogReportEmit(), on the processor the watchdog just reset – five lines, from the global g_mutex_watchdog_report: which processor, how long the mutex had been held, the raw controller and processor status, and, when a valid TCB was found, the task that was running and its priority. The handler, if one is registered, is called once, after that report has been printed; the system stops when the handler returns. See §?? for the full recovery sequence.

Parameters
handler — function to install, matching void (*)(const struct g_mutex_watchdog_report *report); or NULL to uninstall (the default: no handler, only the built-in report).

Returns
Does not return a value.

Thread-safety
One global handler, not per-processor – report->CPUID distinguishes which processor recovered if the application needs to react differently. Not synchronized against a concurrent call; intended to be set once during application initialization, before the watchdog is armed.

Error conditions
None.

Preconditions
None. The handler, when it runs, executes on the processor that still holds the GeMRTOS Mutex – it must not call anything that takes the mutex, gu_printf included; gk_fprintf() is fine, since it uses no kernel service.

Postconditions
The registered handler (or no handler, if NULL) is invoked on every subsequent mutex-hold-watchdog reset, on whichever processor is reset. The system stops (does not resume) once the handler returns – this is a fail-stop recovery, not a resumable one, unlike the per-processor watchdog.

See also
gm_MutexWatchdogTimeoutSet
gm_MutexWatchdogDisable
gm_MutexWatchdogFiredGet

__________________________________________________________________

2.92 gu_MessageQueueSendPriority

Prototype
int gu_MessageQueueSendPriority(GS_RCB *prcb, const char *pmsg, int msg_length, 
                                G_UINT64 timeout, G_UINT32 priority);

Description: Same as gu_MessageQueueSend (which is this function with GU_MQ_PRIORITY_DEFAULT, 1024) with a message priority. Pending messages are delivered in priority order (a smaller number is more urgent) and, within one priority, in the order they were sent. A message the receivers have already started on is not overtaken. Strict priority can starve low-priority messages; the sender timeout bounds the wait.

Parameters

Returns
As gu_MessageQueueSend: the number of receivers that got the message, or minus that number (zero or negative) when the timeout was served first.

___________

2.93 gu_ConsoleStart

Prototype
G_Status gu_ConsoleStart(void);

Description: Starts the console service: a message queue and a consumer task for each console UART. The kernel calls it before main when G_CONSOLE_QUEUE_ENABLE is 1, so applications do not need to; a second call is harmless. Lines that cannot be queued are lost and counted.

Parameters
None.

Returns
G_OK if the service is running or the platform needs none; otherwise a G_ERR_ code (G_ERR_NO_MEMORY if a queue or a task could not be created).

______________

2.94 gu_DiagSnapshotGet

Prototype
G_Status gu_DiagSnapshotGet(GS_DiagBlock *out);

Description: Copies a consistent snapshot of the diagnostic block into out without taking the GeMRTOS mutex. Available when G_INSTRUMENTATION_LEVEL is 1 or more.

Parameters

Returns
G_OK if a consistent copy was made. G_ERR_PARAM if out is NULL. G_ERR_TIMEOUT if every bounded retry found the block being written; the copy is then not valid.

_____________________________________________________________

2.95 gu_AuditSnapshotGet

Prototype
G_Status gu_AuditSnapshotGet(GS_AuditBlock *out);

Description: Copies the result block of the kernel audit if it did not change during the copy. Check out->state: a consistent copy can be of an audit that has not completed. While an audit runs the call fails; call again later. Available when G_INSTRUMENTATION_LEVEL is 1 or more.

Parameters

Returns
G_OK if a consistent copy was made. G_ERR_PARAM if out is NULL. G_ERR_TIMEOUT if every bounded retry found the block being written; the copy is then not valid.

_____________________________________________________________

2.96 gu_TaskStatsSnapshotGet

Prototype
G_Status gu_TaskStatsSnapshotGet(GS_TaskStatsBlock *out);

Description: Copies a consistent snapshot of the task-statistics block, with the same protocol as gu_DiagSnapshotGet. Available when G_INSTRUMENTATION_LEVEL is 1 or more.

Parameters

Returns
G_OK if a consistent copy was made. G_ERR_PARAM if out is NULL. G_ERR_TIMEOUT if every bounded retry found the block being written; the copy is then not valid.