SchedInfo(), SchedInfo_r()

Get scheduler information

Synopsis:

#include <sys/neutrino.h>

int SchedInfo( pid_t pid, 
               int policy,
               struct _sched_info* info );

int SchedInfo_r( pid_t pid, 
                 int policy,
                 struct _sched_info* info );

Arguments:

pid
A process ID, or 0 to get information about the current process.
policy
One of the following:
  • SCHED_FIFO — a fixed-priority scheduler in which the highest priority, ready thread runs 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 timeslice (round robin) every 4 × the clock period (see ClockPeriod()).
  • SCHED_OTHER — currently the same as SCHED_RR.
  • SCHED_SPORADIC — sporadic scheduling. For more information, see pthread_attr_setschedpolicy(), and Scheduling policies in the chapter on the microkernel in the System Architecture guide.
info
A pointer to a _sched_info structure where the function can store the scheduler information.

Library:

libc

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

Description:

These kernel calls return information about the kernel's thread scheduler, including the minimum and maximum thread priority, for the process ID specified by pid when using the specified scheduling policy. If pid is 0, the scheduler information for the current process is returned. In either case, the struct _sched_info pointed to by info is filled in with the appropriate information.

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

Note: Instead of using these kernel calls directly, consider calling sched_get_priority_max(), sched_get_priority_min(), or sched_rr_get_interval().

The struct _sched_info structure pointed to by info contains at least these members:

uint64_t interval
The execution time limit (what POSIX calls the “time quantum”) before the scheduler suspends the thread. If the scheduling policy is SCHED_RR or SCHED_OTHER, this is the timeslice in nanoseconds; for SCHED_FIFO and SCHED_SPORADIC, it's 0.
int priority_max
The maximum priority for a thread using the scheduling policy.
int priority_min
The minimum priority for a thread using the scheduling policy.

Returns:

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

SchedInfo()
If an error occurs, -1 is returned and errno is set. Any other value returned indicates success.
SchedInfo_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:

EINVAL
The pid or policy is invalid.
ESRCH
The process specified by pid doesn't exist.

Classification:

QNX Neutrino

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