1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447 | ------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Cheddar is a GNU GPL real-time scheduling analysis tool.
-- This program provides services to automatically check schedulability and
-- other performance criteria of real-time architecture models.
--
-- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand,
-- Hai Nam Tran, Stephane Rubini
--
-- The Cheddar project was started in 2002 by
-- Frank Singhoff, Lab-STICC UMR CNRS 6285, Universite de Bretagne Occidentale
--
-- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008.
-- Since 2008, Ellidiss technologies also contributes to the development of
-- Cheddar and provides industrial support.
--
-- The full list of contributors and sponsors can be found in README.md
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
--
-- Contact : cheddar@listes.univ-brest.fr
--
------------------------------------------------------------------------------
-- Last update :
-- $Rev: 4589 $
-- $Date: 2023-09-29 16:02:19 +0200 (ven., 29 sept. 2023) $
-- $Author: singhoff $
------------------------------------------------------------------------------
------------------------------------------------------------------------------
with Text_IO; use Text_IO;
with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Systems; use Systems;
with Caches; use Caches;
with Cache_Set; use Cache_Set;
with CFG_Nodes; use CFG_Nodes.CFG_Nodes_Table_Package;
with CFG_Nodes; use CFG_Nodes;
with CFG_Nodes_Builder; use CFG_Nodes_Builder;
with initialize_framework; use initialize_framework;
with CFG_Set; use CFG_Set;
with CFG_Edges; use CFG_Edges;
with CFG_Node_Set; use CFG_Node_Set;
with CFG_Edge_Set; use CFG_Edge_Set;
with unbounded_strings; use unbounded_strings;
with unbounded_strings; use unbounded_strings.strings_table_package;
with unbounded_strings; use unbounded_strings.unbounded_string_list_package;
with Call_Framework; use Call_Framework;
with Integer_Arrays; use Integer_Arrays;
with Basic_Block_Analysis; use Basic_Block_Analysis;
with CFGs; use CFGs;
with CFG_Node_Set.Basic_Block_Set; use CFG_Node_Set.Basic_Block_Set;
with Basic_Blocks; use Basic_Blocks;
with CFG_Nodes.Extended; use CFG_Nodes.Extended;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Call_Cache_Framework; use Call_Cache_Framework;
with Processor_Set; use Processor_Set;
with Scheduler_Interface; use Scheduler_Interface;
with Core_Units; use Core_Units;
with Address_Space_Set; use Address_Space_Set;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with GNAT.Current_Exception; use GNAT.Current_Exception;
with Text_IO; use Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with unbounded_strings; use unbounded_strings;
use unbounded_strings.strings_table_package;
use unbounded_strings.unbounded_string_list_package;
with unbounded_strings; use unbounded_strings;
with Parameters; use Parameters;
with Parameters.extended; use Parameters.extended;
use Parameters.Framework_Parameters_Table_Package;
with Systems; use Systems;
with Framework; use Framework;
with Call_Framework; use Call_Framework;
with Call_Framework_Interface; use Call_Framework_Interface;
use Call_Framework_Interface.Framework_Response_Package;
use Call_Framework_Interface.Framework_Request_Package;
with Call_Scheduling_Framework; use Call_Scheduling_Framework;
with Multiprocessor_Services; use Multiprocessor_Services;
with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface;
with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface.Scheduling_Result_Per_Processor_Package;
with GNAT.Command_Line;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Version; use Version;
with Ada.Exceptions; use Ada.Exceptions;
with Time_Unit_Events; use Time_Unit_Events;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with architecture_models; use architecture_models;
with Ada.Directories; use Ada.Directories;
with Scheduler; use Scheduler;
with architecture_factory; use architecture_factory;
with Debug; use Debug;
with Scheduler.Fixed_Priority.Rm; use Scheduler.Fixed_Priority.Rm;
with Scheduler.Dynamic_Priority.Edf; use Scheduler.Dynamic_Priority.Edf;
with Scheduler.Fixed_Priority.Hpf; use Scheduler.Fixed_Priority.Hpf;
with Framework_Config; use Framework_Config;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Cache_Utility; use Cache_Utility;
with Ada.Numerics;
with Ada.Numerics.Elementary_Functions;
with Ada.Numerics.Float_Random;
with Caches; use Caches.Cache_Blocks_Table_Package;
with Cache_Block_Set; use Cache_Block_Set;
with Scheduling_Analysis; use Scheduling_Analysis;
with Cache_Access_Profile_Set; use Cache_Access_Profile_Set;
with Time_Unit_Events; use Time_Unit_Events.Time_Unit_Package;
with test_case_generator; use test_case_generator;
with scheduling_simulation_util; use scheduling_simulation_util;
with Message_Set; use Message_Set;
with Feasibility_Test; use Feasibility_Test;
with feasibility_test.periodic_task_worst_case_response_time_fixed_priority;
use feasibility_test.periodic_task_worst_case_response_time_fixed_priority;
with Scheduling_Analysis; use Scheduling_Analysis.Double_Tasks_Parameters_Package;
with GNAT.String_Split; use GNAT.String_Split;
package body wcrt_crpd_util is
procedure Test_WCRT_CRPD
is
my_scheduler : Hpf_Scheduler;
my_tasks : Tasks_Set;
processor_name : Unbounded_String;
msg : Unbounded_String;
--response_time : Response_Time_Table;
CRPD_Computation_Approach : CRPD_Computation_Approach_Type := ECB_Union_Multiset;
Block_Reload_Time : Natural := 1;
My_CAPs : Cache_Access_Profiles_Set;
cap_1 : Cache_Access_Profile_Ptr;
cap_2 : Cache_Access_Profile_Ptr;
cap_3 : Cache_Access_Profile_Ptr;
a_cache_block : Cache_Block_Ptr;
a_cache_block_tbl : Cache_Blocks_Table;
response_time : Response_Time_Table;
begin
Set_Initialize;
for i in 0..3 loop
a_cache_block := new Cache_Block;
a_cache_block.cache_block_number := i+1;
Add(a_cache_block_tbl,a_cache_block);
end loop;
cap_1 := new Cache_Access_Profile;
cap_1.name := To_Unbounded_String("CAP_1");
Add(cap_1.ECBs, a_cache_block_tbl.Entries(0));
Add(cap_1.ECBs, a_cache_block_tbl.Entries(1));
Add(cap_1.ECBs, a_cache_block_tbl.Entries(2));
cap_2 := new Cache_Access_Profile;
cap_2.name := To_Unbounded_String("CAP_2");
Add(cap_2.UCBs, a_cache_block_tbl.Entries(2));
--
Add(cap_2.ECBs, a_cache_block_tbl.Entries(2));
Add(cap_2.ECBs, a_cache_block_tbl.Entries(3));
cap_3 := new Cache_Access_Profile;
cap_3.name := To_Unbounded_String("CAP_3");
Add(cap_3.UCBs, a_cache_block_tbl.Entries(0));
Add(cap_3.UCBs, a_cache_block_tbl.Entries(1));
Add(cap_3.UCBs, a_cache_block_tbl.Entries(2));
Add(cap_3.UCBs, a_cache_block_tbl.Entries(3));
--
Add(cap_3.ECBs, a_cache_block_tbl.Entries(0));
Add(cap_3.ECBs, a_cache_block_tbl.Entries(1));
Add(cap_3.ECBs, a_cache_block_tbl.Entries(2));
Add(cap_3.ECBs, a_cache_block_tbl.Entries(3));
Add(My_CAPs,cap_1);
Add(My_CAPs,cap_2);
Add(My_CAPs,cap_3);
Add_Task(My_Tasks => my_tasks,
Name => To_Unbounded_String("Task_1"),
Cpu_Name => To_Unbounded_String("CPU_A"),
Address_Space_Name => To_Unbounded_String("ADDR_A"),
Task_Type => Periodic_Type,
Start_Time => 0,
Capacity => 1,
Period => 40,
Deadline => 40,
Jitter => 0,
Blocking_Time => 0,
Priority => 3,
Criticality => 0,
Policy => Sched_Fifo,
Cache_Access_Profile_Name => To_Unbounded_String("CAP_1"));
Add_Task(My_Tasks => my_tasks,
Name => To_Unbounded_String("Task_2"),
Cpu_Name => To_Unbounded_String("CPU_A"),
Address_Space_Name => To_Unbounded_String("ADDR_A"),
Task_Type => Periodic_Type,
Start_Time => 0,
Capacity => 2,
Period => 40,
Deadline => 40,
Jitter => 0,
Blocking_Time => 0,
Priority => 2,
Criticality => 0,
Policy => Sched_Fifo,
Cache_Access_Profile_Name => To_Unbounded_String("CAP_2"));
Add_Task(My_Tasks => my_tasks,
Name => To_Unbounded_String("Task_3"),
Cpu_Name => To_Unbounded_String("CPU_A"),
Address_Space_Name => To_Unbounded_String("ADDR_A"),
Task_Type => Periodic_Type,
Start_Time => 0,
Capacity => 2,
Period => 40,
Deadline => 40,
Jitter => 0,
Blocking_Time => 0,
Priority => 1,
Criticality => 0,
Policy => Sched_Fifo,
Cache_Access_Profile_Name => To_Unbounded_String("CAP_3"));
periodic_task_worst_case_response_time_fixed_priority.Compute_Response_Time
(My_Scheduler => my_scheduler,
My_Tasks => my_tasks,
Processor_Name => To_Unbounded_String("CPU_A"),
Msg => msg,
Response_Time => response_time,
With_CRPD => True,
CRPD_Computation_Approach => CRPD_Computation_Approach,
Block_Reload_Time => Block_Reload_Time,
My_Cache_Access_Profiles => My_CAPs);
for i in 0..Response_Time.nb_entries-1 loop
Put_Line(Integer(Response_Time.entries(i).data)'Img);
end loop;
end Test_WCRT_CRPD;
procedure Test_Feasibility_Test_Computation_Time
(file_name : in Unbounded_String;
N : in Integer := 10;
PU : in Float := 0.70;
CU : in Float := 5.0;
CS : in Integer := 256;
RF : in Float := 0.3;
H : in Integer := 100000;
With_Harmonic_Tasks : in Boolean)
is
sys : System;
a_Sys : System;
Project_File_Dir_List : unbounded_string_list;
a_core : Core_Unit_Ptr;
Result : Unbounded_String := empty_string;
F: Ada.Text_IO.File_Type;
i_iterator : Tasks_Iterator;
j_iterator : Tasks_Iterator;
j1_iterator : Tasks_Iterator;
ipriority : Natural := 0;
Year,Month,Day : INTEGER;
Start,Ends,Duration : DAY_DURATION;
Time_And_Date : TIME;
my_scheduler : Rm_Scheduler;
msg : Unbounded_String;
response_time : Response_Time_Table;
CRPD_Computation_Approach : CRPD_Computation_Approach_Type := ECB_Union_Multiset;
Block_Reload_Time : Natural := 1;
--sched_result : Natural;
--hyper_period : Natural;
begin
Set_Initialize;
--This function can generate and return a system.
--In this test, we do not use the sys returned because
--we are testing the XML_Parser.
if(With_Harmonic_Tasks) then
generate_system_with_harmonic_tasks_and_CAP(file_name => file_name,
N => N,
PU => PU,
CU => CU,
CS => CS,
RF => RF,
a_system => sys);
else
generate_system_with_periodic_tasks_and_CAP(file_name => file_name,
Min_Period => 10,
Max_Period => 5000,
N => N,
PU => PU,
CU => CU,
CS => CS,
RF => RF,
a_system => sys);
end if;
--Initilize the string
Result := Result & file_name & ",";
-----------------------------------------
--
-----------------------------------------
Initialize(a_Sys);
Systems.Read_From_Xml_File (a_Sys,
Project_File_Dir_List,
file_name);
a_core := Search_core_unit(a_Sys.Core_units,To_Unbounded_String("Core_01"));
a_core.scheduling.scheduler_type := Rate_Monotonic_Protocol;
Put_Line(Get_Standard_Line);
Time_And_Date := Clock;
Split(Time_And_Date, Year, Month, Day, Start);
periodic_task_worst_case_response_time_fixed_priority.Compute_Response_Time
(My_Scheduler => my_scheduler,
My_Tasks => a_Sys.Tasks,
Processor_Name => To_Unbounded_String("CPU_01"),
Msg => msg,
Response_Time => response_time,
With_CRPD => True,
CRPD_Computation_Approach => CRPD_Computation_Approach,
Block_Reload_Time => Block_Reload_Time,
My_Cache_Access_Profiles => a_Sys.Cache_Access_Profiles);
for i in 0..Response_Time.nb_entries-1 loop
Put_Line(Integer(Response_Time.entries(i).data)'Img);
end loop;
--compute_scheduling_of_tasks_from_ada_sys_model(hyper_period,a_Sys, To_Unbounded_String("RM1.xml"),TRUE,sched_result);
-----------------------------------------
-- WRITE FILE
-----------------------------------------
Time_And_Date := Clock;
Split(Time_And_Date, Year, Month, Day, Ends);
Duration:= Ends - Start;
Put_Line("Scheduling Simulation: " & Duration'Img);
Put_Line(Get_Standard_Line);
Result := Result & Duration'Img;
begin
Open(F,Ada.Text_IO.Append_File,"result.txt");
exception
when Ada.IO_Exceptions.Name_Error =>
Create(F,Ada.Text_IO.Out_File,"result.txt");
end;
Unbounded_IO.Put(F, result);
end Test_Feasibility_Test_Computation_Time;
procedure Process_Data
(Exp_Dir : in String;
PU_String : in String)
is
Line : Unbounded_String;
F: Ada.Text_IO.File_Type;
Tokens : GNAT.String_Split.Slice_Set;
Count : Natural := 0;
Line_Result : Unbounded_String := empty_string;
Max : Float;
Float_String : String(1..15);
Temp : Float;
begin
Set_Directory(Exp_Dir);
for i in 5..100 loop
Append(Line_Result,To_String(suppress_space(i'Img)));
Open(F,Ada.Text_IO.In_File, Exp_Dir & To_String(suppress_space(i'Img)) & "/" & PU_String & "/result.txt");
Max := 0.0;
while not End_Of_File (F) loop
Line := Get_Line (F);
GNAT.String_Split.Create(s => Tokens,
From => To_String(Line),
Separators => ",",
Mode => GNAT.String_Split.Single);
Temp := Float'Value(GNAT.String_Split.Slice(Tokens,2));
if (Temp > Max) then
max := temp;
end if;
end loop;
Put(Float_String,max,10,0);
Append(Line_Result,",");
Append(Line_Result,Float_String);
Append(Line_Result,ASCII.LF);
Close (F);
end loop;
Put_Line(Line_Result);
begin
Create(F,Ada.Text_IO.Out_File,"FS_result.txt");
exception
when Ada.IO_Exceptions.Name_Error =>
Create(F,Ada.Text_IO.Out_File,"FS_result.txt");
end;
Unbounded_IO.Put(F, Line_Result);
Close(F);
end Process_Data;
procedure Test_Multiset_Intersection
is
arr_a : Integer_Array;
arr_b : Integer_Array;
arr_c : Integer_Array;
begin
Initialize(arr_a,"1,2,1,2,1,2,2,3,4",",");
Initialize(arr_b,"1,2,3,4,1,2,3,4,1,2,3,4",",");
Print(arr_a);
Print(arr_b);
arr_c := Multiset_Intersection(arr_a,arr_b);
Print(arr_c);
end Test_Multiset_Intersection;
end wcrt_crpd_util;
|