Thread priority scheduling across linux kernels.

Thread priority scheduling across linux kernels.

Post by Jyoti Wagholik » Mon, 30 Aug 2004 21:55:10



Hi,

    I have come across some strange behaviour of
priority base scheduling of threads across linux
kernels.

   The program below shows that main priority is
raised to max = 99. Another thread with priority =30
is created.    

void main()
{
struct sched_param schedparam, getparam,
taskschedparam;
int policy, status;
pthread_attr_t attribs;

pthread_t id =pthread_self();

/* Raising main priority to max =99 */
schedparam.__sched_priority
=sched_get_priority_max( SCHED_FIFO );
pthread_setschedparam(id, SCHED_FIFO, &schedparam);
pthread_getschedparam(id,&policy , &getparam);
printf("\n main  :  priority = %d, policy = %d",
getparam.__sched_priority, policy);

/* First Assign default attributes for the thread */
pthread_attr_init(&attribs);

/*Set stack size as specified by user*/
attribs.__stacksize = 10000;

/*set scheduling policy*/
pthread_attr_setschedpolicy(&attribs, SCHED_FIFO);

/*Set task priority*/
taskschedparam.__sched_priority = 30;
pthread_attr_setschedparam(&attribs, &taskschedparam);

status = pthread_create(&firstTask, &attribs,  
task_fun1, (void*)1 );
printf("\n main :first task = %d,firstTask);
fflush(stdout);

sleep(10000);

Quote:}

void *task_fun1 ( void *param)
{
struct sched_param schedparam, getparam ;
int policy;  

pthread_getschedparam(pthread_self(),&policy ,
&getparam);
printf("\n task_fun1: priority = %d, policy = %d",
getparam.__sched_priority, policy);fflush(stdout);
printf("\n FIRST TASK = %x", firstTask);
fflush(stdout);

Quote:}

Ouputs:
Redhat: 7.2 :[CORRECT OUTPUT]
main  :  priority = 99, policy = 1
pthread_create status = 0
main :first task = 1026
Sleeping for 1000 sec
task_fun1: priority = 30, policy = 1
FIRST TASK = 402

Redhat: 9.0
main  :  priority = 99, policy = 1
task_fun1: priority = 0, policy = 0
FIRST TASK = 40838cc0
pthread_create status = 0
main :first task = 1082363072
Sleeping for 1000 sec

Just wondering if there is any inconsistency in the
priority scheduling across linux version: linux
2.4.20-8(Redhat 9.0) linux 2.4.7(Redhat 7.2).

Has anyone come across this problem earlier? Any
solution to overcome it?

Your input will be helpful.

thanks and regards,
-Jyoti

 
 
 

Thread priority scheduling across linux kernels.

Post by Dan Kege » Tue, 31 Aug 2004 15:13:58



>     I have come across some strange behaviour of
> priority base scheduling of threads across linux
> kernels.

>    The program below shows that main priority is
> raised to max = 99. Another thread with priority =30
> is created.    
> ...

> Ouputs:
> Redhat: 7.2 :[CORRECT OUTPUT]
> main  :  priority = 99, policy = 1
> pthread_create status = 0
> main :first task = 1026
> Sleeping for 1000 sec
> task_fun1: priority = 30, policy = 1
> FIRST TASK = 402

> Redhat: 9.0
> main  :  priority = 99, policy = 1
> task_fun1: priority = 0, policy = 0
> FIRST TASK = 40838cc0
> pthread_create status = 0
> main :first task = 1082363072
> Sleeping for 1000 sec

> Just wondering if there is any inconsistency in the
> priority scheduling across linux version: linux
> 2.4.20-8(Redhat 9.0) linux 2.4.7(Redhat 7.2).

Sure, there have been lots of changes.  Threads in particular
changed; Red Hat 9 uses NPTL, which is a totally different
interface than the traditional LinuxThreads.  Also
I seem to recall that new processes/threads start up
much sooner on recent kernels.

So what's the problem?  You haven't explained why the
new behavior is better or worse for you.
Basically, if you want your program to run across
many versions of Linux, you're going to have to
accept some variations.
- Dan

 
 
 

1. Linux kernel scheduling of kernel-space thread - question

Hello!

Can anyone explain how linux schedules kernel-space threads created with
clone()?

Do kernel-space threads behave the same as normal linux processes, in terms
of scheduling I mean? Are they scheduled in the same way as normal processes
are and is their scheduling done by the same scheduler?

Does every created kernel-space thread have it's own task_struct created and
added in kernel's process list for scheduling? What is the role of
thread_struct inside task_struct of every process and has it anything to do
with thread scheduling?

Thanx,

Best regards,                        

                                        Mario Zagar                        

2. low outgoing throughput over CSLIP

3. Linux kernel scheduling of kernel-space threads - question

4. Sound problem!

5. thread scheduling and priority

6. fd open limit?

7. Quick Q on kernel threads and RT thread priorities

8. How to determine whether a given pid is up & running

9. Thread scheduling: priority meaningless?

10. Thread Scheduling Priorities

11. Performance improvements binding threads to CPUs or thread priorities

12. Thread scheduling in Solaris threads

13. HELP:kernel thread scheduling