Hello,
I have been trying to start a thread with a high priority. When I do set it to a higher priority then the thread doesn't seem to execute. When I just run the thread with out passing it an attribute it works just fine.
Here is my code:
Code:
pthread_attr_t attr;
sched_param schedparam;
schedparam.sched_priority = 2;
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_RR);
pthread_attr_setschedparam(&attr, &schedparam);
dasToTape->Start(NULL, &attr);
And here is the start function where I start the thread.
Code:
bool CWorkerThread::Start(void *pArg, pthread_attr_t *threadAttr)
{
int rc;
pthread_t thread;
m_UserData= pArg;
m_Shutdown= false;
rc= pthread_create(&thread, threadAttr, m_pThreadFunc, this);
if(rc){
cout << "thread creation failed" <<endl;
}
return 1;
}
Thanks
james