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
448
449
450
451
452
453
454 | ------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 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 Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Sax.Readers; use Sax.Readers;
with Sax.Exceptions; use Sax.Exceptions;
with Sax.Locators; use Sax.Locators;
with Sax.Attributes; use Sax.Attributes;
with Unicode.CES; use Unicode.CES;
with Unicode; use Unicode;
with Offsets; use Offsets;
use Offsets.Offsets_Table_Package;
with Parameters; use Parameters;
use Parameters.User_Defined_Parameters_Table_Package;
with strings; use strings;
with unbounded_strings; use unbounded_strings;
with Dependencies; use Dependencies;
with Resources; use Resources;
use Resources.Resource_Accesses;
with resource_set; use resource_set;
use resource_set.generic_resource_set;
with Messages; use Messages;
with message_set; use message_set;
use message_set.generic_message_set;
with event_analyzer_set; use event_analyzer_set;
use event_analyzer_set.generic_event_analyzer_set;
with Tasks; use Tasks;
with task_set; use task_set;
use task_set.generic_task_set;
with Caches; use Caches;
with cache_set; use cache_set;
with Address_Spaces; use Address_Spaces;
with address_space_set; use address_space_set;
use address_space_set.generic_address_space_set;
with Buffers; use Buffers;
use Buffers.Buffer_Roles_Package;
with buffer_set; use buffer_set;
use buffer_set.generic_buffer_set;
with Processors; use Processors;
with Queueing_Systems; use Queueing_Systems;
with time_unit_events; use time_unit_events;
use time_unit_events.time_unit_package;
with Scheduling_Analysis; use Scheduling_Analysis;
with Scheduler_Interface; use Scheduler_Interface;
with task_dependencies; use task_dependencies;
with network_set; use network_set;
with Networks; use Networks;
with xml_architecture_io; use xml_architecture_io;
with multiprocessor_services; use multiprocessor_services;
with Framework_Config; use Framework_Config;
with doubles; use doubles;
package body xml_generic_parsers.event_table is
tue1 : time_unit_event_io;
sched1 : scheduling_result_io;
-- Variable to store indexes of indexed_table entities
--
index_value : Natural;
new_table : scheduling_result_ptr;
new_event : time_unit_event_ptr;
a_buffer : buffer_ptr;
a_message : generic_message_ptr;
a_task : generic_task_ptr;
a_cache : generic_cache_ptr;
a_resource : generic_resource_ptr;
a_processor : generic_processor_ptr;
function get_parsed_event_table
(handler : in xml_event_table_parser) return scheduling_table_ptr
is
begin
return handler.parsed_event_table;
end get_parsed_event_table;
procedure set_scheduled_system
(handler : in out xml_event_table_parser;
scheduled_system : in system)
is
begin
handler.scheduled_system := scheduled_system;
end set_scheduled_system;
procedure initialize_event_table_parser
(handler : in out xml_event_table_parser)
is
begin
Initialize (tue1);
Initialize (sched1);
handler.current_parameter := 1;
end initialize_event_table_parser;
procedure start_document (handler : in out xml_event_table_parser) is
begin
initialize_event_table_parser (handler);
handler.parsed_event_table := new scheduling_table;
end start_document;
procedure start_element
(handler : in out xml_event_table_parser;
namespace_uri : Unicode.CES.byte_sequence := "";
local_name : Unicode.CES.byte_sequence := "";
qname : Unicode.CES.byte_sequence := "";
atts : Sax.Attributes.attributes'class)
is
begin
handler.current_parameter := 1;
Start_Element
(xml_generic_parser (handler),
tue1,
namespace_uri,
local_name,
qname,
atts);
Start_Element
(xml_generic_parser (handler),
sched1,
namespace_uri,
local_name,
qname,
atts);
-- Start to parse a scheduling sequence
--
-- IMPORTANT: NEED TO VERIFY THE PROBLEM WITH SCHEDULING_RESULT
-- IN THE NEW VERSION OF WRITE TO XML !!!
if qname = "event_table" or qname = "scheduling_result" then
new_table := new scheduling_result;
new_table.has_error := False;
new_table.scheduling_msg := empty_string;
new_table.error_msg := empty_string;
new_table.result := new scheduling_sequence;
add (handler.parsed_event_table.all, a_processor, new_table.all);
end if;
end start_element;
procedure end_element
(handler : in out xml_event_table_parser;
namespace_uri : Unicode.CES.byte_sequence := "";
local_name : Unicode.CES.byte_sequence := "";
qname : Unicode.CES.byte_sequence := "")
is
begin
end_element
(xml_generic_parser (handler),
index_value,
namespace_uri,
local_name,
qname);
End_Element
(xml_generic_parser (handler),
tue1,
namespace_uri,
local_name,
qname);
End_Element
(xml_generic_parser (handler),
sched1,
namespace_uri,
local_name,
qname);
-- Name of the processor related to the scheduling sequence
--
if qname = "name" then
a_processor :=
search_processor
(handler.scheduled_system.processors,
handler.parameter_list (1));
end if;
if qname = "scheduling_result" then
initialize_event_table_parser (handler);
end if;
-- TODO: IMPORTANT: NEED TO VERIFY THE PROBLEM WITH SCHEDULING_RESULT
-- IN THE NEW VERSION OF WRITE TO XML !!!
if qname = "event_table" then
initialize_event_table_parser (handler);
end if;
if qname = "time_unit_event" then
case tue1.type_of_event is
when start_of_task_capacity =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.start_task);
new_event := new time_unit_event (start_of_task_capacity);
new_event.start_task := a_task;
add (new_table.result.all, index_value, new_event);
when end_of_task_capacity =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.end_task);
new_event := new time_unit_event (end_of_task_capacity);
new_event.end_task := a_task;
add (new_table.result.all, index_value, new_event);
when write_to_buffer =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.write_task);
a_buffer :=
search_buffer_by_id
(handler.scheduled_system.buffers,
tue1.write_buffer);
new_event := new time_unit_event (write_to_buffer);
new_event.write_buffer := a_buffer;
new_event.write_task := a_task;
new_event.write_size := tue1.write_size;
new_event.write_buffer_current_data_size :=
tue1.write_buffer_current_data_size;
add (new_table.result.all, index_value, new_event);
when read_from_buffer =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.read_task);
a_buffer :=
search_buffer_by_id
(handler.scheduled_system.buffers,
tue1.read_buffer);
new_event := new time_unit_event (read_from_buffer);
new_event.read_buffer := a_buffer;
new_event.read_task := a_task;
new_event.read_size := tue1.read_size;
new_event.read_buffer_current_data_size :=
tue1.read_buffer_current_data_size;
add (new_table.result.all, index_value, new_event);
when buffer_overflow =>
-- TODO
null;
when buffer_underflow =>
-- TODO
null;
when context_switch_overhead =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.switched_task);
new_event := new time_unit_event (context_switch_overhead);
new_event.switched_task := a_task;
add (new_table.result.all, index_value, new_event);
when running_task =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.running_task);
new_event := new time_unit_event (running_task);
new_event.running_task := a_task;
new_event.current_priority :=
priority_range (tue1.current_priority);
new_event.crpd := tue1.CRPD;
new_event.cache_state := tue1.cache_state;
add (new_table.result.all, index_value, new_event);
when task_activation =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.activation_task);
new_event := new time_unit_event (task_activation);
new_event.activation_task := a_task;
add (new_table.result.all, index_value, new_event);
when allocate_resource =>
a_resource :=
search_resource_by_id
(handler.scheduled_system.resources,
tue1.allocate_resource);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.allocate_task);
new_event := new time_unit_event (allocate_resource);
new_event.allocate_task := a_task;
new_event.allocate_resource := a_resource;
add (new_table.result.all, index_value, new_event);
when release_resource =>
a_resource :=
search_resource_by_id
(handler.scheduled_system.resources,
tue1.release_resource);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.release_task);
new_event := new time_unit_event (release_resource);
new_event.release_task := a_task;
new_event.release_resource := a_resource;
add (new_table.result.all, index_value, new_event);
when wait_for_resource =>
a_resource :=
search_resource_by_id
(handler.scheduled_system.resources,
tue1.wait_for_resource);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.wait_for_resource_task);
new_event := new time_unit_event (wait_for_resource);
new_event.wait_for_resource_task := a_task;
new_event.wait_for_resource := a_resource;
add (new_table.result.all, index_value, new_event);
when send_message =>
a_message :=
search_message_by_id
(handler.scheduled_system.messages,
tue1.send_message);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.send_task);
new_event := new time_unit_event (send_message);
new_event.send_task := a_task;
new_event.send_message := a_message;
add (new_table.result.all, index_value, new_event);
when receive_message =>
a_message :=
search_message_by_id
(handler.scheduled_system.messages,
tue1.receive_message);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.receive_task);
new_event := new time_unit_event (receive_message);
new_event.receive_task := a_task;
new_event.receive_message := a_message;
add (new_table.result.all, index_value, new_event);
when wait_for_memory =>
a_cache :=
search_cache_by_id
(handler.scheduled_system.caches,
tue1.wait_for_cache);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.wait_for_memory_task);
new_event := new time_unit_event (wait_for_memory);
new_event.wait_for_memory_task := a_task;
new_event.wait_for_cache := a_cache;
add (new_table.result.all, index_value, new_event);
when address_space_activation =>
new_event := new time_unit_event (address_space_activation);
new_event.activation_address_space :=
tue1.activation_address_space;
new_event.duration := tue1.duration;
add (new_table.result.all, index_value, new_event);
when preemption =>
new_event := new time_unit_event (preemption);
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.preempted_task);
new_event.preempted_task := a_task;
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.preempting_task);
new_event.preempting_task := a_task;
-- TODO: Update the method to find the list of evicted UCB
new_event.evicted_ucbs := 0;
add (new_table.result.all, index_value, new_event);
when discard_missed_deadline =>
a_task :=
search_task_by_id
(handler.scheduled_system.tasks,
tue1.missed_deadline_task);
new_event := new time_unit_event (discard_missed_deadline);
new_event.missed_deadline_task := a_task;
add (new_table.result.all, index_value, new_event);
end case;
initialize_event_table_parser (handler);
end if;
end end_element;
end xml_generic_parsers.event_table;
|