|
MDK 38a、RTX V5.5.4、C 6.19下,在thread1种多次删除、创建thread2后,会导致创建thread2不成功,返回为NULL。不知是何原因
static osThreadId_t threadIdThread2 = NULL;
static const osThreadAttr_t thread2Attr =
{
.name = "osRtxThread2",
.attr_bits = osThreadDetached,
.priority = osPriorityNormal,
.stack_size = 128,
};
void thread2(void *argument)
{
// do some things
osThreadTerminate(osThreadGetId ()); //删除自身本线程
}
void thread1(void *argument)
{
for(;;)
{
//...
if(threadIdThread2 != NULL)
{//如果线程已被建立,删除线程
osThreadTerminate(hreadIdThread2);
}
threadIdThread2=osThreadNew(thread2, NULL, &thread2Attr);
}
}
|
|