Rev 881 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1063 | tullio | 1 | |
2 | /* |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
16 | * |
||
17 | */ |
||
18 | |||
881 | trimarchi | 19 | //==================================================================================== |
20 | // FFFFFFIII RRRRR SSTTTTTTT |
||
21 | // FF IIR RR SS |
||
22 | // FF IR SS |
||
23 | // FFFFFF RRRR SSSSST |
||
24 | // FF FI RRR SS |
||
25 | // FF II RRR SS |
||
26 | // FF IIIIIR RS |
||
27 | // |
||
28 | // Basic FSF(FIRST Scheduling Framework) contract management |
||
29 | // S.Ha.R.K. Implementation |
||
30 | //===================================================================== |
||
31 | |||
32 | #include <time.h> |
||
33 | #include <sys/boolean.h> |
||
34 | #include <sys/types.h> |
||
35 | |||
36 | #include "fsf_configuration_parameters.h" |
||
37 | #include "fsf_opaque_types.h" |
||
38 | |||
39 | #include "edfstar.h" |
||
40 | #include "rmstar.h" |
||
41 | #include "posixstar.h" |
||
42 | #include "nonestar.h" |
||
43 | |||
44 | #ifndef _FSF_CONTRACT_H_ |
||
45 | #define _FSF_CONTRACT_H_ |
||
46 | |||
47 | |||
48 | |||
49 | /* S.Ha.R.K. Init */ |
||
50 | int FSF_register_module(int server_level, bandwidth_t max_bw); |
||
51 | |||
52 | ////////////////////////////////////////////////////////////////// |
||
53 | // BASIC TYPES AND CONSTANTS |
||
54 | ////////////////////////////////////////////////////////////////// |
||
55 | |||
56 | typedef enum {FSF_BOUNDED, FSF_INDETERMINATE} fsf_workload_t; |
||
57 | |||
58 | typedef enum {FSF_CONTINUOUS, FSF_DISCRETE} fsf_granularity_t; |
||
59 | |||
60 | typedef struct { |
||
61 | struct timespec budget; // Execution time |
||
62 | struct timespec period; // Period |
||
63 | } fsf_utilization_value_t; |
||
64 | |||
65 | typedef struct { |
||
66 | int size; // = 0 |
||
67 | fsf_utilization_value_t unit[FSF_MAX_N_UTILIZATION_VALUES]; |
||
68 | } fsf_utilization_set_t; |
||
69 | |||
70 | typedef unsigned long fsf_preemption_level_t; // range 1..2**32-1 |
||
71 | |||
72 | typedef struct { |
||
73 | struct timespec wcet; // Execution time |
||
74 | fsf_preemption_level_t plevel; // Preemption_Level, range 1..2**32-1 |
||
75 | } fsf_critical_section_data_t; |
||
76 | |||
77 | |||
78 | // Definition of basic types |
||
79 | |||
80 | typedef unsigned int fsf_shared_op_id_t; |
||
81 | typedef unsigned int fsf_shared_obj_id_t; |
||
82 | |||
83 | // Operations |
||
84 | // The first field contains the id of the related object |
||
85 | // the second field contains an identifier of the operation |
||
86 | // this identifier is unique for the object but needs not to be unique |
||
87 | // for the system. In other words, there can be two operations with the |
||
88 | // same identifier belonging to different shared objects: they are |
||
89 | // effectively two distinct operations; two different operations on the |
||
90 | // same object must have different identifiers |
||
91 | |||
92 | typedef struct { |
||
93 | fsf_shared_obj_id_t obj_id; // Object identification |
||
94 | fsf_shared_op_id_t op_id; // Operation Identification |
||
95 | struct timespec wcet; // Execution time |
||
96 | } fsf_shared_operation_t; |
||
97 | |||
98 | // Shared object |
||
99 | // the first field is the number of distinct operations on the |
||
100 | // shared object. It is initialized to 0. |
||
101 | // the second field is the id of the object, must be unique in the system. |
||
102 | // the third field is a list of shared operations. |
||
103 | |||
104 | |||
105 | |||
106 | |||
107 | typedef struct { |
||
108 | int size; // = 0 |
||
109 | fsf_critical_section_data_t section[FSF_MAX_N_CRITICAL_SECTIONS]; |
||
110 | } fsf_critical_sections_t; |
||
111 | |||
112 | typedef struct { |
||
113 | int size; // = 0 |
||
114 | fsf_shared_obj_id_t obj_id; // object id |
||
115 | fsf_shared_operation_t shared_op[FSF_MAX_SHARED_OPERATION]; |
||
116 | } fsf_shared_object_t; |
||
117 | |||
118 | typedef struct { |
||
119 | int size; // =0 |
||
120 | fsf_shared_operation_t operation[FSF_MAX_SHARED_OPERATION]; |
||
121 | } fsf_shared_operations_t; |
||
122 | |||
123 | typedef int fsf_scheduler_id_t; |
||
124 | |||
125 | #define FSF_SCHEDULER_POSIX 0 |
||
126 | #define FSF_SCHEDULER_EDF 1 |
||
127 | #define FSF_SCHEDULER_RM 2 |
||
128 | #define FSF_SCHEDULER_NONE 3 |
||
129 | |||
130 | // Constants for assigning default values |
||
131 | #define FSF_DEFAULT_WORKLOAD FSF_INDETERMINATE |
||
132 | #define FSF_DEFAULT_GRANULARITY FSF_CONTINUOUS |
||
133 | #define FSF_DEFAULT_QUALITY 0 |
||
134 | #define FSF_DEFAULT_IMPORTANCE 1 |
||
135 | #define FSF_DEFAULT_D_EQUALS_T TRUE |
||
136 | #define FSF_DEFAULT_DEADLINE {0,0} |
||
137 | #define FSF_DEFAULT_SCHEDULER FSF_SCHEDULER_NONE |
||
138 | |||
139 | // Constants for omitting the assignment of values to specific arguments |
||
140 | // in calls to initialization functions |
||
141 | #define FSF_NULL_CRITICAL_SECTIONS (fsf_critical_sections_t *)NULL |
||
142 | #define FSF_NULL_UTILIZATION_SET (fsf_utilization_set_t *)NULL |
||
143 | #define FSF_NULL_DEADLINE (struct timespec *)NULL |
||
144 | #define FSF_NULL_SIGNAL 0 |
||
145 | |||
146 | |||
147 | // Error codes |
||
148 | #define FSF_ERR_NOT_INITIALIZED 2003001 |
||
149 | #define FSF_ERR_TOO_MANY_TASKS 2003002 |
||
150 | #define FSF_ERR_ALREADY_INITIALIZED 2003003 |
||
151 | #define FSF_ERR_BAD_ARGUMENT 2003004 |
||
152 | #define FSF_ERR_INVALID_SYNCH_OBJECT_HANDLE 2003005 |
||
153 | #define FSF_ERR_NO_RENEGOTIATION_REQUESTED 2003006 |
||
154 | #define FSF_ERR_CONTRACT_REJECTED 2003007 |
||
155 | #define FSF_ERR_TOO_MANY_SERVERS 2003008 |
||
156 | #define FSF_ERR_CREATE_THREAD 2003009 |
||
157 | #define FSF_ERR_SERVER_USED 2003010 |
||
158 | #define FSF_ERR_INVALID_SERVER 2003011 |
||
159 | #define FSF_ERR_CREATE_SERVER 2003012 |
||
160 | |||
161 | ////////////////////////////////////////////////////////////// |
||
162 | // CONTRACT PARAMETERS |
||
163 | ////////////////////////////////////////////////////////////// |
||
164 | |||
165 | // Contract parameters type; it is an opaque type |
||
166 | typedef FSF_CONTRACT_PARAMETERS_T_OPAQUE fsf_contract_parameters_t; |
||
167 | |||
168 | int |
||
169 | fsf_initialize_contract(fsf_contract_parameters_t *contract); |
||
170 | |||
171 | //Description: The operation receives a pointer to a contract parameters |
||
172 | //object and initializes it, setting it to the default values. |
||
173 | // budget_min => {0,0}; |
||
174 | // period_max => {0,0}; |
||
175 | // budget_max => {0,0}; |
||
176 | // period_min => {0,0}; |
||
177 | // workload => DEFAULT_WORKLOAD; |
||
178 | |||
179 | // d_equals_t => DEFAULT_D_EQUALS_T; (false or true) |
||
180 | // deadline => DEFAULT_DEADLINE; |
||
181 | // budget_overrun_sig_notify => 0; (signal number) |
||
182 | // budget_overrun_sig_value => {0, NULL}; |
||
183 | // deadline_miss_sig_notify => 0; (signal number) |
||
184 | // deadline_miss_sig_value => {0, NULL}; |
||
185 | // |
||
186 | // granularity => DEFAULT_GRANULARITY; |
||
187 | // utilization_set; => size = 0 |
||
188 | // quality => DEFAULT_QUALITY; (range 0..100) |
||
189 | // importance => DEFAULT_IMPORTANCE; (range 1..5) |
||
190 | // |
||
191 | // preemption_level => 0; (range 1..2**32-1) |
||
192 | // critical_sections; => size = 0 |
||
193 | |||
194 | |||
195 | int |
||
196 | fsf_set_contract_basic_parameters |
||
197 | (fsf_contract_parameters_t *contract, |
||
198 | const struct timespec *budget_min, |
||
199 | const struct timespec *period_max, |
||
200 | const struct timespec *budget_max, |
||
201 | const struct timespec *period_min, |
||
202 | fsf_workload_t workload); |
||
203 | |||
204 | //Description: The operation updates the specified contract parameters |
||
205 | //object by setting its budget, period, and workload to the specified |
||
206 | //input parameters. (Note: the workload is a basic parameter because |
||
207 | //bounded tasks are triggered by the scheduler (see the Timed Schedule |
||
208 | //Next Job operation, later), while indeterminate tasks are not; |
||
209 | //therefore, their programming model is quite different). |
||
210 | |||
211 | int |
||
212 | fsf_get_contract_basic_parameters |
||
213 | (const fsf_contract_parameters_t *contract, |
||
214 | struct timespec *budget_min, |
||
215 | struct timespec *period_max, |
||
216 | struct timespec *budget_max, |
||
217 | struct timespec *period_min, |
||
218 | fsf_workload_t *workload); |
||
219 | |||
220 | //Description: This operation obtains from the specified contract parameters |
||
221 | //object its budget, period, and workload, and copies them to the places |
||
222 | //pointed to by the corresponding input parameters. |
||
223 | |||
224 | int |
||
225 | fsf_set_contract_timing_requirements |
||
226 | (fsf_contract_parameters_t *contract, |
||
227 | bool d_equals_t, |
||
228 | const struct timespec *deadline, |
||
229 | int budget_overrun_sig_notify, |
||
230 | union sigval budget_overrun_sig_value, |
||
231 | int deadline_miss_sig_notify, |
||
232 | union sigval deadline_miss_sig_value); |
||
233 | |||
234 | //Description: The operation updates the specified contract parameters |
||
235 | //object. d_equals_t is used as a boolean, deadline must be |
||
236 | //NULL_DEADLINE if d_equals_t is true, budget_overrun_sig_notify or |
||
237 | //deadline_miss_sig_notify may be NULL_SIGNAL (no notification) or any |
||
238 | //posix signal. budget_overrun_sig_value and deadline_miss_sig_value |
||
239 | //are the values to be delivered with the signal. |
||
240 | |||
241 | int |
||
242 | fsf_get_contract_timing_requirements |
||
243 | (const fsf_contract_parameters_t *contract, |
||
244 | bool *d_equals_t, |
||
245 | struct timespec *deadline, |
||
246 | int *budget_overrun_sig_notify, |
||
247 | union sigval *budget_overrun_sig_value, |
||
248 | int *deadline_miss_sig_notify, |
||
249 | union sigval *deadline_miss_sig_value); |
||
250 | |||
251 | //Description: The operation obtains the corresponding input |
||
252 | //parameters from the specified contract parameters object. If |
||
253 | //d_equals_t is true, the deadline will not be updated. |
||
254 | |||
255 | int |
||
256 | fsf_set_contract_reclamation_parameters |
||
257 | (fsf_contract_parameters_t *contract, |
||
258 | fsf_granularity_t granularity, |
||
259 | const fsf_utilization_set_t *utilization_set, |
||
260 | int quality, |
||
261 | int importance); |
||
262 | |||
263 | //Description: The operation updates the specified contract parameters |
||
264 | //object by setting its granularity, utilization set, quality, and |
||
265 | //importance to the specified input parameters. |
||
266 | |||
267 | int |
||
268 | fsf_get_contract_reclamation_parameters |
||
269 | (const fsf_contract_parameters_t *contract, |
||
270 | fsf_granularity_t *granularity, |
||
271 | fsf_utilization_set_t *utilization_set, |
||
272 | int *quality, |
||
273 | int *importance); |
||
274 | |||
275 | //Description: The operation obtains from the specified contract parameters |
||
276 | //object its granularity, utilization set, quality, and importance. Then |
||
277 | //copies them to the places pointed to by the specified input parameters. |
||
278 | //Only the utilization_values of the utilization_set that are in use, are |
||
279 | //copied (according to its size field). |
||
280 | |||
281 | |||
282 | /* OLD VERSION |
||
283 | int |
||
284 | fsf_set_contract_synchronization_parameters |
||
285 | (fsf_contract_parameters_t *contract, |
||
286 | fsf_preemption_level_t preemption_level, |
||
287 | const fsf_critical_sections_t *critical_sections); |
||
288 | |||
289 | //Description: The operation updates the specified contract parameters |
||
290 | //object by setting its preemption level and critical sections to the |
||
291 | //specified input parameters. |
||
292 | |||
293 | */ |
||
294 | |||
295 | int |
||
296 | fsf_get_contract_synchronization_parameters |
||
297 | (const fsf_contract_parameters_t *contract, |
||
298 | fsf_preemption_level_t *preemption_level, |
||
299 | fsf_critical_sections_t *critical_sections); |
||
300 | |||
301 | //Description: The operation obtains from the specified contract |
||
302 | //parameters object its preemption level and critical sections, and |
||
303 | //copies them to the places pointed to by the specified input |
||
304 | //parameters. Only those critical_section_data records that are in use |
||
305 | //in the critical_sections structure are copied (according to its size |
||
306 | //field). |
||
307 | |||
308 | int |
||
309 | fsf_set_local_scheduler_parameter |
||
310 | (fsf_contract_parameters_t *contract, |
||
311 | fsf_scheduler_id_t local_scheduler_id); |
||
312 | |||
313 | //Description: Set the local scheduler |
||
314 | |||
315 | int |
||
316 | fsf_get_local_scheduler_parameter |
||
317 | (const fsf_contract_parameters_t *contract, |
||
318 | fsf_scheduler_id_t *local_scheduler_id); |
||
319 | |||
320 | //Description: Get the local scheduler |
||
321 | |||
322 | ////////////////////////////////////////////////////////////// |
||
323 | // SYNCHRONIZATION OBJECTS |
||
324 | ////////////////////////////////////////////////////////////// |
||
325 | |||
326 | //An abstract synchronization object is defined by the application. |
||
327 | //This object can be used by an application to wait for an event to |
||
328 | //arrive by invoking the Event Triggered Schedule Next Job operation. |
||
329 | //It can also be used to signal the event either causing a waiting |
||
330 | //server to wake up, or the event to be queued if no server is waiting |
||
331 | //for it. It is defined by the following opaque type and has the |
||
332 | //following operations: |
||
333 | |||
334 | typedef FSF_SYNCH_OBJECT_HANDLE_T_OPAQUE fsf_synch_object_handle_t; |
||
335 | |||
336 | int |
||
337 | fsf_create_synchobject(fsf_synch_object_handle_t *synch_handle); |
||
338 | |||
339 | //Description: This operation creates and initializes a |
||
340 | //synchronization object variable managed by the scheduler, and |
||
341 | //returns a handle to it in the variable pointed to by synch_handle. |
||
342 | |||
343 | int |
||
344 | fsf_signal_synchobject(fsf_synch_object_handle_t *synch_handle); |
||
345 | |||
346 | //Description: If one or more servers are waiting upon the specified |
||
347 | //synchronization object one of them is awakened; if not, the event is |
||
348 | //queued at the synchronization object. |
||
349 | |||
350 | int |
||
351 | fsf_destroy_synchobject(fsf_synch_object_handle_t *synch_handle); |
||
352 | |||
353 | //This operation destroys the synchronization object (created by a |
||
354 | //previous call to fsf_create_synchobject) that is referenced by the |
||
355 | //synch_handle variable. After calling this operation, the |
||
356 | //synch_handle variable can not be used until it is initialized again |
||
357 | //by a call to fsf_create_synchobject. |
||
358 | |||
359 | |||
360 | /////////////////////////////////////////////////////////////// |
||
361 | // CONTRACT NEGOCIATION OPERATIONS |
||
362 | /////////////////////////////////////////////////////////////// |
||
363 | |||
364 | // Server Id type, that identifies a server created to manage a |
||
365 | // given contract |
||
366 | |||
367 | typedef int fsf_server_id_t; |
||
368 | |||
369 | |||
370 | typedef struct { |
||
371 | fsf_server_id_t server; |
||
372 | TIME actual_period; |
||
373 | TIME actual_budget; |
||
374 | int Qs; // quality of service |
||
375 | int Is; // importance of service |
||
376 | bandwidth_t U; // actual bandwidth |
||
377 | bandwidth_t Umin; // min bandwidth |
||
378 | bandwidth_t Umax; // max bandwidth |
||
379 | TIME Cmin; |
||
380 | TIME Tmin; |
||
381 | TIME Tmax; |
||
382 | TIME deadline; |
||
383 | bool d_equals_t; |
||
384 | } server_elem; |
||
385 | |||
386 | int recalculate_contract(bandwidth_t U); |
||
387 | |||
388 | |||
389 | // The following type references a function that may become |
||
390 | // a thread's code |
||
391 | |||
392 | typedef void * (*fsf_thread_code_t) (void *); |
||
393 | |||
394 | // Negotiate contract functions: The following functions are used to |
||
395 | // create servers for a contract parameters specification and also to |
||
396 | // assign one or more threads to a server (Note: the current |
||
397 | // implementation only supports one thread per server; this limitation |
||
398 | // will be removed in the next phase of the project) |
||
399 | |||
400 | // The first time that any of these operations is called, it creates |
||
401 | // all the internal management structures that are necessary for the |
||
402 | // FIRST Scheduling Framework to operate properly. |
||
403 | |||
404 | int |
||
405 | fsf_negotiate_contract |
||
406 | (const fsf_contract_parameters_t *contract, |
||
407 | fsf_server_id_t *server); |
||
408 | |||
409 | //Description: The operation negotiates a contract for a new |
||
410 | //server. If the on-line admission test is enabled it determines |
||
411 | //whether the contract can be admitted or not based on the current |
||
412 | //contracts established in the system. Then it creates the server and |
||
413 | //recalculates all necessary parameters for the contracts already |
||
414 | //present in the system. This is a potentially blocking operation; it |
||
415 | //returns when the system has either rejected the contract, or |
||
416 | //admitted it and made it effective. It returns zero and places the |
||
417 | //server identification number in the location pointed to by the |
||
418 | //server input parameter if accepted, or an error if rejected. No |
||
419 | //thread is bound to the newly created server, which will be idle |
||
420 | //until a thread is bound to it. This operation can only be executed |
||
421 | //by threads that are already bound to an active server and therefore |
||
422 | //are being scheduled by the fsf scheduler. |
||
423 | |||
424 | int |
||
425 | fsf_create_thread |
||
426 | (fsf_server_id_t server, |
||
427 | pthread_t *thread, |
||
428 | pthread_attr_t *attr, |
||
429 | fsf_thread_code_t thread_code, |
||
430 | void *arg, |
||
431 | void *local_scheduler_arg); |
||
432 | |||
433 | //Description: This operation creates a new thread inside a specific |
||
434 | //server. The local_scheduler_arg parameter is used to pass specific |
||
435 | //parameters to local scheduler. These parameters are application |
||
436 | //depented. |
||
437 | |||
438 | int |
||
439 | fsf_get_server |
||
440 | (fsf_server_id_t *server, |
||
441 | pthread_t thread); |
||
442 | |||
443 | //Description: This operation returns the server associated with a |
||
444 | //thread. It returns an error if the thread does not exist, it is not |
||
445 | //under the control of the scheduling framework, or is not bound. |
||
446 | |||
447 | int |
||
448 | fsf_cancel_contract (fsf_server_id_t *server); |
||
449 | |||
450 | //Description: The operation eliminates the specified server and |
||
451 | //recalculates all necessary parameters for the contracts remaining in |
||
452 | //the system. This is a potentially blocking operation; it returns when |
||
453 | //the system has made the changes effective. |
||
454 | |||
455 | int |
||
456 | fsf_renegotiate_contract |
||
457 | (const fsf_contract_parameters_t *new_contract, |
||
458 | fsf_server_id_t server); |
||
459 | |||
460 | //Description: The operation renegotiates a contract for an existing |
||
461 | //server. If the on-line admission test is enabled it determines |
||
462 | //whether the contract can be admitted or not based on the current |
||
463 | //contracts established in the system. If it cannot be admitted, the |
||
464 | //old contract remains in effect and an error is returned. If it can |
||
465 | //be admitted, it recalculates all necessary parameters for the |
||
466 | //contracts already present in the system anr returns zero. This is a |
||
467 | //potentially blocking operation; it returns when the system has |
||
468 | //either rejected the new contract, or admitted it and made it |
||
469 | //effective. |
||
470 | |||
471 | int |
||
472 | fsf_request_contract_renegotiation |
||
473 | (const fsf_contract_parameters_t *new_contract, |
||
474 | fsf_server_id_t server, |
||
475 | int sig_notify, |
||
476 | union sigval sig_value); |
||
477 | |||
478 | //Description: The operation enqueues a renegotiate operation for an |
||
479 | //existing server, and returns immediately. The renegotiate operation |
||
480 | //is performed asynchronously, as soon as it is practical; meanwhile |
||
481 | //the system operation will continue normally. When the renegotiation |
||
482 | //is made, if the on-line admission test is enabled it determines |
||
483 | //whether the contract can be admitted or not based on the current |
||
484 | //contracts established in the system. If it cannot be admitted, the |
||
485 | //old contract remains in effect. If it can be admitted, it |
||
486 | //recalculates all necessary parameters for the contracts already |
||
487 | //present in the system. When the operation is completed, notification |
||
488 | //is made to the caller, if requested, via a signal. The status of the |
||
489 | //operation (in progress, admitted, rejected) can be checked with the |
||
490 | //get_renegotiation_status operation. The argument sig_notify can be |
||
491 | //NULL_SIGNAL (no notification), or any posix signal; and in this case |
||
492 | //sig_value is to be sent with the signal. |
||
493 | |||
494 | typedef enum {FSF_IN_PROGRESS, |
||
495 | FSF_REJECTED, |
||
496 | FSF_ADMITTED} fsf_renegotiation_status_t; |
||
497 | |||
498 | int |
||
499 | fsf_get_renegotiation_status |
||
500 | (fsf_server_id_t server, |
||
501 | fsf_renegotiation_status_t *renegotiation_status); |
||
502 | |||
503 | //Description: The operation reports on the status of the last |
||
504 | //renegotiation operation enqueued for the specified server. It is |
||
505 | //callable even after notification of the completion of such operation, |
||
506 | //if requested. |
||
507 | |||
508 | int |
||
509 | fsf_request_change_quality_and_importance |
||
510 | (fsf_server_id_t server, |
||
511 | int new_importance, |
||
512 | int new_quality); |
||
513 | |||
514 | //Description: The operation enqueues a request to change the quality and |
||
515 | //importance parameters of the specified server, and returns immediately. |
||
516 | //The change operation is performed as soon as it is practical; |
||
517 | //meanwhile the system operation will continue normally. |
||
518 | |||
519 | |||
520 | //////////////////////////////////////////////////////////// |
||
521 | // SCHEDULING BOUNDED WORKLOADS |
||
522 | //////////////////////////////////////////////////////////// |
||
523 | |||
524 | int |
||
525 | fsf_schedule_next_timed_job |
||
526 | (const struct timespec *at_absolute_time, |
||
527 | struct timespec *next_budget, |
||
528 | struct timespec *next_period, |
||
529 | bool *was_deadline_missed, |
||
530 | bool *was_budget_overran); |
||
531 | |||
532 | //Description: This operation is invoked by threads associated with |
||
533 | //bounded workload servers to indicate that a job has been completed |
||
534 | //(and that the scheduler may reassign the unused capacity of the |
||
535 | //current job to other servers), and also when the first job require |
||
536 | //to be scheduled. The system will activate the job at the specified |
||
537 | //absolute time, and will then use the scheduling rules to determine |
||
538 | //when the job can run, at which time the call returns. Upon return, |
||
539 | //the system reports the current period and budget for the current |
||
540 | //job, whether the deadline of the previous job was missed or not, |
||
541 | //and whether the budget of the previous job was overrun or not. |
||
542 | |||
543 | |||
544 | int |
||
545 | fsf_schedule_next_event_triggered_job |
||
546 | (fsf_synch_object_handle_t *synch_handle, |
||
547 | struct timespec *next_budget, |
||
548 | struct timespec *next_period, |
||
549 | bool *was_deadline_missed, |
||
550 | bool *was_budget_overran); |
||
551 | |||
552 | //Description: This operation is invoked by threads associated with |
||
553 | //bounded workload servers to indicate that a job has been completed |
||
554 | //(and that the scheduler may reassign the unused capacity of the |
||
555 | //current job to other servers), and also when the first job require |
||
556 | //to be scheduled. If the specified synchronization object has events |
||
557 | //queued, one of them is dequeued; otherwise the server will wait upon |
||
558 | //the specified synchronization object until it is signalled. Then, the |
||
559 | //system will use the scheduling rules to determine when the job can run |
||
560 | //and the call will return at that time. Upon return, the system reports |
||
561 | //the current period and budget for the current job, whether the deadline |
||
562 | //of the previous job was missed or not, and whether the budget of the |
||
563 | //previous job was overrun or not. |
||
564 | |||
565 | |||
566 | ////////////////////////////////////////////////////////////// |
||
567 | // OBTAINING INFORMATION FROM THE SCHEDULER |
||
568 | ////////////////////////////////////////////////////////////// |
||
569 | |||
570 | int |
||
571 | fsf_get_available_capacity (fsf_server_id_t server, float *capacity); |
||
572 | |||
573 | //Description: This operation returns the current spare capacity (in |
||
574 | //percentage of processor or network utilization), currently assigned |
||
575 | //to the importance level of the specified server. |
||
576 | |||
577 | int |
||
578 | fsf_get_total_quality (fsf_server_id_t server, int *total_quality); |
||
579 | |||
580 | //Description: This operation returns the sum of the quality parameters |
||
581 | //for all servers in the system of importance level equal to that of |
||
582 | //the specified server. |
||
583 | |||
584 | int |
||
585 | fsf_is_admission_test_enabled(); |
||
586 | |||
587 | //Description: Returns true if the system is configured with the |
||
588 | //on-line admission test enabled, or false otherwise. |
||
589 | |||
590 | |||
591 | // Mutex function |
||
592 | |||
593 | // Initialization |
||
594 | // here we initialize the second and third field of the structure |
||
595 | void fsf_init_shared_op(fsf_shared_operation_t *op, |
||
596 | fsf_shared_op_id_t op_id, |
||
597 | struct timespec wcet); |
||
598 | |||
599 | // initialization |
||
600 | // The shared object id is set equal to the second parameter. |
||
601 | int fsf_init_shared_object(fsf_shared_object_t *obj, |
||
602 | fsf_shared_obj_id_t id); |
||
603 | |||
604 | // Declare an operation |
||
605 | // This function is used to declare that a shared object has |
||
606 | // a synchronized operation on it. |
||
607 | // It checks if another operation with the same id has already been |
||
608 | // declared; if so, return false (-1). |
||
609 | // The obj_id field of the operation is set equal to the shared object id. |
||
610 | // the structure op is copied in the first free element in the array |
||
611 | // shared_op pof the structure obj. If there are no more free element, |
||
612 | // returns -1. |
||
613 | // Returns 0 if the operation has been completed, -1 otherwise. |
||
614 | |||
615 | int fsf_declare_shared_object_operation(fsf_shared_object_t *obj, |
||
616 | fsf_shared_operation_t *op); |
||
617 | |||
618 | |||
619 | int fsf_lock_object(fsf_shared_operation_t *op); |
||
620 | |||
621 | int fsf_unlock_object(fsf_shared_operation_t *op); |
||
622 | |||
623 | // set contract parameters |
||
624 | // specify a list of operations for each contract |
||
625 | // the list is specified as a pointer to an array. |
||
626 | // the size of the array is specified as third parameter |
||
627 | // returns 0 if all operations are correctly initialized |
||
628 | // returns -1 otherwise. |
||
629 | |||
630 | int fsf_set_contract_synchronization_parameters( |
||
631 | fsf_contract_parameters_t *contract, |
||
632 | const fsf_shared_operation_t *shared_ops, |
||
633 | size_t op_num); |
||
634 | |||
635 | |||
636 | |||
637 | #endif // _FSF_CONTRACT_H_ |