- access dynamic thread scheduling
cc –mt [ flag... ] file...[ library... ] #include <thread.h> int thr_setprio(thread_t target_thread, int priority);
int thr_getprio(thread_t target_thread, int *priority);
The thr_setprio() function dynamically changes the priority of the thread specified by target_thread within the current process to the priority specified by priority. By default, threads contend for synchronization objects based on fixed priorities that range from 0, the least significant, to 127. The target_thread will receive precedence by libthread over lower priority threads with respect to synchronization object contention.
The thr_getprio() function stores the current priority for the thread specified by target_thread in the location pointed to by priority. Thread priorities regulate the order in which threads unblock from synchronization objects and are different from realtime priorities, which regulate and enforce access to CPU resources. Programs that need access to "real" priorities should use bound threads in the realtime class (see priocntl(2)).
If successful, the thr_getprio() and thr_setprio() return 0. Otherwise, an error number is returned to indicate the error.
For each of the following conditions, these functions return an error number if the condition is detected.
The value specified by target_thread does not refer to an existing thread.
The thr_getprio() and thr_setprio() functions may fail if:
The value of priority makes no sense for the scheduling class associated with the target_thread.
See attributes(5) for descriptions of the following attributes: