Scheduling policy for threads

The scheduling policy contains many possible values for threads.

SCHED_FIFO
After a thread with this policy is scheduled, it runs to completion unless it is blocked, it voluntarily yields control of the processor, or a higher-priority thread becomes dispatchable. Only fixed-priority threads can have a SCHED_FIFO scheduling policy.
SCHED_RR
When a SCHED_RR thread has control at the end of the time slice, it moves to the tail of the queue of dispatchable threads of its priority. Only fixed-priority threads can have a SCHED_RR scheduling policy.
SCHED_OTHER
The POSIX Standard 1003.4a defines this policy as implementation-defined. The recalculation of the priority value of the running thread at each clock interrupt means that a thread might lose control because its priority value becomes more than another dispatchable thread.
SCHED_FIFO2
The policy is the same as for SCHED_FIFO. However, it allows a thread that slept for only a short amount of time to be put at the head of its run queue when it is awakened. This time period is the affinity limit (tunable with schedo -o affinity_lim).
SCHED_FIFO3
A thread whose scheduling policy is set to SCHED_FIFO3 is always put at the head of a run queue. To prevent a thread that belongs to the SCHED_FIFO2 scheduling policy from being put ahead of SCHED_FIFO3, the run queue parameters are changed when a SCHED_FIFO3 thread is enqueued so that no thread that belongs to SCHED_FIFO2 satisfies the criterion that enables it to join the head of the run queue.
SCHED_FIFO4
A higher priority SCHED_FIFO4 scheduling class thread does not preempt the currently running low-priority thread if their priorities differ by a value of 1. The default behavior is the preemption of the currently running low-priority thread on a specified CPU by a high-priority thread that becomes eligible to run on the same processor.
waitlock_policy

The waitlock_policy is a schedo tunable parameter that determines the algorithm that must be used to wake up sleepers on a user lock..

The following values are the valid values of the waitlock_policy tunable parameter:
  • 0: Specifies the traditional policy where all the threads on the wait list are searched to awaken the highest priority thread.
  • 1: Specifies the first-in first-out (FIFO) policy where the first thread on the wait list is awakened.
  • 2: Specifies the QUEUED policy where the wake-ups of all other threads are blocked except for the wake-ups of the calling thread and awakens high priority thread or the FIFO thread if FIFO (1) is also set.
  • 3: Specifies the QFIFO policy where the wake-ups of all other threads are blocked except for the wake-ups of the calling thread and awakens the FIFO thread.
  • 4: Specifies the PRIOQ policy where the wake-ups of all other threads are blocked except for the wake-ups of the calling thread and awakens the first thread on the wait list.

The scheduling policies are set with the thread_setsched() system call and are only effective for the calling thread. However, a thread can be set to the SCHED_RR scheduling policy by issuing a setpri() system call specifying the process ID. The caller of the setpri() system call and the target of the setpri() system call do not have to match.

Only processes that have root authority can issue the setpri() system call. Only threads that have root authority can change the scheduling policy to any of the SCHED_FIFO options or SCHED_RR. If the scheduling policy is SCHED_OTHER, the priority parameter is ignored by the thread_setsched() subroutine.

Threads are primarily of interest for applications that currently consist of several asynchronous processes. These applications might impose a lighter load on the system if converted to a multithreaded structure.