setprio()

Set the priority of a process

Synopsis:

#include <sched.h>

int setprio( pid_t pid, 
             int prio );

Arguments:

pid
The process ID of the process whose priority you want to set.
prio
The new priority.

In QNX Neutrino 6.6 or later, you can wrap the new priority in one these macros to specify how to handle out-of-range priority requests:

  • SCHED_PRIO_LIMIT_ERROR(prio) — indicate an error
  • SCHED_PRIO_LIMIT_SATURATE(prio) — use the maximum allowed priority (reach a "maximum saturation point")

If procnto was started with a -P option ending with s or S, out-of-range priority requests by default "saturate" at the maximum allowed value.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The setprio() function changes the priority of thread 1 of process pid to priority prio. If pid is zero, the priority of the calling thread is set.

Note: In order to set the priority for a thread whose real or saved user ID is different from the calling process's real or effective user ID, your process must have the PROCMGR_AID_SCHEDULE ability enabled. In order to change its priority to a value above the maximum permitted for unprivileged processes, your process must have the PROCMGR_AID_PRIORITY ability enabled. For more information, see procmgr_ability().

Returns:

The previous priority, or -1 if an error occurred (errno is set).

Errors:

EINVAL
The priority prio isn't a valid priority.
EPERM
The calling process doesn't have the required permission; see procmgr_ability().
ESRCH
The process pid doesn't exist.

Classification:

QNX 4

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

The getprio() and setprio() functions are included in the libraries for porting QNX 4 applications. For new programs, use sched_setparam(), pthread_setschedparam(), or pthread_setschedprio().