Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Single UNIX Specification, Version 3 |
both | z/OS V1R9 |
#define _UNIX03_THREADS
#include <pthread.h>
#include <sched.h>
int pthread_attr_getschedparam(const pthread_attr_t *__restrict__ attr,
struct sched_param *__restrict__ param);
pthread_attr_getschedparam() gets the scheduling priority attribute from attr and stores it into param.
attr is a pointer to a thread attribute object initialized by pthread_attr_init().
param points to a user-defined scheduling parameter object into which pthread_attr_getschedparam() copies the thread scheduling priority attribute.
If successful, pthread_attr_getschedparam() returns 0; otherwise it returns an error number.
⁄* CELEBP63 *⁄
⁄* Example using SUSv3 pthread_attr_getschedparam() interface *⁄
#define _UNIX03_THREADS 1
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
int main(void)
{
pthread_attr_t attr;
int rc;
struct sched_param param;
param.sched_priority = 999;
if (pthread_attr_init(&attr) == -1) {
perror("error in pthread_attr_init");
exit(1);
}
rc = pthread_attr_setschedparam(&attr, ¶m);
if (rc != 0) {
printf("pthread_attr_setschedparam returned: %d\n", rc);
printf("Error: %d, Errno_Jr: %08x\n", errno, __errno2());
exit(2);
} else {
printf("Set schedpriority to %d\n", param.sched_priority);
}
param.sched_priority = 0;
rc = pthread_attr_getschedparam(&attr, ¶m);
if (rc != 0) {
printf("pthread_attr_getschedparam returned: %d\n", rc);
printf("Error: %d, Errno_Jr: %08x\n", errno, __errno2());
exit(3);
} else {
printf("Retrieved schedpriority of %d\n", param.sched_priority);
}
rc = pthread_attr_destroy(&attr);
if (rc != 0) {
perror("error in pthread_attr_destroy");
exit(4);
}
exit(0);
}