no difference seen even after setting application thread priority in linux environmen
Hi,
Can any one help in resolving the below problem. Actually i am trying to set different priorities for two application threads.With root privilages i could set the thread priority using pthread_setschedparam()(Returning the expected as successfull) in linux environment.But i don't see any difference in the output(thread's) i.e.thread with high priority and thread with low priority are exiting at the same time. Actually thread with high priority should get called more number of times and it should exit first. Below is the process i followed to set the thread priority. pthread_attr_t attr; pthread_t threadId; int threadStatus; struct sched_param param; int policy; threadStatus = pthread_attr_init(&attr); threadStatus = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); threadStatus = pthread_attr_setstacksize(&attr,0x10000); param.sched_priority = threadPriority; ret = pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED); /* cleanup any zombie threads that are holding resources */ waitpid(0, &status, WNOHANG | __WCLONE); threadStatus = pthread_create(&threadId, &attr, pThreadFuncAddress, pParameter); ret= pthread_setschedparam(threadId,SCHED_RR,¶m); Please comment.. |
you can't rise the thread prority. It's for stoping DOS attacts. I lack detailed information right now. Try greping pthread documetion and linux/Documetation.
|
No difference seen even after setting application thread priority in linux environment
Quote:
I have referred below link http://www.kernel.org/doc/man-pages/...edparam.3.html Please comment on this. Syed. |
I think I have a idea but I need to know which scheduling you use. Right now, Defualt linux scheduling mechanism follows dynamic scheduling. For that, you may not really see scheduling differences between differently priority threads.
|
If the machine isn't busy then priority won't affect execution time. Scheduling makes a difference when resources are overtaxed. On a multiple core/CPU machine the resources (CPU mainly in this case) will be available for both threads when they request CPU so they will both execute at full speed.
Now if you had two cores and three very busy threads then there would be contention for the CPU resources. Busy threads would be doing something like Code:
dd if=/dev/urandom of=/dev/null <whatever> These kinds of factors affect the amount of CPU requested by a high priority thread. |
All times are GMT -5. The time now is 12:10 AM. |