Scheduling
RealTimeScheduling implements a simple yet flexible scheduling simulator supporting preemptive global job-level fixed priority scheduling of TaskSystem
structs. It also supports generating plots of the resulting schedules using the Plots.jl package.
using RealTimeScheduling, Plots
T = TaskSystem([PeriodicImplicitTask(3, 2), PeriodicImplicitTask(3, 2), PeriodicImplicitTask(3, 2)])
s = schedule_gedf(T, 2, 30.)
plot(s, size=(600, 300))
RealTimeScheduling.schedule_global
— Functionschedule_global(release!, T, m, endtime; kill=false, pass_schedule=false)
Simulate a preemptive global schedule of task system T
on m
processors to the specified endtime
. When releasing a job, the function release!(job)
is called, allowing arbitrary modifications to be made, enabling a wide variety of global schedulers to be implemented. Three examples are provided: schedule_gfp
, schedule_gedf
, and schedule_gfl
.
The job
provided to release!(job)
defaults to being released as early as possible (i.e. at time 0 or one period after the task's last job), and has the relative deadline and cost specified by the task. The priority defaults to the task's index in T
, with lower priority values being treated as higher priority by the scheduler.
If kill
is true
, jobs are killed at their deadline if they have not yet completed.
If pass_schedule
is true
, the release!
function is passed a second argument containing the schedule up until the job's release.
RealTimeScheduling.schedule_gedf
— Functionschedule_gedf(T, m, time; kill=false)
Simulate a preemptive global earliest-deadline-first (GEDF) schedule of task system T
on m
processors for the specified time
.
If kill
is true
, jobs are killed at their deadline if they have not yet completed.
See also schedule_global
for more general global scheduling.
RealTimeScheduling.schedule_gfl
— Functionschedule_gfl(T, m, time; kill=false)
Simulate a preemptive global fair lateness (GFL) schedule of task system T
on m
processors for the specified time
. This provides the lowest tardiness bounds of any GEDF-like scheduler under compliant vector analysis; for more information, see Erickson, "Managing Tardiness Bounds and Overload in Soft Real-Time Systems." DOI: 10.17615/fvp3-q039.
If kill
is true
, jobs are killed at their deadline if they have not yet completed.
See also schedule_global
for more general global scheduling.
RealTimeScheduling.schedule_gfp
— Functionschedule_gfp(T, m, time; kill=false)
Simulate a preemptive global fixed priority (GFP) schedule of task system T
on m
processors for the specified time
. Tasks are prioritized by their index in T
, lowest index first.
If kill
is true
, jobs are killed at their deadline if they have not yet completed.
See also schedule_global
for more general global scheduling.
RealTimeScheduling.AbstractSchedule
— TypeAbstractSchedule{T}
Abstract supertype for all real-time schedules.
RealTimeScheduling.AbstractTaskSchedule
— TypeAbstractTaskSchedule{T}
Abstract supertype for all real-time schedules of task systems.
RealTimeScheduling.RealTimeTaskSchedule
— TypeRealTimeTaskSchedule{T}(tasks::AbstractRealTimeTaskSystem, jobs::Vector{Vector{T}})
Schedule of a real-time task system.
RealTimeScheduling.RealTimeTaskSchedule
— MethodRealTimeTaskSchedule(T::Type, tasks::AbstractRealTimeTaskSystem)
Create a RealTimeTaskSchedule{T}
with an empty job list for each task.
Concrete Jobs
Schedule objects contain a Vector
of Vector
s of AbstractJob
objects. These contain all the parameters of a concrete real-time job: release
, deadline
, cost
, and priority
, as well as a Vector
of ExecInterval
objects.
RealTimeScheduling.AbstractJob
— TypeAbstractJob
Abstract supertype for all real-time jobs.
RealTimeScheduling.AbstractJobOfTask
— TypeAbstractJobOfTask{T}
Abstract supertype for all real-time jobs of tasks.
RealTimeScheduling.Job
— TypeJob{S}(release::S, deadline::S, cost::S, priority::S, exec::Vector{ExecInterval{S}}
A real-time job with the given parameters, executing over the intervals in exec
.
RealTimeScheduling.JobOfTask
— TypeJobOfTask{S, T}(task::T, release::S, deadline::S, cost::S, priority::S, exec::Vector{ExecInterval{S}}
A real-time job of the given task
with the given parameters, executing over the intervals in exec
.
RealTimeScheduling.task
— Methodtask(j::AbstractJobOfTask)
Return the task associated with job j
.
RealTimeScheduling.release
— Methodrelease(j::AbstractJob)
Return the release time of job j
.
RealTimeScheduling.deadline
— Methoddeadline(j::AbstractJob)
Return the absolute deadline of job j
.
RealTimeScheduling.cost
— Methodcost(j::AbstractJob)
Return the execution cost of job j
.
RealTimeScheduling.priority
— Methodpriority(j::AbstractJob)
Return the priority of job j
.
RealTimeScheduling.exec
— MethodRealTimeScheduling.exectime
— Methodexectime(j::AbstractJob)
Return the total time occupied by all execution intervals of job j
.
See also exec
.
RealTimeScheduling.completed
— Methodcompleted(j::AbstractJob)
Return whether the job j
has completed, i.e., whether exectime(j) >= cost(j)
.
RealTimeScheduling.completiontime
— Methodcompletiontime(j::AbstractJob)
Return the absolute completion time of job j
, if it has completed. Throw an ArgumentError
otherwise.
RealTimeScheduling.responsetime
— Methodresponsetime(j::AbstractJob)
Return the response time of job j
, if it has completed. Throw an ArgumentError
otherwise.
RealTimeScheduling.ExecInterval
— TypeExecInterval{S}(start::S, stop::S, proc::Int)
Interval type for job execution, with a specified processor index. Always assumed to be half open, i.e., [start, stop)
.