Linux(zigbee)中创建线程
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
pthread_t pid;
if (pthread_create(&pid, NULL, (void *)&dev_ctrl_process_async, NULL) == 0) {
}
else
{
}
线程函数
static srv_ctrl_res_e dev_ctrl_process_async(void *arg)
{
pthread_detach(pthread_self());
zstack_intfc_status_e status;
while(auto_test.start == 1)
{
pthread_mutex_lock(&mutex);
dzlog_debug("**********ON************");
pthread_mutex_unlock(&mutex);
usleep(auto_test.interval_time*1000);
}
//pthread_mutex_unlock(&mutex);
pthread_exit(0);
}
其中:pthread_detach(pthread_self());//函数解释作用详解
https://blog.csdn.net/m0_60663280/article/details/121589479