View previous topic :: View next topic |
Author |
Message |
vsramesh Beginner
Joined: 15 May 2008 Posts: 3 Topics: 2
|
Posted: Wed Aug 19, 2009 1:48 pm Post subject: Posix threads(Pthreads) dispatching priority. |
|
|
Hello all.
I am working on a C++ program on z/OS v1.8. Mine is a multithreaded program which needs to control the dispatching priority of each thread as I want a thread to run in lower priority. I went through the run time library documentation for pthreads.. there is no function that can do the above mentionedgh I can created multiple threads which basically inherit the dispatching priority from the task address space. Can you guys please throw some light on this and if its not possible to do this using pthreads are they any alternatives I can pursue.
Thanks
Ramesh. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Aug 19, 2009 4:34 pm Post subject: |
|
|
vsramesh,
Googled result
You can set the priority attribute before creating the thread. The child thread is created with the new priority that is specified in the sched_param structure (this structure also contains other scheduling information).
It is always a good idea to get the existing parameters, change the priority, create the thread, and then reset the priority.
Code: |
#include <pthread.h>
#include <sched.h>
pthread_attr_t tattr;
pthread_t tid;
int ret;
int newprio = 20;
sched_param param;
/* initialized with default attributes */
ret = pthread_attr_init (&tattr);
/* safe to get existing scheduling param */
ret = pthread_attr_getschedparam (&tattr, ¶m);
/* set the priority; others are unchanged */
param.sched_priority = newprio;
/* setting the new scheduling param */
ret = pthread_attr_setschedparam (&tattr, ¶m);
/* with new priority specified */
ret = pthread_create (&tid, &tattr, func, arg);
|
Kolusu |
|
Back to top |
|
 |
vsramesh Beginner
Joined: 15 May 2008 Posts: 3 Topics: 2
|
Posted: Thu Sep 03, 2009 9:42 am Post subject: Thank you Kolusu. |
|
|
I saw the same link when I googled but to my dismay when I refer to z/OS v1.8 language reference which is the version of z/OS we are in there is no reference to functions like pthread_attr_setschedparam and pthread_attr_getschedparam so I understand these functions are not supported in z/OS 1.8. Hence am looking for alternatives .. !!
Thanks
Ramesh. |
|
Back to top |
|
 |
|
|