response_time_analysis/fifo/
rta.rs

1use crate::demand::{self, RequestBound};
2use crate::time::{Duration, Offset};
3use crate::{fixed_point, supply};
4
5/// Try to find a response-time bound for any task in a task set
6/// under FIFO scheduling on a dedicated uniprocessor.
7///
8/// The analysis assumes that all tasks are independent and that each
9/// is characterized by an arbitrary arrival curve and a WCET bound.
10/// The total rbf is represented by `tasks_rbf`
11///
12/// Note that all tasks share the same response-time bound under FIFO
13/// scheduling; hence this function does not take any parameters
14/// specific to a "task under analysis."
15///
16/// If no fixed point is found below the divergence limit given by
17/// `limit`, return a [SearchFailure][fixed_point::SearchFailure]
18/// instead.
19#[allow(non_snake_case)]
20pub fn dedicated_uniproc_rta<RBF>(tasks_rbf: &RBF, limit: Duration) -> fixed_point::SearchResult
21where
22    RBF: RequestBound + ?Sized,
23{
24    // This analysis is specific to dedicated uniprocessors.
25    let proc = supply::Dedicated::new();
26
27    // First, bound the maximum possible busy-window length.
28    let L = fixed_point::search(&proc, limit, |L| tasks_rbf.service_needed(L))?;
29
30    // Now define the offset-specific RTA.
31    let rta = |A: Offset| {
32        // Demand of all tasks
33        let total_service = tasks_rbf.service_needed(A.closed_since_time_zero());
34        // Extract the corresponding bound.
35        Duration::from(total_service) - A.since_time_zero()
36    };
37
38    // Third, define the search space. The search space is given by
39    // A=0 and each step below L of the task under analysis's RBF.
40    // The case of A=0 is not handled explicitly since
41    // `step_offsets()` necessarily yields it.
42    let max_offset = Offset::from_time_zero(L);
43    let search_space = demand::step_offsets(&tasks_rbf).take_while(|A| *A < max_offset);
44
45    // Apply the offset-specific RTA to each offset in the search space and
46    // return the maximum response-time bound.
47    Ok(search_space.map(rta).max().unwrap_or_else(Duration::zero))
48}