【发布时间】:2020-07-13 13:01:37
【问题描述】:
我正在尝试使用 vTaskList() 列出当前正在运行的所有任务的状态。每当我调用该函数时,我都会得到一个 HardFault 并且我不知道它的故障所在。我尝试增加堆大小和堆栈大小。这会导致 vTaskList() 工作一次,但第二次会再次引发硬故障。 以下是我在 osThreadList() 中使用 vTaskList() 的方式
osStatus osThreadList (uint8_t *buffer)
{
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )
vTaskList((char *)buffer);
#endif
return osOK;
}
以下是我如何使用 osThreadList() 在我的串行终端上打印所有任务。
uint8_t TskBuf[1024];
bool IOParser::TSK(bool print_help)
{
if(print_help)
{
uart_printf("\nTSK: Display list of tasks.\r\n");
}
else
{
uart_printf("\r\nName State Priority Stack Num\r\n" );
uart_printf("---------------------------------------------\r\n");
/* The list of tasks and their status */
osThreadList(TskBuf);
uart_printf( (char *)TskBuf);
uart_printf("---------------------------------------------\r\n");
uart_printf("B : Blocked, R : Ready, D : Deleted, S : Suspended");
}
return true;
}
当我注释掉任何一项任务时,我都能让它发挥作用。我猜这与内存有关,但我还没有找到解决方案。
【问题讨论】:
标签: multithreading malloc stm32 freertos iar