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 to SCHED_FIFO.
  • -o or --other: sets the schedule to SCHED_OTHER.
  • -r or --rr: sets schedule to SCHED_RR.
  • -d or --deadline: sets schedule to SCHED_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.

Table 12.1. Library functions for real-time scheduler
FunctionsDescription

sched_getscheduler()

Retrieves the scheduler policy for a specific process identifier (PID)

sched_setscheduler()

Sets the scheduler policy and other parameters. This function requires three parameters: sched_setscheduler(pid_t pid, int policy, const struct sched_param *sp);

sched_getparam()

Retrieves the scheduling parameters of a scheduling policy.

sched_setparam()

Sets the parameters associated with a scheduling policy that has been already set and can be verified using the sched_getparam() function.

sched_get_priority_max()

Returns the maximum valid priority associated with the scheduling policy.

sched_get_priority_min()

Returns the minimum valid priority associated with the scheduling policy .

sched_rr_get_interval()

Displays the allocated timeslice for each process.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.