Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 8

sched_getparam()

Get the current scheduling parameters of a process

Synopsis:

#include <sched.h>

int sched_getparam( pid_t pid,
                    struct sched_param *param );

Arguments:

pid
The ID of the process whose scheduling parameters you want to get, or 0 to get them for the current process.
param
A pointer to a sched_param that the function fills with the scheduling parameters.

Library:

libc

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

Description:

The sched_getparam() function gets the current scheduling parameters (including the original and current priorities) of the process specified by pid, and puts them in the sched_param structure pointed to by param.

If pid is zero, function gets the parameters for the calling process.

Returns:

0
Success
-1
An error occurred (errno is set).

Errors:

EPERM
The calling process doesn't have sufficient privilege to get the scheduling parameters.
ESRCH
The process pid doesn't exist.

Examples:

#include <sched.h>
#include <stdio.h>

#define PRIORITY_ADJUSTMENT 5

int main (void)
{
   int max_priority;
   struct sched_param param;

   /* Find out the MAX priority for the FIFO Schedular */
   max_priority = sched_get_priority_max(SCHED_FIFO);

   /* Find out what the current priority is. */
   sched_getparam(0, &param);

   printf("The assigned priority is %d.\n", param.sched_priority);
   printf("The current priority is %d.\n", param.sched_curpriority);

   param.sched_priority = ((param.sched_curpriority +
   PRIORITY_ADJUSTMENT) <= max_priority) ?
      (param.sched_curpriority + PRIORITY_ADJUSTMENT) : -1;

   if (param.sched_priority == -1)
   {
      printf(
        "Cannot increase the priority by %d. Try a smaller value\n",
        PRIORITY_ADJUSTMENT);
      return(0);
   }

   sched_setscheduler (0, SCHED_FIFO, &param);

   sched_getparam(0, &qparam);
   printf("The newly assigned priority is %d.\n",
          param.sched_priority);
   printf("The current priority is %d.\n",
          param.sched_curpriority);
   return(0);
}

Classification:

POSIX 1003.1 PS

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

Caveats:

In a multithreaded program, sched_getparam() returns the scheduling parameters for thread 1 in the process pid, or for the calling thread if pid is 0.

See also:

errno, getprio(), sched_get_priority_max(), sched_get_priority_min(), sched_getscheduler(), sched_param, sched_setparam(), sched_setscheduler(), sched_yield(), setprio()

Thread scheduling in the QNX Neutrino Microkernel chapter of the System Architecture guide

Scheduling algorithms in the Programming Overview chapter of the QNX Neutrino Programmer's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 227

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sched_getparam.html on line 227