/* create a main thread reading data and four threads for four buffer */ static s32 create_io_thread(t_io_ops *p) { int ret = 0; t_io_thread_info *pt = NULL; pthread_attr_t attr; pthread_attr_init (&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if(NULL == p){ printf("NULL == p\n"); return -1; } if( NULL == p->_pfntrancb){ printf("NULL == p->_pfncb\n"); return 0; } pt = &p->_threadinfo; pt->_exit = 0; pt->_thd = -1; ret = pthread_create(&pt->_thd, &attr, io_thread_func, p); if (ret != 0) { perror("create_absreader_thread failed"); return -1; } if (set_realtime_schedule(pt->_thd) < 0) { printf("set realtime schedule error \n"); return -1; } printf("create_io_thread thread id=0x%x, type=%d\n", (unsigned int)pt->_thd, p->_event); return 0; }
int StreamState::createWorkingThread() { if (pthread_create(&fWorkingThreadID, NULL, workingThreadFunc, this) < 0) { printf("createWorkingThread error\n"); return -1; } if (set_realtime_schedule(fWorkingThreadID) < 0) { printf("set realtime schedule error\n"); return -1; } return 0; }
/* create a main thread reading data and four threads for four buffer */ static int create_working_thread(void) { pthread_t tid; int ret; G_force_main_thread_quit = 0; ret = pthread_create(&tid, NULL, bsreader_dispatcher_thread_func, NULL); if (ret != 0) { perror("main thread create failed"); return -1; } G_main_thread_id = tid; if (set_realtime_schedule(G_main_thread_id) < 0) { printf("set realtime schedule error \n"); return -1; } return 0; }