您好!
我对 POSIX 头有些陌生。
我一直在使用开箱即用项目从 mainthread()方法创建新线程。
我要启动的函数是检查 UART 传入消息的循环。
但是,我这样做似乎是导致系统冻结(死锁)?
是否可以在我在另一个线程上启动的函数中放置 while (1)?
下面是 开始线程的代码:
int32_t RetVal;
pthread_attr_t pAttrs;
struct sched_param priParam;
pthread_attr_init(&pAttrs);
priParam.sched_priority = 1;
RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
RetVal |= pthread_attr_setstacksize(&pAttrs, LINKLOCAL_STACK_SIZE);
if (RetVal)
{
/* Handle Error */
UART_PRINT("Unable to configure thread parameters \n");
while (1)
{
;
}
}
RetVal = pthread_create(&thread, &pAttrs, test, NULL);
我的测试循环(没有 UART、只需测试题头)
void* test(void *pvParameters)
{
int a=0;
while (1)
{
a=0;
for (int i = 0; i < 10000000; i++)
{
a++;
}
UART_PRINT("test of doom\r\n");
}
}
我尝试更改线程优先级... 但似乎什么都不起作用。