LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-22-2005, 01:00 PM   #1
tornatom
LQ Newbie
 
Registered: Jun 2005
Posts: 3

Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[thread control suggestion] add a "solved" button that the thread starter can click atom LQ Suggestions & Feedback 3 03-24-2005 11:55 AM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 09:15 AM
'Last Thread' 'Next Thread' for 0 Replies and new posts darin3200 LQ Suggestions & Feedback 2 08-16-2004 01:02 PM
configure qt thread issue (just compiled qt w/ -thread option) cleff Linux - Software 8 05-07-2004 11:11 PM
send parameter from thread to thread marek Programming 2 09-08-2003 05:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration