MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Posix threads(Pthreads) dispatching priority.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vsramesh
Beginner


Joined: 15 May 2008
Posts: 3
Topics: 2

PostPosted: Wed Aug 19, 2009 1:48 pm    Post subject: Posix threads(Pthreads) dispatching priority. Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 19, 2009 4:34 pm    Post subject: Reply with quote

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, &param);

/* set the priority; others are unchanged */
param.sched_priority = newprio;

/* setting the new scheduling param */
ret = pthread_attr_setschedparam (&tattr, &param);

/* with new priority specified */
ret = pthread_create (&tid, &tattr, func, arg);


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vsramesh
Beginner


Joined: 15 May 2008
Posts: 3
Topics: 2

PostPosted: Thu Sep 03, 2009 9:42 am    Post subject: Thank you Kolusu. Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group