LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   thread priority (https://www.linuxquestions.org/questions/programming-9/thread-priority-355864/)

tornatom 08-22-2005 02:00 PM

thread priority
 
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


All times are GMT -5. The time now is 11:04 AM.