Rev 994 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
881 | trimarchi | 1 | //fsf_basic_types.h |
2 | //======================================================================= |
||
3 | // FFFFFFIII RRRRR SSTTTTTTT |
||
4 | // FF IIR RR SS |
||
5 | // FF IR SS |
||
6 | // FFFFFF RRRR SSSSST |
||
7 | // FF FI RRR SS |
||
8 | // FF II RRR SS |
||
9 | // FF IIIIIR RS |
||
10 | // |
||
11 | // Basic FSF(FIRST Scheduling Framework) common types |
||
12 | //======================================================================= |
||
13 | // |
||
14 | |||
993 | lipari | 15 | /** |
16 | \file fsf_basic_types.h |
||
17 | */ |
||
18 | |||
881 | trimarchi | 19 | #include <time.h> |
20 | #include "fsf_opaque_types.h" |
||
21 | #include "fsf_configuration_parameters.h" |
||
22 | |||
23 | #ifndef _FSF_BASIC_TYPES_H_ |
||
24 | #define _FSF_BASIC_TYPES_H_ |
||
25 | |||
26 | |||
27 | // Definition of types and constants used in fsf modules |
||
28 | |||
29 | |||
30 | // |
||
31 | // Types for the core module |
||
32 | // |
||
33 | |||
993 | lipari | 34 | /** |
35 | This data type is used for defining the workload parameter in the |
||
36 | contract specification functions. |
||
37 | |||
38 | It can have the following values: |
||
39 | |||
40 | - FSF_BOUNDED: The workload generated by the task(s) in the server is bounded |
||
41 | |||
42 | - FSF_INDETERMINATE: The workload generated by the task(s) in the server is indeterminate |
||
43 | |||
44 | - FSF_OVERHEAD: The workload generated by the task(s) in the server is TBD |
||
45 | |||
46 | */ |
||
881 | trimarchi | 47 | typedef enum {FSF_BOUNDED, FSF_INDETERMINATE, FSF_OVERHEAD} fsf_workload_t; |
48 | |||
993 | lipari | 49 | /// Default value for the workload parameter |
50 | #define FSF_DEFAULT_WORKLOAD FSF_INDETERMINATE |
||
889 | trimarchi | 51 | |
993 | lipari | 52 | /// Default value for the parameter d_equal_t in the contract initialization |
881 | trimarchi | 53 | #define FSF_DEFAULT_D_EQUALS_T false |
993 | lipari | 54 | |
55 | // Default value for the server relative deadline |
||
881 | trimarchi | 56 | #define FSF_DEFAULT_DEADLINE {0,0} //struct timespec |
57 | |||
889 | trimarchi | 58 | // Constants for omitting the assignment of values |
59 | // to specific arguments in calls to |
||
60 | // initialization functions |
||
61 | |||
993 | lipari | 62 | /// A null deadline |
881 | trimarchi | 63 | #define FSF_NULL_DEADLINE (struct timespec *)NULL |
993 | lipari | 64 | |
65 | /// A null signal |
||
881 | trimarchi | 66 | #define FSF_NULL_SIGNAL 0 |
67 | |||
971 | trimarchi | 68 | /** |
993 | lipari | 69 | This data type is used to express the list of possible values |
70 | returned by fsf_get_renegotiation_status. It can assume the |
||
71 | following values: |
||
72 | |||
73 | |||
971 | trimarchi | 74 | */ |
75 | typedef enum {FSF_IN_PROGRESS, |
||
76 | FSF_REJECTED, |
||
77 | FSF_ADMITTED, |
||
78 | FSF_NOT_REQUESTED} |
||
79 | fsf_renegotiation_status_t; |
||
889 | trimarchi | 80 | |
971 | trimarchi | 81 | |
985 | julio | 82 | /** |
83 | Synchronization object handle type, this an opaque type |
||
84 | used to signaling of servers |
||
85 | */ |
||
86 | typedef FSF_SYNCH_OBJ_HANDLE_T_OPAQUE fsf_synch_obj_handle_t; |
||
87 | |||
88 | |||
89 | |||
90 | /** |
||
91 | Server Id type, that identifies a server created to manage a given |
||
92 | contract |
||
93 | */ |
||
94 | typedef int fsf_server_id_t; // => 0 |
||
95 | |||
96 | /** |
||
97 | The type references a function that may become a thread's |
||
98 | code |
||
99 | */ |
||
100 | typedef void * (*fsf_thread_code_t) (void *); |
||
101 | |||
102 | |||
881 | trimarchi | 103 | // |
104 | // Types for the spare capacity module |
||
105 | // |
||
106 | |||
993 | lipari | 107 | /** |
108 | Granularity of spare capacity requirements. This data type is used |
||
109 | in the spare capacity module to specify the kind of granularity in |
||
110 | spare capacity allocation when creating a new contract. |
||
111 | |||
112 | A variable of this type can assume the following values: |
||
113 | |||
114 | - FSF_CONTINUOUS the utilization assigned to the server by the |
||
115 | spare capacity module can assume any value between the minimum |
||
116 | (Cmin / Tmax) and the maximum (Cmax/Tmin). |
||
117 | |||
118 | - FSF_DISCRETE the utilization assigned to the server can assume |
||
119 | only values in a discrete set of pairs (C,T) (to be specified |
||
120 | with a variable of type fsf_utilization_set_t) |
||
121 | |||
122 | */ |
||
881 | trimarchi | 123 | typedef enum {FSF_CONTINUOUS, FSF_DISCRETE} fsf_granularity_t; |
124 | |||
993 | lipari | 125 | /** |
126 | This data type is used in the spare capacity module to specify |
||
127 | pairs of (budget,period) that can be assigned by the spare capacity |
||
128 | distribution algorithm to the server. |
||
129 | respectively. |
||
130 | */ |
||
881 | trimarchi | 131 | typedef struct { |
993 | lipari | 132 | /// server capacity |
133 | struct timespec budget; |
||
134 | /// server period |
||
135 | struct timespec period; |
||
881 | trimarchi | 136 | } fsf_utilization_value_t; |
137 | |||
993 | lipari | 138 | |
139 | /** |
||
140 | This data type is used in the spare capacity module to specify a |
||
141 | set of possible pairs (C,T) that can be assigned to the server. |
||
142 | */ |
||
881 | trimarchi | 143 | typedef struct { |
993 | lipari | 144 | /// lenght of the array |
881 | trimarchi | 145 | int size; // = 0 |
993 | lipari | 146 | /// array of pairs (C,T) |
881 | trimarchi | 147 | fsf_utilization_value_t |
148 | value[FSF_MAX_N_UTILIZATION_VALUES]; |
||
149 | } fsf_utilization_set_t; |
||
150 | |||
1039 | trimarchi | 151 | /// List of servers to cancel |
152 | typedef struct { |
||
153 | int size; |
||
154 | fsf_server_id_t servers[FSF_MAX_N_SERVERS]; |
||
155 | } fsf_servers_group_t; |
||
993 | lipari | 156 | |
1039 | trimarchi | 157 | |
993 | lipari | 158 | /// The defualt granularity |
881 | trimarchi | 159 | #define FSF_DEFAULT_GRANULARITY FSF_CONTINUOUS |
993 | lipari | 160 | |
161 | /// Defaut value for the quality parameter |
||
881 | trimarchi | 162 | #define FSF_DEFAULT_QUALITY 0 |
993 | lipari | 163 | |
164 | /// Default value for the importance parameter |
||
881 | trimarchi | 165 | #define FSF_DEFAULT_IMPORTANCE 1 |
166 | |||
993 | lipari | 167 | /// Constant for omitting the assignment of values to the |
168 | /// fsf_utilizazion_set_t parameter in call to the contract initialization |
||
169 | /// functions |
||
881 | trimarchi | 170 | #define FSF_NULL_UTILIZATION_SET \ |
171 | (fsf_utilization_set_t *)NULL |
||
172 | |||
993 | lipari | 173 | /// Maximum value of the quality parameter |
985 | julio | 174 | #define FSF_MAX_QUALITY (2**32 -1) |
993 | lipari | 175 | |
176 | /// Minimum value of the quality parameter |
||
985 | julio | 177 | #define FSF_MIN_QUALITY 0 |
993 | lipari | 178 | |
179 | /// Maximum value of the importance parameter |
||
985 | julio | 180 | #define FSF_MAX_IMPORTANCE FSF_N_IMPORTANCE_LEVELS |
993 | lipari | 181 | |
182 | /// Minimum value of the importance parameter |
||
985 | julio | 183 | #define FSF_MIN_IMPORTANCE 1 |
881 | trimarchi | 184 | |
985 | julio | 185 | |
186 | |||
187 | |||
881 | trimarchi | 188 | // |
189 | // Types for the implementation specific module |
||
190 | // |
||
191 | |||
889 | trimarchi | 192 | //Implementation specific preemption level values |
881 | trimarchi | 193 | typedef unsigned long fsf_preemption_level_t; |
194 | // range 1..2**32-1 |
||
195 | |||
196 | |||
994 | trimarchi | 197 | /// |
198 | /// Types for the shared objects module |
||
199 | /// |
||
881 | trimarchi | 200 | |
994 | trimarchi | 201 | /// Shared object identifier (null character terminated string) |
881 | trimarchi | 202 | typedef char * fsf_shared_obj_id_t; |
203 | |||
994 | trimarchi | 204 | /// Shared object handle (opaque type) |
881 | trimarchi | 205 | typedef FSF_SHARED_OBJ_HANDLE_T_OPAQUE fsf_shared_obj_handle_t; |
206 | |||
994 | trimarchi | 207 | /// Critical section data |
881 | trimarchi | 208 | typedef struct { |
994 | trimarchi | 209 | /// handle of shared object |
881 | trimarchi | 210 | fsf_shared_obj_handle_t obj_handle; |
994 | trimarchi | 211 | /// Execution time of critical section |
212 | struct timespec wcet; |
||
881 | trimarchi | 213 | } fsf_critical_section_data_t; |
214 | |||
994 | trimarchi | 215 | /** |
216 | This data type is used to specify the critical sections for the contract and is a part of shared object module. |
||
217 | |||
218 | */ |
||
219 | /// List of critical sections |
||
881 | trimarchi | 220 | typedef struct { |
994 | trimarchi | 221 | /// lenght of the array |
881 | trimarchi | 222 | int size; // = 0 |
994 | trimarchi | 223 | /// array of critical sections |
881 | trimarchi | 224 | fsf_critical_section_data_t |
225 | section[FSF_MAX_N_CRITICAL_SECTIONS]; |
||
226 | } fsf_critical_sections_t; |
||
227 | |||
228 | |||
229 | // |
||
230 | // Types for the hierarchical module |
||
231 | // |
||
994 | trimarchi | 232 | /** |
233 | This data type is used for defining scheduling polices in a contract |
||
234 | or the behaviour of a task. |
||
235 | |||
236 | It can have the following values: |
||
881 | trimarchi | 237 | |
994 | trimarchi | 238 | - FSF_EDF: EDF policy |
239 | |||
240 | - FSF_RR: Round robin policy |
||
241 | |||
242 | - FSF_TABLE_DRIVEN: Table driven policy |
||
243 | |||
244 | - FSF_NONE: Defines that the contract can accept one thread |
||
245 | |||
246 | */ |
||
247 | /// Scheduling policies |
||
1039 | trimarchi | 248 | typedef enum {FSF_FP, FSF_EDF, FSF_TABLE_DRIVEN, FSF_RR, FSF_FEDF,FSF_NONE} |
881 | trimarchi | 249 | fsf_sched_policy_t; |
250 | |||
994 | trimarchi | 251 | /** |
252 | This data type is used to specify the scheduling policy and parameters for each task in the hierarchical module. |
||
253 | |||
254 | */ |
||
255 | /// Real time parameters |
||
881 | trimarchi | 256 | typedef struct { |
994 | trimarchi | 257 | /// The params member specify the scheduling policy |
881 | trimarchi | 258 | fsf_sched_policy_t policy; |
994 | trimarchi | 259 | /// The params member is a pointer to one of the |
260 | /// following: |
||
261 | /// FP: int (priority) |
||
262 | /// EDF: struct timespec (deadline) |
||
263 | /// RR: none |
||
264 | /// TABLE_DRIVEN : struct fsf_table_driven_params_t |
||
881 | trimarchi | 265 | void * params; |
994 | trimarchi | 266 | |
267 | |||
881 | trimarchi | 268 | } fsf_sched_params_t; |
269 | |||
994 | trimarchi | 270 | /** |
271 | This data type is used to specify a target window of a task. |
||
272 | |||
273 | */ |
||
274 | ///Target window for the table-driven scheduler |
||
971 | trimarchi | 275 | typedef struct fsf_target_window { |
994 | trimarchi | 276 | /// The start time of the target window |
971 | trimarchi | 277 | struct timespec start; |
994 | trimarchi | 278 | /// The end time of the target window |
971 | trimarchi | 279 | struct timespec end; |
994 | trimarchi | 280 | /// The computation time of the task in the target window |
971 | trimarchi | 281 | struct timespec comp_time; |
282 | } fsf_target_window; |
||
283 | |||
994 | trimarchi | 284 | /** |
285 | This data type is used to specify the window of activation for each task in the table driven scheduler. |
||
286 | |||
287 | */ |
||
288 | /// Real time parameters for table drivern |
||
881 | trimarchi | 289 | typedef struct { |
994 | trimarchi | 290 | /// The params indicates the lenght of the array |
909 | trimarchi | 291 | int size; |
994 | trimarchi | 292 | /// The params rappresent the array of target windows |
971 | trimarchi | 293 | fsf_target_window table[FSF_MAX_N_TARGET_WINDOWS]; |
881 | trimarchi | 294 | } fsf_table_driven_params_t; |
295 | |||
296 | |||
994 | trimarchi | 297 | ///Initialization information for a scheduling policy |
298 | /// It shall be one of the following: |
||
299 | /// FP: none |
||
300 | /// EDF: none |
||
301 | /// RR: struct timespec (slice duration) |
||
302 | /// TABLE_DRIVEN : struct timespec (schedule duration) |
||
881 | trimarchi | 303 | typedef void * fsf_sched_init_info_t; |
993 | lipari | 304 | |
985 | julio | 305 | // Constant for assigning default values |
306 | #define FSF_DEFAULT_SCHED_POLICY FSF_NONE |
||
307 | |||
901 | trimarchi | 308 | // |
309 | // Types for the distributed services module |
||
310 | // |
||
881 | trimarchi | 311 | |
901 | trimarchi | 312 | // Type designating the network ids. They need not |
313 | // be sequential numbers. |
||
314 | typedef unsigned int fsf_network_id_t; |
||
881 | trimarchi | 315 | |
901 | trimarchi | 316 | #define FSF_DEFAULT_NETWORK_ID 1 |
317 | #define FSF_NULL_NETWORK_ID 0 |
||
318 | |||
985 | julio | 319 | //opaque types for fsf endpoints |
320 | typedef FSF_SEND_ENDPOINT_T_OPAQUE fsf_send_endpoint_t; |
||
321 | typedef FSF_RECEIVE_ENDPOINT_T_OPAQUE fsf_receive_endpoint_t; |
||
901 | trimarchi | 322 | |
985 | julio | 323 | /** |
324 | \ingroup distjmodule |
||
325 | |||
326 | The node_address type specifies the node address in a |
||
327 | communication-protocol-independent way. The actual address is |
||
328 | obtained via a configuration dependent mapping function |
||
329 | */ |
||
330 | typedef unsigned int fsf_node_address_t; |
||
331 | |||
332 | /** |
||
333 | \ingroup distjmodule |
||
334 | |||
335 | The port type specifies the information that is necessary to get in |
||
336 | contact with the thread in the receiving node, in a |
||
337 | protocol-independent way. The actual port number is obtained via a |
||
338 | configuration dependent mapping function |
||
339 | */ |
||
340 | typedef unsigned int fsf_port_t; |
||
341 | |||
342 | |||
1039 | trimarchi | 343 | /** |
344 | Contract parameters type; it is an opaque type (i.e. the internal |
||
345 | structure of this data type is implementation dependent). The user |
||
346 | can access and modify the parameters of a contract only with the |
||
347 | proper functions, and should never access the data directly. |
||
348 | */ |
||
349 | typedef FSF_CONTRACT_PARAMETERS_T_OPAQUE fsf_contract_parameters_t; |
||
985 | julio | 350 | |
1039 | trimarchi | 351 | /// List of contracts to negotiate |
352 | typedef struct { |
||
353 | int size; |
||
354 | fsf_contract_parameters_t* contracts[FSF_MAX_N_SERVERS]; |
||
355 | } fsf_contracts_group_t; |
||
985 | julio | 356 | |
1039 | trimarchi | 357 | |
889 | trimarchi | 358 | // Error codes |
971 | trimarchi | 359 | #define FSF_ERR_BASE_VALUE 0x02004000 |
889 | trimarchi | 360 | |
971 | trimarchi | 361 | #define FSF_ERR_TOO_MANY_TASKS 0x02004001 |
362 | #define FSF_ERR_BAD_ARGUMENT 0x02004002 |
||
363 | #define FSF_ERR_INVALID_SYNCH_OBJ_HANDLE 0x02004003 |
||
364 | #define FSF_ERR_NO_RENEGOTIATION_REQUESTED 0x02004004 |
||
365 | #define FSF_ERR_CONTRACT_REJECTED 0x02004005 |
||
366 | #define FSF_ERR_NOT_SCHEDULED_CALLING_THREAD 0x02004006 |
||
985 | julio | 367 | #define FSF_ERR_NOT_BOUND 0x02004007 |
971 | trimarchi | 368 | #define FSF_ERR_UNKNOWN_SCHEDULED_THREAD 0x02004008 |
369 | #define FSF_ERR_NOT_CONTRACTED_SERVER 0x02004009 |
||
370 | #define FSF_ERR_NOT_SCHEDULED_THREAD 0x0200400A |
||
371 | #define FSF_ERR_TOO_MANY_SERVICE_JOBS 0x0200400B |
||
372 | #define FSF_ERR_TOO_MANY_SYNCH_OBJS 0x0200400C |
||
373 | #define FSF_ERR_TOO_MANY_SERVERS_IN_SYNCH_OBJ 0x0200400D |
||
374 | #define FSF_ERR_TOO_MANY_EVENTS_IN_SYNCH_OBJ 0x0200400E |
||
375 | #define FSF_ERR_INTERNAL_ERROR 0x0200400F |
||
376 | #define FSF_ERR_TOO_MANY_SERVERS 0x02004010 |
||
377 | #define FSF_ERR_INVALID_SCHEDULER_REPLY 0x02004011 |
||
378 | #define FSF_ERR_TOO_MANY_PENDING_REPLENISHMENTS 0x02004012 |
||
379 | #define FSF_ERR_SYSTEM_ALREADY_INITIALIZED 0x02004013 |
||
380 | #define FSF_ERR_SHARED_OBJ_ALREADY_INITIALIZED 0x02004014 |
||
381 | #define FSF_ERR_SHARED_OBJ_NOT_INITIALIZED 0x02004015 |
||
382 | #define FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE 0x02004016 |
||
383 | #define FSF_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE 0x02004017 |
||
384 | #define FSF_ERR_ALREADY_BOUND 0x02004018 |
||
385 | #define FSF_ERR_WRONG_NETWORK 0x02004019 |
||
386 | #define FSF_ERR_TOO_LARGE 0x0200401A |
||
387 | #define FSF_ERR_BUFFER_FULL 0x0200401B |
||
388 | #define FSF_ERR_NO_SPACE 0x0200401C |
||
389 | #define FSF_ERR_NO_MESSAGES 0x0200401D |
||
390 | #define FSF_WRN_MODULE_NOT_SUPPORTED 0x0200401E |
||
391 | #define FSF_ERR_SYSTEM_NOT_INITIALIZED 0x0200401F |
||
392 | #define FSF_ERR_TOO_MANY_SHARED_OBJS 0x02004020 |
||
889 | trimarchi | 393 | |
971 | trimarchi | 394 | #define FSF_ERR_LAST_VALUE 0x02004020 |
395 | |||
889 | trimarchi | 396 | |
901 | trimarchi | 397 | |
881 | trimarchi | 398 | #endif // _FSF_BASIC_TYPES_H_ |