Thread priorities not working
Hi,
I am new to linux world.. I am creating a thread and setting the priority. pthread_attr_t tAttr; if (pthread_attr_init(&tAttr)==ENOMEM){ cout <<"Thread Attibute : No Memory left"<<endl; } if(pthread_attr_setdetachstate(&tAttr, PTHREAD_CREATE_DETACHED)!=0){ cout <<"Thread State: Error Making Detachable"<<endl; } struct sched_param schedParam; pthread_t _taskId; schedParam.sched_priority = 20; int error = pthread_attr_setschedpolicy(&tAttr, SCHED_RR) ; error = pthread_attr_setschedparam(&tAttr, &schedParam); //cout << " pthread_attr_setschedparam Error = " << error << endl; if(pthread_create(&_taskId, &tAttr, doCalculation , (void*)"Thread-20")!= 0){ cout<<" Task Creation : Resource Error , Permission Problem or Invalid Argument " <<endl; return ; } //and checking the priority using following ... int policy = 0; if (pthread_getschedparam(_taskId, &policy, &schedParam) == 0) { cout << "Thread sched policy = " << policy << " Prioriy = " << _schedParam.sched_priority <<endl; } But every time I get the output as Thread sched policy = 0 Prioriy = 0. Somehow priority is not getting set.. PLease help.. I am running this program on kernal 2.6.7-2.2. Fedora - 2.. Sticky bit is set Please help. Let me know if I need to do any settings with the kernel. Thanks and Regads -- Ujjwal |
Hey, the problem is that, by default the priority is 0 and the maximum and minimum priority is also 0 for pc based application. It range upto 200 for rtos.. for that we have to set CONFIG_MAX_RT_PRIO.
Unless you are doing specialized real-time programming with kernel threads, the default is fine. here is the link frm where i got the information http://www.kernel.org/pub/linux/kern...e8-ac4-1.patch hope this solves your problem...all the best Quote:
|
All times are GMT -5. The time now is 11:45 AM. |