Response time analysis WCRT Liu and Layland, implementation

3 views (last 30 days)
I need to compute the WCRT for tasks using the Liu and Layland equation, how is this done in matlab.
Here c1=2, c2=2, c3=5. Thanks!

Accepted Answer

Filip Markovic
Filip Markovic on 25 Feb 2021
Hi Eli,
Maybe this can help:
Here I defined the function "rt", and it uses the "rtsum" function which is described after the "rt" function. You just need to provide the array C of task execution times, and also the array T of task periods. If you use fixed-priority scheduling, then just sort C and T arrays in the increasing priority order. I implemented this without using the recursion, I tried to optimise the code a bit. Maybe it can be optimised even more.
function [Ri] = rt(i,C,T,D_i)
% Function rt(i,C,T,D_i) computes response time of the i-th task in the taskset
% given the index of the task, array of WCET values and array of periods.
% It stops immediately if R_i is greater than D_i, and returns R_i.
% Syntax:
% Ri = rt(i,C,T)
% Input:
% i, index of the task under analysis
% C, array of WCET values
% T, Array of minimum inter-arrival times
% D_i, Relative deadline of the i-th task
% Output:
% Ri, response time of tau_i
Ri = C(i);
R_i_next = rtsum(i,Ri,C,T);
while(Ri ~= R_i_next && Ri < D_i )
Ri = R_i_next;
R_i_next = rtsum(i,Ri,C,T);
end
And here is the "rtsum" function:
function [R] = rtsum(i,t,C,T)
% Function rtsum(i,t,C,T) computes the WCET workload for the i-th task, given the
% duration 't', array 'C' of WCETs values, and array 'T' of periods
% Syntax:
% R = Rsum(i,t,C,T)
% Input:
% i, index of the task under analysis
% t, time duration under analysis
% C, array of WCET values
% T, Array of minimum inter-arrival times
% Output:
% R, response time sum
sum = C(i);
for h = 1:i-1
sum = sum + ceil(t/T(h)) * C(h);
end
R = sum;

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!