Click to See Complete Forum and Search --> : Thread priority


tornatom
August 22nd, 2005, 09:21 AM
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:

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.


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

Andreas Masur
August 22nd, 2005, 10:22 AM
[ Redirected thread ]