Skip to main content

Sched

Functions#

Name
intsched_get_priority_max(int policy)
intsched_get_priority_min(int policy)
intsched_getparam(pid_t pid, struct sched_param * param)
intsched_getscheduler(pid_t pid)
intsched_rr_get_interval(pid_t pid, struct timespec * ts)
intsched_setparam(pid_t pid, const struct sched_param * param)
intsched_setscheduler(pid_t pid, int policy, const struct sched_param * param)
intsched_yield()

Functions Documentation#

sched_get_priority_max#

int sched_get_priority_max(    int policy)

Return: Zero on success or -1 with errno (see Errno) set to:

  • EINVAL: policy is not SCHED_RR, SCHED_FIFO, or SCHED_OTHER

This function gets the maximum priority for policy.

sched_get_priority_min#

int sched_get_priority_min(    int policy)

Return: Zero on success or -1 with errno (see Errno) set to:

  • EINVAL: policy is not SCHED_RR, SCHED_FIFO, or SCHED_OTHER

This function gets the minimum priority for policy.

sched_getparam#

int sched_getparam(    pid_t pid,    struct sched_param * param)

Return: Zero on success or -1 with errno (see Errno) set to:

  • EINVAL: policy is not SCHED_RR, SCHED_FIFO, or SCHED_OTHER
  • ESRCH: pid is not a valid process

This function gets the scheduling parameter (priority) for pid.

Todocheck the permissions for EPERM

sched_getscheduler#

int sched_getscheduler(    pid_t pid)

Return: The scheduling policy on success or -1 with errno (see Errno) set to:

  • ESRCH: pid is not a valid process

This function gets the scheduling policy.

sched_rr_get_interval#

int sched_rr_get_interval(    pid_t pid,    struct timespec * ts)

Return: Zero on success or -1 with errno (see Errno) set to:

  • EINVAL: ts is NULL
  • ESRCH: pid is not a valid process

This function gets the round robin interval for pid.

sched_setparam#

int sched_setparam(    pid_t pid,    const struct sched_param * param)

Return: Zero on success or -1 with errno (see Errno) set to:

  • ESRCH: pid is not a valid process
  • EPERM: the calling process does not have permission to change the scheduling parameters

This function sets the process's scheduling paramater (priority).

sched_setscheduler#

int sched_setscheduler(    pid_t pid,    int policy,    const struct sched_param * param)

Return: Zero on success or -1 with errno (see Errno) set to:

  • EINVAL: policy is not SCHED_RR, SCHED_FIFO, or SCHED_OTHER
  • EPERM: the calling process does not have permission to change the scheduling parameters
  • ESRCH: pid is not a valid process

This function sets the scheduler policy and parameter (priority) for the process.

TodoSet the policy

sched_yield#

int sched_yield()

Return: Zero

This function causes the calling thread to yield the processor. The context is switched to the next active task. If no tasks are active, the CPU idles.


Updated on 18 September 2021 at 21:44:10 MDT