Chapter 12. RHEL for Real Time scheduler
RHEL for Real Time uses the command line utilities help you to configure and monitor process configurations.
12.1. chrt utility for setting the scheduler
The chrt
utility checks and adjusts scheduler policies and priorities. It can start new processes with the desired properties, or change the current properties of a running process.
The chrt
utility takes the either --pid
or the -p
option to specify the process ID (PID).
The chrt
utility takes the following policy options:
-
-f
or--fifo
: sets the schedule toSCHED_FIFO
. -
-o
or--other
: sets the schedule toSCHED_OTHER
. -
-r
or--rr
: sets schedule toSCHED_RR
. -
-d
or--deadline
: sets schedule toSCHED_DEADLINE
.
The following example shows the attributes for a specified process.
# chrt -p 468
pid 468’s current scheduling policy: SCHED_FIFO
pid 468’s current scheduling priority: 85
12.2. Preemptive scheduling
The real-time preemption is the mechanism to temporarily interrupt an executing task, with the intention of resuming it at a later time. It occurs when a higher priority process interrupts the CPU usage. Preemption can have a particularly negative impact on performance, and constant preemption can lead to a state known as thrashing. This problem occurs when processes are constantly preempted and no process ever gets to run completely. Changing the priority of a task can help reduce involuntary preemption.
You can check for voluntary and involuntary preemption occurring on a single process by viewing the contents of the /proc/PID/status
file, where PID is the process identifier.
The following example shows the preemption status of a process with PID 1000.
# grep voluntary /proc/1000/status
voluntary_ctxt_switches: 194529
nonvoluntary_ctxt_switches: 195338
12.3. Library functions for scheduler priority
The real-time processes use a different set of library calls to control policy and priority. The functions require the inclusion of the sched.h
header file. The symbols SCHED_OTHER
, SCHED_RR
and SCHED_FIFO
must also be defined in the sched.h
header file.
The table lists the functions that set the policy and priority for the real-time scheduler.
Functions | Description |
---|---|
| Retrieves the scheduler policy for a specific process identifier (PID) |
|
Sets the scheduler policy and other parameters. This function requires three parameters: |
| Retrieves the scheduling parameters of a scheduling policy. |
|
Sets the parameters associated with a scheduling policy that has been already set and can be verified using the |
| Returns the maximum valid priority associated with the scheduling policy. |
| Returns the minimum valid priority associated with the scheduling policy . |
|
Displays the allocated |