[Previous] [Contents] [Next]

SchedSet(), SchedSet_r()

Set the scheduling policy for a thread

Synopsis:

#include <sys/neutrino.h>

int SchedSet( 
       pid_t pid,
       int tid,
       int policy,
       const struct sched_param * param );

int SchedSet_r(
       pid_t pid,
       int tid,
       int policy,
       const struct sched_param * param );

Library:

libc

Description:

The SchedSet() and SchedSet_r() functions are identical except in the way they indicate errors. See the Returns section for details.

These kernel calls set both the scheduling policy and the associated parameters for the thread specified by tid in the process specified by pid. If pid is zero the current process is used to look up a nonzero tid. If tid is zero, then the calling thread is used and pid is ignored.

There are 4 scheduling policies defined which may be passed as the policy argument:

Policy Description
SCHED_FIFO A fixed priority scheduler in which the highest priority ready thread will run until it blocks or is preempted by a higher priority thread.
SCHED_RR The same as SCHED_FIFO except threads at the same priority level will time slice (round robin) every 50 msec.
SCHED_OTHER Currently the same as SCHED_RR.
SCHED_NOCHANGE This isn't actually a policy but a special value which tells the kernel to update the parameters specified in param without changing the policy.

The param argument contains at least the following members:

Member Description
int sched_priority The thread priority.

The sched_priority member in param must lie between the minimum and maximum values returned by sched_get_priority_min() and sched_get_priority_max() for the specified scheduling policy.

Blocking states

These calls don't block.

Returns:

The only difference between these functions is the way they indicate errors:

SchedSet()
If an error occurs, -1 is returned and errno is set. Any other value returned indicates success.
SchedSet_r()
EOK is returned on success. This function does NOT set errno. If an error occurs, any value in the Errors section may be returned.

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers you provided.
EINVAL
The given scheduling policy is invalid.
EPERM
The process doesn't have permission to change the scheduling of the indicated thread.
ESRCH
The process indicated by pid or thread indicated by tid doesn't exist.

Classification:

QNX 6

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

See also:

SchedGet(), SchedInfo(), SchedYield()


[Previous] [Contents] [Next]