Post by Chih-Chung ChangPost by Wan-Teh ChangI'm also worried about using a function that
is not part of the pthread library. It may
have unforseen interaction with the pthread
library.
I found the interaction is defined, but Linux
http://www.opengroup.org/onlinepubs/009695399/functions/setpriority.html
I quote the relevant text from that page:
The nice value set with setpriority() shall be
applied to the process. If the process is
multi-threaded, the nice value shall affect
all system scope threads in the process.
Any processes or threads using SCHED_FIFO or
SCHED_RR shall be unaffected by a call to
setpriority(). This is not considered an error.
A process which subsequently reverts to
SCHED_OTHER need not have its priority affected
by such a setpriority() call.
This interaction does not seem desirable. It
seems that setpriority sets a different kind of
priority called a "nice value". It's not clear
what the relation between a nice value and a
pthread's priority is.
Post by Chih-Chung ChangPost by Wan-Teh ChangDoes your code rely on thread priorities?
Yes, it is a video player, and a high priority
thread is used to ensure images can be displayed
on screen at regular intervals.
Can you achieve that without relying on thread
priorities?
Can you use thread synchronization (mutex +
condition variable) to ensure that the image
display thread gets an opportunity to run
at regular intervals?
Thread priorities are not portable. In most
cases, proper thread synchronization rather
than thread priority is the right solution.
Wan-Teh