Reference for CMSIS-RTOS2 document translation (RTX5-specific API functions)

RTX5 function. More...

function

uint32_t  osRtxErrorNotify (uint32_t code, void *object_id)
  OS error callback function. More...
 
void  osRtxIdleThread (void *argument)
  OS idle thread. More...
 

describe

function documentation

uint32_t osRtxErrorNotify ( uint32_t  code,
    void *  object_id 
  )    

Some system error conditions can be detected at runtime. If the RTX kernel detects a runtime error, it calls the runtime error function osRtxErrorNotify for the object specified by the parameter object_id.

The parameter code passes the actual error code to this function:

error code describe
osRtxErrorStackUnderflow Thread stack overflow detected (thread_id = object_id)
osRtxErrorISRQueueOverflow ISR queue overflow detected when inserting object (object_id)
osRtxErrorTimerQueueOverflow User timer callback timer detected queue overflow (timer_id = object_id)
osRtxErrorClibSpace Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
osRtxErrorClibMutex Standard C/C++ library mutex initialization failed

The function osRtxErrorNotify must contain an infinite loop to prevent further program execution. You can use the simulator to step through infinite loops and trace code that introduces runtime errors. For overflow errors, this means you need to increase the size of the object that caused the overflow.

Notice
Cannot be called from an interrupt service routine.

code example

#include "rtx_os.h"
uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
(void)object_id;
switch (code) {
// Stack overflow detected for thread (thread_id=object_id)
break ;
// ISR Queue overflow detected when inserting object (object_id)
break ;
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
break ;
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
break;
// Standard C/C++ library mutex initialization failed
break;
default:
break;
}
for (;;) {}
//return 0U;
}
osRtxErrorClibMutexvoid osRtxIdleThread ( void *  argument )  

当没有其他线程准备运行时,函数 osRtxIdleThread 由 RTX 内核执行。默认情况下,该线程是一个空白的无终止循环,它什么都不做。它只是等待另一个任务准备运行。您可以更改 osRtxIdleThread 函数的代码,使 CPU 进入省电模式或空闲模式,请参阅无节拍低功耗操作。

该线程的默认堆栈大小在文件 RTX_Config.h 中定义。请参阅线程配置。

注意
不能从中断服务程序调用。

代码示例

#include "rtx_os.h"
__NO_RETURN void osRtxIdleThread ( void *argument) {
(void)argument;
for (;;) {}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325569139&siteId=291194637