response_time_analysis/wcet/mod.rs
1/*! Models of resource needs such as a task's scalar *worst-case execution time* (WCET)
2
3This module provides the trait [JobCostModel], which models the notion
4of the cumulative worst-case resource needs of one or more jobs of a
5task.
6
7The implementation most commonly encountered in the literature is
8[Scalar], which represents a WCET value as assumed by Liu & Layland. */
9
10use auto_impl::auto_impl;
11
12use crate::time::Service;
13
14/// The interface for models of per-job and per-job-sequence
15/// *maximum* execution costs.
16#[auto_impl(&, Box, Rc)]
17pub trait JobCostModel {
18 /// Model: yield the maximum cumulative processor demand of any
19 /// `n` consecutive jobs.
20 fn cost_of_jobs(&self, n: usize) -> Service {
21 self.job_cost_iter().take(n).sum()
22 }
23
24 /// Model: yield the WCET of the job with the least WCET among
25 /// any sequence of `n` consecutive jobs.
26 fn least_wcet(&self, n: usize) -> Service {
27 self.job_cost_iter()
28 .take(n)
29 .min()
30 .unwrap_or_else(Service::none)
31 }
32
33 /// Model: iterate the maximum WCETs of any sequence of consecutive jobs.
34 fn job_cost_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Service> + 'a>;
35}
36
37mod curve;
38mod multiframe;
39mod scalar;
40
41pub use curve::{Curve, ExtrapolatingCurve};
42pub use multiframe::Multiframe;
43pub use scalar::Scalar;
44
45#[cfg(test)]
46mod tests;