Example Programs:
KURT comes with sample programs which can be found in the
user_progs subdirectory of the distribution. These sample
programs are described below:
- make_sched: This
program generates a schedule file that can be used by the
executive process. make_sched can be used to generate periodic or
aperiodic schedules. To generate periodic schedules, use
make_sched period RTMod# num_events data_value bin_file
Where:
- period is the period in micro-seconds
between consecutive real-time events.
- RTMod# is the RTMOD that should be called
for each event.
- num_events is the number of events in the
schedule
- data_value is the data that should be
passed to the RTMod when it is invoked.
- bin_file is the output schedule file.
To generate aperiodic schedules, first generate an ASCII file
with one event per line in the following format:
time RTMod # Data Value
Then, use
make_sched -f ascii_file bin_file
(Note that for scheduling a real-time process, the RTMod# is 0
and the data_value is the rt_id of the process to be
scheduled.)
- rt_test: is an example of an executive
process. This process schedules the invocation of real-time
modules, including the process module. Usage is as follows:
rt_test sched_file rt_mode from_mem/from_disk repeat_num num_rtprocs rt_ids ...
Where
- sched_file is the schedule file that is
created using make_sched.
- rt_mode is the real-time mode that the
kernel should be switched to when scheduling the events.
See switch_to_rt for details on
the various modes.
- from_mem/from_disk specifies
whether to read the entire schedule into kernel memory or to
intermittently read it from disk while scheduling other
events.
- repeat_num is the number of times
to repeat the schedule in case the mode is from_mem.
- num_rtprocs is the number of real-time
processes that the executive process should wait for before
switching the kernel to real-time mode and starting to
schedule the events. This includes the executive process.
- rt_ids are the real-time ids of the
processes that the executive process is scheduling.
- proc: an example of a KURT process. This
program registers itself as a KURT process and enters into a
infinite loop. In the loop, it suspends itself and performs a
gettimeofday when it is woken up by the executive process
(rt_test). Usage is as follows:
proc rtid
- periodic: is an example of a periodic KURT
process. This program registers itself as a KURT process and
passes the processing requirements to the kernel, and then
enters into a infinite loop. In the loop, it suspends itself
and performs a gettimeofday when it is woken up by the executive
process (rt_test). You can also specify the number of KURT
processes that should be forked as well as the number of
iterations that each process should perform. The timing data
collected by each process is written to a file in the output
directory specified. Each of these files are named as pid.timing
(where pid is the process id of the process generating the
data). This application can also be used to compare the
performance of periodic process with SCHED_KURT as well as
SCHED_FIFO scheduling modes. SCHED_FIFO processes use the select
system call to schedule itself. Usage is as follows:
periodic rtid proc_req num_iters num_procs output_dir rt-1/rt-2/non-rt period
- run_rt: This program takes any application and
runs it as a real time process.
run_rt exec_filename params
- For example, run_rt bash runs bash as a
SCHED_KURT process.
- rtd: This is a daemon that continuously checks
whether any of a list of specified processes are running. It
then marks all such processes as realtime. This is useful in
making sure essential processes like kerneld etc run when the
kernel is in realtime mode.
rtd rtd.conf
- rtd.conf specifies the list of processes to look
for. If this parameter is not specified, then rtd
looks for /etc/rtd.conf.
KURT Examples
All these programs should be run in the KURT/user_progs
directory of the distribution.
Explicit Scheduling of User Processes Using a Schedule File
This sequence of commands will create a periodic schedule, switch
the kernel to real-time mode, and schedule a particular process
according to the created schedule. The scheduled process would go
into a loop, suspending itself at the beginning of the loop and
collect timestamps when it is woken up.
make_sched 1000 0 100 1 sched.bin
This creates a schedule file, called sched.bin, which has a
schedule for 100 KURT events. Each of these events would be 1000
microseconds apart. These events are for the RTMod 0 which is the
process module which switches context to a particular process.
The data that is passed to this module is 1, which is the rt_id of
the process that should be woken up.
proc 1
This starts a process which registers itself as a KURT process
with rt_id 1. It enters a loop, suspending itself and collecting
a timestamp whenever it wakes up. When this is started, proc will
suspend without doing anything.
In a different shell, run rt_test:
rt_test sched.bin rt-2 from_mem 3 1
This starts a scheduling process which waits for at least two
real-time processes to register themselves (this includes rt_test
itself). Once the processes are registered, it asks the kernel to
schedule the events in sched.bin using the RT_FROM_MEM (i.e. it
reads the entire schedule into memory before starting the
schedule). The schedule is repeated three times and then the
statistics about the real-time process with rt_id 1 is printed
out.
Explicit Scheduling of Periodic User Processes without Using a
Schedule File
The periodic example program performs a similar operation, using
only a single command:
periodic 1 600 300 1 ./ rt-2 1000
This forks off one child process which registers itself as a KURT
process with rt_id 1, processing requirement of 600 microseconds
and a period of 1000 microseconds. The parent then switches the
kernel to real-time mode 2 (in which all processes are allowed to
run, but KURT processes are explicitly scheduled) and then waits
for the child process to exit. The child process goes into a
loop, suspending at the beginning of the loop and then collects a
timestamp when it is woken up. This timestamp is written to a
file pid_rt_2.timing where pid is the PID of the process. As can
be seen in this example, there is no need to run a separate
scheduling process like rt_test.
Note on Using Real-Time Mode 1
Please be sure that if you are running real-time mode 1 then rtd
is running. rtd marks a set of required processes as real-time.
This set of processes is specified in a configuration file,
rtd.conf.
rtd rtd.conf
Other User Programs
In addition to the above user programs, there is run_rt which
allows the user to run any application as a KURT process. For
example, to run bash as a KURT process, use:
run_rt bash
KURT @ ITTC
Last modified: Fri Mar 24 13:01:37 CST 2000