工具/软件:Code Composer Studio
尊敬的 TI:
下面是创建分离 pthread 的示例代码、为什么它在完成任务时一直占用堆内存?
请帮助。 谢谢。
pthread_t create_thread (const int 优先级、回调 CB、void * args)
{
pthread_t pid = NULL;
pthread_attr_t atttrs;
struct sched_param schedule;
执行{
pthread_attr_init (atttrs);
schedule.sched_priority = priority;
pthread_attr_setschedparam (&atttrs、&schedule);
if (pthread_attr_setdetachstate (&atttrat、pthread_create_detachstate)!= 0){
错误("设置状态失败\n");
中断;
}
if (pthread_attr_setstacksize (&attrs、4096)!= 0){
错误("无法设置 stacksize\n");
中断;
}
if (pthread_create (&pid、&attrs、CB、args)!= 0){
错误("无法创建线程\n");
中断;
}
} while (false);
pthread_attr_destroy (atttrs);
返回 pid;
}





