Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * Paolo Gai <pj@hartik.sssup.it> |
||
6 | * |
||
7 | * Authors : Marco Caccamo and Paolo Gai |
||
8 | * |
||
9 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
10 | * |
||
11 | * http://www.sssup.it |
||
12 | * http://retis.sssup.it |
||
13 | * http://shark.sssup.it |
||
14 | */ |
||
15 | |||
16 | /** |
||
17 | ------------ |
||
18 | CVS : $Id: cbs_ft.h,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
||
19 | |||
20 | File: $File$ |
||
21 | Revision: $Revision: 1.1.1.1 $ |
||
22 | Last update: $Date: 2002-09-02 09:37:41 $ |
||
23 | ------------ |
||
24 | |||
25 | This file contains the server CBS_FT |
||
26 | |||
27 | Read CBS_FT.h for further details. |
||
28 | |||
29 | **/ |
||
30 | |||
31 | /* |
||
32 | * Copyright (C) 2000 Marco Caccamo and Paolo Gai |
||
33 | * |
||
34 | * This program is free software; you can redistribute it and/or modify |
||
35 | * it under the terms of the GNU General Public License as published by |
||
36 | * the Free Software Foundation; either version 2 of the License, or |
||
37 | * (at your option) any later version. |
||
38 | * |
||
39 | * This program is distributed in the hope that it will be useful, |
||
40 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
41 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
42 | * GNU General Public License for more details. |
||
43 | * |
||
44 | * You should have received a copy of the GNU General Public License |
||
45 | * along with this program; if not, write to the Free Software |
||
46 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
47 | * |
||
48 | */ |
||
49 | |||
50 | #ifndef __CBS_FT__ |
||
51 | #define __CBS_FT__ |
||
52 | |||
53 | |||
54 | |||
55 | #include <ll/string.h> |
||
56 | #include <kernel/model.h> |
||
57 | #include <kernel/descr.h> |
||
58 | #include <kernel/var.h> |
||
59 | #include <kernel/func.h> |
||
60 | |||
61 | |||
62 | |||
63 | |||
64 | |||
65 | |||
66 | /*+ flags... +*/ |
||
67 | #define CBS_FT_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/ |
||
68 | #define CBS_FT_ENABLE_ALL 1 |
||
69 | |||
70 | #define CBS_FT_FAILED_GUARANTEE 8 /*+ used in the module, unsettable |
||
71 | in EDF_register_level... +*/ |
||
72 | |||
73 | |||
74 | #define PRIMARY 1 |
||
75 | #define BACKUP 2 |
||
76 | #define FT_PCLASS 0x0700 // Nuova classe di task, quelli fault_tolerant |
||
77 | |||
78 | #define CBS_FT_LEVELNAME "CBSFT base" |
||
79 | #define CBS_FT_LEVEL_CODE 110 |
||
80 | #define CBS_FT_LEVEL_VERSION 1 |
||
81 | |||
82 | |||
83 | /* The Fault-Tolerant Task model extends the base task model |
||
84 | This model cannot be APERIODIC, only PERIODIC tasks are allowed. |
||
85 | A faut-tolerant application is composed by two different tasks (primary and |
||
86 | backup). The backup task is characterized by its WCET and its type (BACKUP). |
||
87 | The primary task must define the task period, its average execution time |
||
88 | (used as sort of prediction in order to recharge the budget using the |
||
89 | capacity cash queue!), the budget (budget / period = U that is, the |
||
90 | bandwidth assigned to the fault-tolerant application), its type (PRIMARY) |
||
91 | and finally the PID of the corresponding backup task. */ |
||
92 | |||
93 | typedef struct { |
||
94 | TASK_MODEL t; |
||
95 | |||
96 | TIME wcetB; // WCET of the backup job (BACKUP TASK ONLY) |
||
97 | |||
98 | TIME execP; // average exec. time of the primary job (PRIMARY TASK ONLY) |
||
99 | |||
100 | TIME period; // period of the fault-tolerant task (PRIMARY TASK ONLY) |
||
101 | |||
102 | int budget; // amount of guaranteed capacity (PRIMARY TASK ONLY) |
||
103 | |||
104 | char type; // PRIMARY or BACKUP |
||
105 | |||
106 | PID backup; // (PRIMARY TASK ONLY) |
||
107 | |||
108 | } FT_TASK_MODEL; |
||
109 | |||
110 | |||
111 | #define ft_task_default_model(m) \ |
||
112 | task_default_model((m).t,FT_PCLASS), \ |
||
113 | (m).period = 0, \ |
||
114 | (m).wcetB = 0, \ |
||
115 | (m).execP = 0, \ |
||
116 | (m).budget = 0, \ |
||
117 | (m).type = BACKUP, \ |
||
118 | (m).backup = NIL |
||
119 | |||
120 | #define ft_task_def_level(m,l) task_def_level((m).t,l) |
||
121 | #define ft_task_def_arg(m,a) task_def_arg((m).t,a) |
||
122 | #define ft_task_def_stack(m,s) task_def_stack((m).t,s) |
||
123 | #define ft_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s) |
||
124 | #define ft_task_def_usemath(m) task_def_usemath((m).t) |
||
125 | #define ft_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t) |
||
126 | #define ft_task_def_group(m,g) task_def_group((m).t,g) |
||
127 | #define ft_task_def_period(m,o) (m).period = (o) |
||
128 | #define ft_task_def_budget(m,o) (m).budget = (o) |
||
129 | #define ft_task_def_backup(m) (m).type = BACKUP |
||
130 | #define ft_task_def_primary(m) (m).type = PRIMARY |
||
131 | #define ft_task_def_backup_task(m,b) (m).backup = b |
||
132 | #define ft_task_def_backup_wcet(m,b) (m).wcetB = b |
||
133 | #define ft_task_def_primary_exec(m,b) (m).execP = b |
||
134 | |||
135 | /************************************************************************/ |
||
136 | void CBS_FT_register_level(int flags, LEVEL master); |
||
137 | |||
138 | |||
139 | bandwidth_t CBS_FT_usedbandwidth(LEVEL l); |
||
140 | |||
141 | |||
142 | |||
143 | /* This function notifies to a primary task that the task itself has to |
||
144 | suspend its execution (the task has to suspend itself with a |
||
145 | task_endcycle() */ |
||
146 | char CBS_FT_Checkpoint(void); |
||
147 | |||
148 | |||
149 | |||
150 | /* This function sets the checkpoint flag! hence, at the next checkpoint, |
||
151 | that is: |
||
152 | |||
153 | if (CBS_FT_Checkpoint()) { |
||
154 | task_endcycle(); |
||
155 | continue; |
||
156 | } |
||
157 | |||
158 | the primary task will suspend itself switching to the backup task */ |
||
159 | void CBS_FT_Primary_Abort(void); |
||
160 | |||
161 | /***************************************************************************/ |
||
162 | |||
163 | |||
164 | |||
165 | |||
166 | #endif |