1
|
(* ----------------------------------------------------------------------------
|
2
|
* SchedMCore - A MultiCore Scheduling Framework
|
3
|
* Copyright (C) 2009-2011, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE
|
4
|
*
|
5
|
* This file is part of Prelude
|
6
|
*
|
7
|
* Prelude is free software; you can redistribute it and/or
|
8
|
* modify it under the terms of the GNU Lesser General Public License
|
9
|
* as published by the Free Software Foundation ; either version 2 of
|
10
|
* the License, or (at your option) any later version.
|
11
|
*
|
12
|
* Prelude is distributed in the hope that it will be useful, but
|
13
|
* WITHOUT ANY WARRANTY ; without even the implied warranty of
|
14
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
* Lesser General Public License for more details.
|
16
|
*
|
17
|
* You should have received a copy of the GNU Lesser General Public
|
18
|
* License along with this program ; if not, write to the Free Software
|
19
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
20
|
* USA
|
21
|
*---------------------------------------------------------------------------- *)
|
22
|
|
23
|
open Utils
|
24
|
open Format
|
25
|
|
26
|
type deadline_word = int array * int array
|
27
|
|
28
|
let dword_create ud =
|
29
|
[||],[|ud|]
|
30
|
|
31
|
let pat_length dw =
|
32
|
let (dpref, dpat) = dw in
|
33
|
Array.length dpat
|
34
|
|
35
|
let pref_length dw =
|
36
|
let (dpref, dpat) = dw in
|
37
|
Array.length dpref
|
38
|
|
39
|
(* [nth_ud dw n] returns the nth value of dw *)
|
40
|
let nth_ud dw n =
|
41
|
let (dpref, dpat) = dw in
|
42
|
let (lpref, lpat) = Array.length dpref, Array.length dpat in
|
43
|
if n < lpref then
|
44
|
dpref.(n)
|
45
|
else
|
46
|
let pos = (n-lpref) mod lpat in
|
47
|
dpat.(pos)
|
48
|
|
49
|
let add_int dw n =
|
50
|
let (dpref, dpat) = dw in
|
51
|
(Array.map (fun ud -> ud+n) dpref,Array.map (fun ud -> ud+n) dpat)
|
52
|
|
53
|
let dw_map2 f dw1 dw2 =
|
54
|
let (dpref1, dpat1), (dpref2, dpat2) = dw1, dw2 in
|
55
|
let (lpref1, lpref2) = Array.length dpref1, Array.length dpref2 in
|
56
|
let (lpat1, lpat2) = Array.length dpat1, Array.length dpat2 in
|
57
|
let lpref = max lpref1 lpref2 in
|
58
|
let lpat = lcm lpat1 lpat2 in
|
59
|
let pref,pat = Array.make lpref 0, Array.make lpat 0 in
|
60
|
for i=0 to lpref-1 do
|
61
|
pref.(i) <- f (nth_ud dw1 i) (nth_ud dw2 i)
|
62
|
done;
|
63
|
for i=0 to lpat-1 do
|
64
|
pat.(i) <- f (nth_ud dw1 (i+lpref)) (nth_ud dw2 (i+lpref))
|
65
|
done;
|
66
|
pref,pat
|
67
|
|
68
|
let add_dw dw1 dw2 =
|
69
|
dw_map2 (+) dw1 dw2
|
70
|
|
71
|
(* [min_dw dw1 dw2] returns the minimum, point-by-point, of [dw1] and [dw2].
|
72
|
Can only be used on fully instanciated deadlines. *)
|
73
|
let min_dw dw1 dw2 =
|
74
|
dw_map2 (min) dw1 dw2
|
75
|
|
76
|
let print_dw dw =
|
77
|
let (dpref, dpat) = dw in
|
78
|
if (Array.length dpref > 0) then
|
79
|
pp_array dpref print_int "" "." ".";
|
80
|
pp_array dpat print_int "(" ")" "."
|
81
|
|
82
|
(* Local Variables: *)
|
83
|
(* compile-command:"make -C .." *)
|
84
|
(* End: *)
|