LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 11-19-2010, 07:09 AM   #1
rahimlnx
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
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,&param);


Please comment..
 
Old 11-20-2010, 04:06 PM   #2
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
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.
 
Old 11-21-2010, 06:19 AM   #3
rahimlnx
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
No difference seen even after setting application thread priority in linux environment

Quote:
Originally Posted by ozanbaba View Post
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.
From the linux pthread documentation i came to know that we can raise the thread priority(between 0-99) with root privilages, same i am doing but expected result was not seen.I am working on Linux kernel 2.6.9.

I have referred below link

http://www.kernel.org/doc/man-pages/...edparam.3.html


Please comment on this.

Syed.
 
Old 11-21-2010, 08:06 AM   #4
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
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.
 
Old 11-21-2010, 08:15 AM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
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>
Most practical threads have some i/o wait. Other threads can execute during the time when a high priority thread is waiting for i/o.

These kinds of factors affect the amount of CPU requested by a high priority thread.

Last edited by stress_junkie; 11-21-2010 at 08:22 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
difference between an AIX thread and Linux thread sanjeebkdeka AIX 1 02-11-2010 09:37 AM
how to configure linux kernel thread for dynamic priority kishor chalukkil Linux - Newbie 0 04-18-2009 01:37 PM
How should i map Windows thread priority macros to Linux? patyogesh Linux - Newbie 3 11-12-2008 05:20 AM
Priority of Linux process/thread scanner Linux - Newbie 1 07-07-2006 12:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 03:13 PM.

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