setPriority¶
Synopsis¶
#include <sys/threads.h>
int setPriority(int val);
Status¶
Implemented
Conformance¶
Phoenix-RTOS specific
Description¶
The setPriority() function shall set the base priority of the calling thread to val.
The priority range supported by the kernel is signed, with lower values denoting higher criticality. It shall be
queried at runtime with schedInfo() for the SCHED_RR policy rather than hardcoded, because it depends on the
kernel NPRIOS configuration. The default thread priority is PH_PRIO_DEFAULT.
val is a native priority. It is not the POSIX priority taken by sched_setparam() or pthread_setschedprio(),
whose range is inverted and reported by sched_get_priority_min() and sched_get_priority_max(). See
Scheduling priorities.
Use setPriority() instead of setpriority() or nice(), which don’t change the priority when
__PHOENIX_NICE_IGNORED is defined.
Setting the priority affects the base priority of the thread only. If the thread currently holds a mutex that raised its effective priority (through priority inheritance or the priority ceiling protocol), the effective priority shall not be reduced below the inherited one until the mutex is unlocked.
Lowering the priority of the calling thread may cause an immediate reschedule.
setPriority() replaces the deprecated priority() function.
Return value¶
If successful, the setPriority() function shall return zero; otherwise, an error number shall be returned to
indicate the error.
Errors¶
The setPriority() function shall fail if:
-EINVAL-valis not a valid priority value.