Subversion Repositories shark

Rev

Rev 974 | Rev 985 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
983 lipari 1
/**
2
   @file This file contains the functions and definitions for the core
3
   module.
4
 
5
   The file contains all fuinctions and data structures for the core
6
   module of the FSF.
7
 */
8
 
881 trimarchi 9
//fsf_core.h
10
//=================================================================
11
//       FFFFFFIII   RRRRR      SSTTTTTTT
12
//      FF         IIR   RR    SS
13
//     FF           IR        SS
14
//    FFFFFF         RRRR    SSSSST
15
//   FF       FI       RRR  SS
16
//  FF         II     RRR  SS
17
// FF           IIIIIR    RS
18
//
19
// Basic FSF(FIRST Scheduling Framework) contract management
20
//================================================================
21
 
929 lipari 22
 
881 trimarchi 23
#include <time.h>
24
#include <pthread.h>
25
#include <sys/types.h>
983 lipari 26
#include <stdbool.h>  
881 trimarchi 27
 
28
#include "fsf_configuration_parameters.h"
29
#include "fsf_opaque_types.h"
30
#include "fsf_basic_types.h"
31
 
32
#ifndef _FSF_CORE_H_
33
#define _FSF_CORE_H_
34
 
35
 
983 lipari 36
//////////////////////////////////////////////////////////////////////
37
//           INITIALIZATION SERVICES 
38
//////////////////////////////////////////////////////////////////////
881 trimarchi 39
 
983 lipari 40
/**
41
    \ingroup coremodule
881 trimarchi 42
 
983 lipari 43
    \defgroup core_init Initialization and utilities
928 trimarchi 44
 
983 lipari 45
    @{
46
*/
47
 
48
/**
49
   We cannot call any fsf functions before fsf_init. After calling
50
   fsf_init, the main will be executing in the background. Then, it
51
   can do the negotiations, create the threads and, if needed,
52
   activate them via some user-specified synchronization mechanism. It
53
   may also create a contract for itself. The second time this
54
   function is called it fails.
55
 
56
   @retval 0 if the system is initialized
57
   @retval FSF_ERR_SYSTEM_ALREADY_INITIALIZED if the function has already
58
           been called before
59
 
60
   @retval others It may also return any of the errors that may be
61
         returned by the underlying operating system primitives
62
         required to perform the FSF system start up
63
*/
64
int fsf_init();
65
 
881 trimarchi 66
/**
67
   This function converts an error code to an error message that is
68
   stored in the buffer starting at the location pointed to by
69
   message. The size of this buffer is specified by the size
70
   argument. If the error message is longer than size-1, it is
71
   truncated to that length. Regardless of whether the message is
72
   truncated or not, a final zero character that marks the end of the
73
   string is stored in the buffer.  The function fails if the error
74
   code passed does not correspond to any of the fsf error codes.
983 lipari 75
 
76
   @retval FSF_ERR_BAD_ARGUMENT  error is not a valid value
881 trimarchi 77
*/
78
int fsf_strerror (int error, char *message, size_t size);
79
 
983 lipari 80
/* @} */
81
 
881 trimarchi 82
/////////////////////////////////////////////////////////////
83
//                       CONTRACT PARAMETERS
84
/////////////////////////////////////////////////////////////
85
 
86
/**
983 lipari 87
   \ingroup coremodule
88
   \defgroup core_contract Contract Creation and Initialization.
881 trimarchi 89
 
90
   These functions are used to create and initialize a contract, and
91
   set its parameters.
92
 */
93
/*@{*/
94
/**
95
    Contract parameters type; it is an opaque type (i.e. the internal
96
    structure of this data type is implementation dependent). The user
97
    can access and modify the parameters of a contract only with the
98
    proper functions, and should never access the data directly.
99
*/
100
typedef FSF_CONTRACT_PARAMETERS_T_OPAQUE fsf_contract_parameters_t;
101
 
102
/**
103
    The operation receives a pointer to a contract parameters object
104
    and initializes it, setting it to the default values.
105
    The default values are:
983 lipari 106
    - budget min and max are set to 0;
107
    - period min and max are set to 0;
108
    - the workload is unbounded (FSF_INDETERMINATE);
109
    - the server deadline is equal to the period;
110
    - the budget and deadline overrun are not notified;
111
    - the granularity is set to "continuous";
112
    - the quality and importance are set to the default values;
113
    - the scheduling policy is FSF_NONE.
881 trimarchi 114
 
115
    @param     contract the pointer to the contract variable.
983 lipari 116
    @retval   FSF_ERR_BAD_ARGUMENT   contract is NULL
881 trimarchi 117
*/
118
int fsf_initialize_contract (fsf_contract_parameters_t *contract);
119
 
120
//  budget_min                => {0,0};
121
//  period_max                => {0,0};
122
//  budget_max                => {0,0};
123
//  period_min                => {0,0};
124
//  workload                  => DEFAULT_WORKLOAD;
125
 
126
//  d_equals_t                => DEFAULT_D_EQUALS_T; (false or true)
127
//  deadline                  => DEFAULT_DEADLINE;
128
//  budget_overrun_sig_notify => 0;  (signal number)
129
//  budget_overrun_sig_value  => {0, NULL};
130
//  deadline_miss_sig_notify  => 0;  (signal number)
131
//  deadline_miss_sig_value   => {0, NULL};
132
//
133
//  granularity               => DEFAULT_GRANULARITY;
134
//  utilization_set;          => size = 0
135
//  quality                   => DEFAULT_QUALITY;    (range 0..100)
136
//  importance                => DEFAULT_IMPORTANCE; (range 1..5)
137
//
138
//  preemption_level          => 0; (range 1..2**32-1)
139
//  critical_sections;        => size = 0
140
 
141
//  sched_policy              => DEFAULT_SCHED_POLICY
142
//                              (FSF_NONE)
143
 
144
 
145
/**
146
   The operation updates the specified contract parameters object by
147
   setting its budget, period, and workload to the specified input
148
   parameters. (Note: the workload is a basic parameter because
149
   bounded tasks are triggered by the scheduler (see the
150
   fsf_schedule_timed_job() operation), while indeterminate tasks are
151
   not; therefore, their programming model is quite different).
152
 
983 lipari 153
   @param contract          the pointer to the contract object
881 trimarchi 154
   @param [in] budget_min   the minimum budget for the contract
155
   @param [in] period_max   the maximum period for the contract
983 lipari 156
   @param [in] workload     the kind of workload (can be FSF_BOUNDED or
157
                            FSF_INDETERMINATE)
881 trimarchi 158
 
983 lipari 159
   @retval 0 if the operation is succesful
160
   @retval FSF_ERR_BAD_ARGUMENT if any of the pointers is NULL
881 trimarchi 161
       or if only one of the timespec values is 0, and also if the workload
983 lipari 162
       is not a proper value (FSF_INDETERMINATE or FSF_BOUNDED)
881 trimarchi 163
*/
164
int
165
fsf_set_contract_basic_parameters
166
  (fsf_contract_parameters_t *contract,
167
   const struct timespec     *budget_min,
168
   const struct timespec     *period_max,
169
   fsf_workload_t            workload);
170
 
171
/**
172
   This operation obtains from the specified contract parameters
173
   object its budget, period, and workload, and copies them to the
174
   places pointed to by the corresponding input parameters.
175
 
176
   @param [in] contract   the pointer to the contract object
177
   @param[out] budget_min pointer to the variable that will contain
178
   the minimum budget
179
   @param[out] period_max pointer to the variable that will contain the
180
   max_period
181
   @param[out] workload pointer to the variable that will contain the
182
   workload type
183
 
983 lipari 184
   @retval  FSF_ERR_BAD_ARGUMENT :  if contract is NULL
881 trimarchi 185
*/
186
int
187
fsf_get_contract_basic_parameters
188
  (const fsf_contract_parameters_t *contract,
189
   struct timespec  *budget_min,
190
   struct timespec  *period_max,
191
   fsf_workload_t   *workload);
192
 
193
 
194
/**
195
   The operation updates the specified contract parameters
196
   object, specifying the additional parameters requirements of
197
   a contract.
198
 
199
   @param  contract The pointer to the contract object
200
 
201
   @param [in] d_equals_t It is a boolean value, set to true (1) if the
202
                 we want to specify a deadline different from the period
203
                 for the contract.
204
   @param [in] deadline If the previous parameter is set to true,
205
                 this parameter should be set to NULL_DEADLINE. Otherwise,
206
                 it contains the desired deadline value.
983 lipari 207
 
881 trimarchi 208
   @param [in] budget_overrun_sig_notify contains the number of posix signal
209
                 that must be raised if the budget of the server is overrun.
210
                 If the value of this parameter is NULL_SIGNAL, no signal will
211
                 be raised.
212
   @param [in] budget_overrun_sig_value contains the value that will be
213
                 passed to the signal "catcher" when the signal is raised.
214
                 This parameters is not used if the budget_overrun_sig_notify
215
                 parameters is set to NULL_SIGNAL.
216
   @param [in] deadline_miss_sig_notify contains the number of posix
217
                 signal that must be raised if the deadline of the server
218
                 is missed. If the value of this parameter is NULL_SIGNAL,
219
                 no signal is raised.
220
   @param [in] deadline_miss_sig_value contains the value that will be
221
                 passed to the signal "catcher" when the signal is raised.
222
                 This parameters is not used if the budget_overrun_sig_notify
223
                 parameters is set to NULL_SIGNAL
224
 
983 lipari 225
   @retval 0    if the operation is succesful
226
   @retval FSF_BAD_ARGUMENT if contract is NULL or  
881 trimarchi 227
       (d_equals_t is true and  deadline is not FSF_NULL_DEADLINE) or
228
       (budget_overrun_sig_notify is not a valid signal)  or
229
       (deadline_miss_sig_notify is not a valid signal)  or
230
       (d_equals_t is false but (deadline is FSF_NULL_DEADLINE or its value
983 lipari 231
                                 is grater than the contracts maximum period))
881 trimarchi 232
 
233
   @see sigexplanation
234
*/
235
int
236
fsf_set_contract_timing_requirements
237
  (fsf_contract_parameters_t *contract,
238
   bool                   d_equals_t,
239
   const struct timespec *deadline,
240
   int                    budget_overrun_sig_notify,
241
   union sigval           budget_overrun_sig_value,
242
   int                    deadline_miss_sig_notify,
243
   union sigval           deadline_miss_sig_value);
244
 
245
/**
246
   The operation obtains the corresponding input parameters from the
247
   specified contract parameters object. If d_equals_t is true, the
248
   deadline will not be updated.
249
 
983 lipari 250
   @retval FSF_ERR_BAD_ARGUMENT if contract is NULL
251
 
252
   @see fsf_set_contract_timing_requirements
881 trimarchi 253
*/
254
int
255
fsf_get_contract_timing_requirements
256
  (const fsf_contract_parameters_t *contract,
257
   bool                    *d_equals_t,
258
   struct timespec         *deadline,
259
   int                     *budget_overrun_sig_notify,
260
   union sigval            *budget_overrun_sig_value,
261
   int                     *deadline_miss_sig_notify,
262
   union sigval            *deadline_miss_sig_value);
263
 
264
/*@}*/
265
 
266
//////////////////////////////////////////////////////////////////
267
//                 SYNCHRONIZATION OBJECTS
268
//////////////////////////////////////////////////////////////////
269
 
270
 
271
/**
983 lipari 272
   \ingroup coremodule
273
 
274
   \defgroup core_synch  Synchronization objects
275
 
276
   These objects are used to synchronize threads belonging to bounded
277
   workload servers.
278
 
279
   In the future we may add a broadcast operation that would signal a
280
   group of synchronization objects. We have not included a broadcast
281
   service in this version because it can be easily created by the
282
   user by signalling individual synchronization objects inside a
283
   loop.
284
 
285
   Notice that for synchronization objects there is no naming service
286
   like in shared objects because tasks that use synchronization are
287
   not developed independently, as they are closely coupled.
288
 
881 trimarchi 289
*/
290
/*@{*/
291
/**
292
   An abstract synchronization object is defined by the application.
293
   This object can be used by an application to wait for an event to
294
   arrive by invoking the fsf_schedule_triggered_job() operation.  It
295
   can also be used to signal the event either causing a waiting
296
   server to wake up, or the event to be queued if no server is
297
   waiting for it.
298
*/
299
typedef FSF_SYNCH_OBJ_HANDLE_T_OPAQUE fsf_synch_obj_handle_t;
300
 
301
 
302
/**
303
   This operation creates and initializes a synchronization object
304
   variable managed by the scheduler, and returns a handle to it in
305
   the variable pointed to by synch_handle.
306
 
983 lipari 307
   @param[out] synch_handle pointer to the variable that will contain
308
                the handle to the newly created synchronization object
881 trimarchi 309
 
983 lipari 310
   @retval  0 if the operation is succesful
311
   @retval  FSF_ERR_BAD_ARGUMENT   if synch_handle is 0
312
   @retval  FSF_ERR_TOO_MANY_SYNCH_OBJS  if the number of synchronization
313
             objects in the system has already exceeded the maximum
314
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD  if the calling thread is not
315
            scheduled under the FSF
316
   @retval  FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong
317
             or not running
881 trimarchi 318
*/
319
int
320
fsf_create_synch_obj
321
    (fsf_synch_obj_handle_t *synch_handle);
322
 
983 lipari 323
/**
974 trimarchi 324
 
881 trimarchi 325
   This function sends a notification to the synchronization object
983 lipari 326
   specified as parameter. If there is at least one server waiting on
327
   the synchronization object, the corresponding thread is unblocked,
328
   and the server rules for budget recharging apply.
881 trimarchi 329
 
983 lipari 330
   If more than one server is waiting, just one of them is woken.
331
   However, which one is woken is implementation dependent.
332
 
333
   If no thread is waiting on the synchronization object, the
334
   notification is queued.
335
 
881 trimarchi 336
   @param [in] synch_handle the handle of the synchronization object to
337
                  notify.
338
 
983 lipari 339
   @retval 0 if the operation is completed succesfully
340
   @retval FSF_ERR_BAD_ARGUMENT   if synch_handle is 0
341
   @retval FSF_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid
342
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD  if the calling thread
343
              is not scheduled under the FSF
344
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or
345
              not running
346
   @retval FSF_ERR_TOO_MANY_EVENTS_IN_SYNCH_OBJ  if the number of
347
              events stored in the synchronization object reaches the
348
              maximum defined in the configuration parameter header file
881 trimarchi 349
 
983 lipari 350
   @see fsf_schedule_triggered_job, fsf_timed_schedule_triggered_job
881 trimarchi 351
*/
352
int
353
fsf_signal_synch_obj
354
    (fsf_synch_obj_handle_t synch_handle);
355
 
356
/**
357
   This operation destroys the synchronization object (created by a
358
   previous call to fsf_create_synch_obj) that is referenced by the
359
   synch_handle variable. After calling this operation, the
360
   synch_handle variable can not be used until it is initialized again
361
   by a call to fsf_create_synch_obj.
362
 
363
   @param synch_handle the handle to the synchronization object
364
             to be destroyed
365
 
983 lipari 366
   @retval 0 if the operation is succesful
367
   @retval FSF_ERR_INVALID_SYNCH_OBJ_HANDLE is the handle is not valid
368
   @retval FSF_ERR_BAD_ARGUMENT   if synch_handle is 0
369
   @retval FSF_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid
370
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 371
       scheduled under the FSF
983 lipari 372
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or
373
       not running
881 trimarchi 374
 
983 lipari 375
   @see fsf_create_synch_obj
881 trimarchi 376
*/
377
int
378
fsf_destroy_synch_obj
379
    (fsf_synch_obj_handle_t synch_handle);
380
 
381
 
382
////////////////////////////////////////////////////
383
//           SCHEDULING BOUNDED WORKLOADS
384
////////////////////////////////////////////////////
385
 
386
/**
387
   This operation is invoked by threads associated with bounded
388
   workload servers to indicate that a job has been completed (and
389
   that the scheduler may reassign the unused capacity of the current
390
   job to other servers). It is also invoked when the first job of
983 lipari 391
   such threads has to be scheduled.
881 trimarchi 392
 
393
   As an effect, the system will make the current server's budget zero
394
   for the remainder of the server's period, and will not replenish
395
   the budget until the specified absolute time.  At that time, all
396
   pending budget replenishments (if any) are made effective. Once the
397
   server has a positive budget and the scheduler schedules the
398
   calling thread again, the call returns and at that time, except for
399
   those parameters equal to NULL pointers, the system reports the
400
   current period and budget for the current job, whether the deadline
401
   of the previous job was missed or not, and whether the budget of
402
   the previous job was overrun or not.
403
 
404
   In a system with hierarchical scheduling, since this call makes the
405
   budget zero, the other threads in the same server are not run. As
406
   mentioned abobe, only when the call finishes the budget may be
407
   replenished.
408
 
409
   @param [in] abs_time     absolute time at which the budget will be
410
                            replenished
411
 
412
   @param [out] next_budget upon return of this function, the variable
413
                            pointed by this function will be equal to
414
                            the current server budget. If this parameter is
415
                            set to NULL, no action is taken.
416
 
417
   @param [out] next_period upon return of this function, the variable
418
                            pointed by this function will be equal to
419
                            the current server period. If this parameter is
420
                            set to NULL, no action is taken.
421
 
422
   @param [out] was_deadline_missed upon return of this function, the
423
                            variable pointed by this function will be
424
                            equal to true if the previous server deadline
425
                            was missed, to false otherwise. If this
426
                            parameter is set to NULL, no action is
427
                            taken.
428
 
983 lipari 429
   @param [out] was_budget_overran upon return of this function, the
881 trimarchi 430
                            variable pointed by this function will be
431
                            equal to true if the previous server budget was
432
                            overrun, to false otherwise. If this
433
                            parameter is set to NULL, no action is
434
                            taken.
435
 
983 lipari 436
   @retval 0 if the operation is succesful
437
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or
438
              not running
439
   @retval FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction of the FSF
881 trimarchi 440
       main scheduler
983 lipari 441
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is
442
       not scheduled under the FSF
443
   @retval FSF_ERR_UNBOUND if the calling thread does not have a valid
881 trimarchi 444
       server bound to it
983 lipari 445
   @retval FSF_ERR_BAD_ARGUMENT   if the workload of the server is not
446
       FSF_BOUNDED
881 trimarchi 447
 
448
   @sa fsf_schedule_triggered_job, fsf_timed_schedule_triggered_job
449
*/
450
int
451
fsf_schedule_timed_job
452
  (const struct timespec *abs_time,
453
   struct timespec       *next_budget,
454
   struct timespec       *next_period,
455
   bool                  *was_deadline_missed,
456
   bool                  *was_budget_overran);
457
 
458
/**
459
   This operation is invoked by threads associated with bounded
460
   workload servers to indicate that a job has been completed (and
461
   that the scheduler may reassign the unused capacity of the current
462
   job to other servers). It is also invoked when the first job of
463
   such threads has to be scheduled. If the specified synchronization
464
   object has events queued, one of them is dequeued; otherwise the
465
   server will wait upon the specified synchronization object, the
466
   server's budget will be made zero for the remainder of the server's
467
   period, and the implementation will not replenish the budget until
983 lipari 468
   the specified synchronization object is signalled.
881 trimarchi 469
 
983 lipari 470
   At that time, all pending budget replenishments (if any) are made
471
   effective. Once the server has a positive budget and the scheduler
472
   schedules the calling thread again, the call returns and at that
473
   time, except for those parameters equal to NULL pointers, the
474
   system reports the current period and budget for the current job,
475
   whether the deadline of the previous job was missed or not, and
476
   whether the budget of the previous job was overrun or not.
477
 
881 trimarchi 478
   In a system with hierarchical scheduling, since this call makes the
479
   budget zero, the other threads in the same server are not run. As
480
   mentioned above, only when the call finishes the budget may be
481
   replenished.
482
 
983 lipari 483
   @param [in]  synch_handle   handle of the synchronization object
881 trimarchi 484
 
983 lipari 485
   @param [out] next_budget    upon return of this function, the variable
486
                               pointed by this function will be equal
487
                               to the current server budget. If this
488
                               parameter is set to NULL, no action is
489
                               taken.
490
   @param [out] next_period    upon return of this function, the variable
491
                               pointed by this function will be equal to
492
                               the current server period. If this parameter is
493
                               set to NULL, no action is taken.
881 trimarchi 494
 
983 lipari 495
   @param [out] was_deadline_missed upon return of this function, the
496
                            variable pointed by this function will be
497
                            equal to true if the previous server deadline
498
                            was missed, to false otherwise. If this
499
                            parameter is set to NULL, no action is
500
                            taken.
501
 
502
   @param [out] was_budget_overran upon return of this function, the
503
                            variable pointed by this function will be
504
                            equal to true if the previous server budget was
505
                            overrun, to false otherwise. If this
506
                            parameter is set to NULL, no action is
507
                            taken.
508
 
509
   @retval 0 if the operation is succesful
510
   @retval  FSF_ERR_INVALID_SYNCH_OBJ_HANDLE if the handle is not valid
511
   @retval  FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or not
512
            running
513
   @retval  FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction of
514
            the FSF main scheduler
515
   @retval  FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread
516
            is not scheduled under the FSF
517
   @retval  FSF_ERR_UNBOUND if the calling thread does not have
518
            a valid server bound to it
519
   @retval  FSF_ERR_BAD_ARGUMENT if the workload of the server is not
520
            FSF_BOUNDED or the synch_handle given is not valid
521
 
522
   @sa fsf_schedule_triggered_job, fsf_schedule_timed_job
523
 
881 trimarchi 524
*/
525
int
526
fsf_schedule_triggered_job
527
  (fsf_synch_obj_handle_t  synch_handle,
528
   struct timespec         *next_budget,
529
   struct timespec         *next_period,
530
   bool                    *was_deadline_missed,
531
   bool                    *was_budget_overran);
532
 
533
 
534
/**
535
   This call is the same as fsf_schedule_triggered_job, but with an
536
   absolute timeout. The timed_out argument, indicates whether the
537
   function returned because of a timeout or not
538
 
983 lipari 539
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
540
       not running
541
   @retval FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction
542
       of the FSF main scheduler
543
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is
544
       not scheduled under the FSF
545
   @retval FSF_ERR_UNBOUND  if the calling thread does not have a valid
881 trimarchi 546
       server bound to it
983 lipari 547
   @retval FSF_ERR_BAD_ARGUMENT   if the workload of the server is not
548
       FSF_BOUNDED, the synch_handle given is not valid or the abs_timeout
549
       argument is NULL or its value is in the past
881 trimarchi 550
 
983 lipari 551
   @see fsf_schedule_triggered_job
881 trimarchi 552
*/
553
int
554
fsf_timed_schedule_triggered_job
555
  (fsf_synch_obj_handle_t  synch_handle,
556
   const struct timespec   *abs_timeout,
557
   bool                    *timed_out,
558
   struct timespec         *next_budget,
559
   struct timespec         *next_period,
560
   bool                    *was_deadline_missed,
561
   bool                    *was_budget_overran);
562
 
563
/*@}*/
564
 
565
///////////////////////////////////////////////////////////////////
566
//                 CONTRACT NEGOCIATION OPERATIONS
567
///////////////////////////////////////////////////////////////////
568
 
569
/**
983 lipari 570
   \ingroup coremodule
881 trimarchi 571
 
983 lipari 572
   \defgroup core_negotiate Negotiate contract functions
573
 
881 trimarchi 574
   The following functions are used to create servers for a contract
575
   parameters specification and also to assign one or more threads to
983 lipari 576
   a server.
881 trimarchi 577
*/
578
/*@{*/
579
 
580
/**
581
    Server Id type, that identifies a server created to manage a given
582
    contract
583
*/
584
typedef int      fsf_server_id_t;             // => 0
585
 
586
/**
587
    The type references a function that may become a thread's
588
    code
589
*/
590
typedef void * (*fsf_thread_code_t) (void *);
591
 
592
/**
593
   The operation negotiates a contract for a new server. If the
594
   on-line admission test is enabled it determines whether the
595
   contract can be admitted or not based on the current contracts
596
   established in the system. Then it creates the server and
597
   recalculates all necessary parameters for the contracts already
983 lipari 598
   present in the system.
881 trimarchi 599
 
983 lipari 600
   This is a potentially blocking operation; it returns when the
601
   system has either rejected the contract, or admitted it and made it
602
   effective. It returns zero and places the server identification
603
   number in the location pointed to by the server input parameter if
604
   accepted, or an error if rejected.  No thread is bound to the newly
605
   created server, which will be idle until a thread is bound to
606
   it. This operation can only be executed by threads that are already
607
   bound to an active server and therefore are being scheduled by the
608
   fsf scheduler.
881 trimarchi 609
 
983 lipari 610
   @param [in] contract pointer to the contract
611
   @param [out] server server id
612
 
613
   @retval 0 if the call is succesful
614
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or not
615
                                            running
616
   @retval FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction of the FSF
617
                                   main scheduler
618
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD  
619
                                   if the calling thread is not scheduled
620
                                   under the FSF
621
   @retval FSF_ERR_BAD_ARGUMENT    if the contract or server arguments
622
                                   are NULL
881 trimarchi 623
*/
624
int
625
fsf_negotiate_contract
626
  (const fsf_contract_parameters_t *contract,
627
   fsf_server_id_t      *server);
628
 
629
/**
630
   This operation negotiates a contract for a new server, creates a
631
   thread and binds it to the server. If the contract is accepted, the
632
   operation creates a thread with the arguments thread, attr,
633
   thread_code and arg as they are defined for the pthread_create()
634
   POSIX function call, and attaches it to the fsf scheduler. Then, it
635
   binds the created thread to the new server. It returns zero and
636
   puts the server identification number in the location pointed to by
983 lipari 637
   the server input parameter.
881 trimarchi 638
 
983 lipari 639
   The attr parameter is overwritten as necessary to introduce the
640
   adequate scheduling attributes, according to the information given
641
   in the contract.
642
 
881 trimarchi 643
   The server is created with the FSF_NONE scheduling policy, which
644
   means no hierarchical scheduling, and only one thread per server,
645
   except for the case of background tasks (see below)
646
 
983 lipari 647
   If the contract is rejected, the thread is not created and the
648
   corresponding error is returned.
649
 
650
   @param [in] contract pointer to the contract
651
   @param [out] server server id
652
   @param [out] thread thread id
653
   @param [in] attr threads attributes
654
   @param [in] thread_code  pointer to the function that implements
655
               the thread
656
   @param [in] arg  arguments for the thread
657
 
658
   @retval  FSF_ERR_BAD_ARGUMENT  if the contract or server arguments are NULL
659
   @retval  FSF_ERR_CONTRACT_REJECTED  if the contract is rejected
881 trimarchi 660
 
983 lipari 661
   @retval  others it may also return all the errors that may be returned
662
            by the pthread_create()POSIX function call
881 trimarchi 663
 
664
*/
665
int
666
fsf_negotiate_contract_for_new_thread
667
  (const fsf_contract_parameters_t *contract,
668
   fsf_server_id_t      *server,
669
   pthread_t            *thread,
670
   pthread_attr_t       *attr,
671
   fsf_thread_code_t     thread_code,
672
   void                 *arg);
673
 
674
/**
675
   This operation negotiates a contract for a new server, and binds
676
   the calling thread to it. If the contract is accepted it returns
677
   zero and copies the server identification number in the location
678
   pointed to by the server input parameter.  If it is rejected, an
679
   error is returned.
680
 
681
   The server is created with the FSF_NONE scheduling policy, which
682
   means no hierarchical scheduling, and only one thread per server,
683
   except for the case of background tasks (see below)
684
 
685
   Implementation dependent issue: In order to allow the usage of
686
   application defined schedulers, the calling thread must not have
687
   the SCHED_APP scheduling policy and at the same time be attached to
688
   an application scheduler different than the fsf scheduler; in such
689
   case, an error is returned. After a successful call the calling
690
   thread will have the SCHED_APP scheduling policy and will be
691
   attached to the fsf scheduler.
692
 
983 lipari 693
   @param [in] contract pointer to the contract
694
   @param [out] server id
695
 
696
   @retval 0 if the contract negotation is succesful
697
   @retval  FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD  if the thread is attached to
881 trimarchi 698
       an application defined scheduler different than the fsf scheduler
983 lipari 699
   @retval FSF_ERR_BAD_ARGUMENT  if the contract or server arguments
700
       are NULL
701
   @retval FSF_ERR_CONTRACT_REJECTED  if the contract is rejected.
881 trimarchi 702
*/
703
int
704
fsf_negotiate_contract_for_myself
705
  (const fsf_contract_parameters_t *contract,
706
   fsf_server_id_t      *server);
707
 
708
 
709
/**
983 lipari 710
   This operation associates a thread with a server, which means that
711
   it starts consuming the server's budget and is executed according
712
   to the contract established for that server. If the thread is
713
   already bound to another server, and error is returned.
881 trimarchi 714
 
715
   It fails if the server's policy is different than FSF_NONE, or if
716
   there is already a thread bound to this server
717
 
718
   Implementation dependent issue: In order to allow the usage of
719
   application defined schedulers, the given thread must not have the
720
   scheduling policy SCHED_APP and at the same time be attached to an
721
   application scheduler different than the fsf scheduler.
722
 
983 lipari 723
   @param [in] server id
724
   @param [in] thread id
725
 
726
   @retval FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction
727
       of the FSF main scheduler
728
   @retval FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD if the thread is attached to
881 trimarchi 729
       an application defined scheduler different than the fsf scheduler
983 lipari 730
   @retval FSF_ERR_BAD_ARGUMENT if the server value does not complain with the
881 trimarchi 731
       expected format or valid range or the given thread does not exist
983 lipari 732
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the referenced server
733
       is not valid
734
   @retval FSF_ERR_ALREADY_BOUND if the thread is already bound to
735
       another server.
881 trimarchi 736
 
737
*/
738
int
739
fsf_bind_thread_to_server
740
  (fsf_server_id_t server,
741
   pthread_t       thread);
742
 
743
 
744
/**
745
   This operation unbinds a thread from a server.  Since threads with
746
   no server associated are not allow to execute, they remain in a
747
   dormant state until they are either eliminated or bound again.
748
 
749
   If the thread is inside a critical section the effects of this call
750
   are deferred until the critical section is ended
751
 
752
   Implementation dependent issue: in the implementation with an
753
   application scheduler, the thread is still attached to the fsf
754
   scheduler, but suspended.
755
 
983 lipari 756
   @param [in] thread thread id
757
 
758
   @retval 0 if the operation is succesful
759
   @retval FSF_ERR_INTERNAL_ERROR  erroneous binding or malfunction of the FSF
881 trimarchi 760
       main scheduler
983 lipari 761
   @retval FSF_ERR_BAD_ARGUMENT  if the given thread does not exist
762
   @retval FSF_ERR_NOT_SCHEDULED_THREAD  if the given thread is not scheduled
881 trimarchi 763
       under the FSF
983 lipari 764
   @retval FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD if the thread is attached to
881 trimarchi 765
       an application defined scheduler different than the fsf scheduler
983 lipari 766
   @retval FSF_ERR_NOT_BOUND if the given thread does not have a valid
881 trimarchi 767
       server bound to it
768
*/
769
int
770
fsf_unbind_thread_from_server (pthread_t thread);
771
 
772
/**
773
   This operation stores the Id of the server associated with the
774
   specified thread in the variable pointed to by server. It returns
775
   an error if the thread does not exist, it is not under the control
776
   of the scheduling framework, or is not bound.
777
 
983 lipari 778
   @param [in] thread thread id
779
   @param [out] server server
780
 
781
   @retval 0 if the operation is succesful
782
   @return FSF_ERR_NOT_SCHEDULED_THREAD if the given thread is not scheduled
881 trimarchi 783
       under the FSF
983 lipari 784
   @return FSF_ERR_UNBOUND if the given thread does not have a valid
881 trimarchi 785
       server bound to it
983 lipari 786
   @return FSF_ERR_BAD_ARGUMENT if the given thread does not exist or the
881 trimarchi 787
       server argument is NULL
788
*/
789
int
790
fsf_get_server
791
  (pthread_t       thread,
792
   fsf_server_id_t *server);
793
 
794
/**
795
   This operation stores the contract parameters currently associated
796
   with the specified server in the variable pointed to by
797
   contract. It returns an error if the server id is incorrect.
798
 
983 lipari 799
   @param [in] server server id
800
   @param [out] contract pointer to the contract structure
801
 
802
   @retval 0 if the operation is succesful
803
   @retval FSF_ERR_BAD_ARGUMENT  if the contract argument is
804
         NULL or the value of the server argument is not in range
805
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 806
       scheduled under the FSF
983 lipari 807
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or
808
       not running
809
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 810
       has been cancelled or it is not valid
811
*/
812
int
813
fsf_get_contract
814
   (fsf_server_id_t server,
815
    fsf_contract_parameters_t *contract);
816
 
817
/**
818
   The operation eliminates the specified server
819
   and recalculates all necessary parameters for the contracts
820
   remaining in the system. This is a potentially blocking operation;
821
   it returns when the system has made the changes effective.
822
 
983 lipari 823
   @param [in] server server id
881 trimarchi 824
 
983 lipari 825
   @retval 0 if the operation is succesful
826
   @retval FSF_ERR_BAD_ARGUMENT   if the value of server is not in range
827
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD  if the calling thread is not
828
           scheduled under the FSF
829
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY  the scheduler is wrong or not
830
           running
831
   @retval FSF_ERR_NOT_CONTRACTED_SERVER  if the server of the calling thread
832
           has been cancelled or it is not valid
881 trimarchi 833
*/
834
int
835
fsf_cancel_contract (fsf_server_id_t server);
836
 
837
 
838
/**
839
   The operation renegotiates a contract for an existing server. If
840
   the on-line admission test is enabled it determines whether the
841
   contract can be admitted or not based on the current contracts
842
   established in the system. If it cannot be admitted, the old
843
   contract remains in effect and an error is returned. If it can be
844
   admitted, it recalculates all necessary parameters for the
845
   contracts already present in the system anr returns zero. This is a
846
   potentially blocking operation; it returns when the system has
847
   either rejected the new contract, or admitted it and made it
848
   effective.
849
 
983 lipari 850
   @param [in]  new_contract a pointer to the new contract
851
   @param [in]  server server id
852
 
853
   @retval 0 if the operation is succesful
854
   @retval FSF_ERR_BAD_ARGUMENT  if the new_contract argument is NULL or the  
881 trimarchi 855
       value of the server argument is not in range
983 lipari 856
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 857
       scheduled under the FSF
983 lipari 858
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or not
859
       running
860
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 861
       has been cancelled or it is not valid
862
*/
863
int
864
fsf_renegotiate_contract
865
  (const fsf_contract_parameters_t *new_contract,
866
   fsf_server_id_t server);
867
 
868
/**
869
   The operation enqueues a renegotiate operation for an existing
870
   server, and returns immediately. The renegotiate operation is
983 lipari 871
   performed asynchronously and the calling thread may continue
872
   executing normally. Of course, wheter the operation is performed
873
   immediately or not depends on the relative priority of the service
874
   thread and the calling thread, on the scheduler used, etc.
881 trimarchi 875
 
983 lipari 876
   When the renegotiation is completed, if the on-line admission test
877
   is enabled it determines whether the contract can be admitted or
878
   not based on the current contracts established in the system. If it
879
   cannot be admitted, the old contract remains in effect. If it can
880
   be admitted, it recalculates all necessary parameters for the
881
   contracts already present in the system. When the operation is
882
   completed, notification is made to the caller, if requested, via a
883
   signal. The status of the operation (in progress, admitted,
884
   rejected) can be checked with the get_renegotiation_status
885
   operation.  The argument sig_notify can be NULL_SIGNAL (no
886
   notification), or any POSIX signal; and in this case sig_value is
887
   to be sent with the signal.
888
 
889
   @param [in] new_contract pointer to the new contract to be negotiated
890
   @param [in] server  server id
891
   @param [in] sig_notify NULL (no signal) or any POSIX signal
892
   @param [in] sig_value a sigval structure that contains values to be
893
               passed to the signal handler. Valid only if sig_notify
894
               is different from NULL.
895
 
896
   @retval 0 if the call is succesful
897
   @retval FSF_ERR_BAD_ARGUMENT  if the new_contract argument is NULL, the  
881 trimarchi 898
       value of the server argument is not in range or sig_notify is
899
       neither NULL nor a valid POSIX signal
983 lipari 900
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 901
       scheduled under the FSF
983 lipari 902
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or not
903
       running
904
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 905
       has been cancelled or it is not valid
906
 
907
*/
908
int
909
fsf_request_contract_renegotiation
910
  (const fsf_contract_parameters_t *new_contract,
911
   fsf_server_id_t                  server,
912
   int                              sig_notify,
913
   union sigval                     sig_value);
914
 
983 lipari 915
/**
916
   Possible values returned by fsf_get_renegotiation_status
917
*/
918
typedef enum {FSF_IN_PROGRESS,
919
              FSF_REJECTED,
920
              FSF_ADMITTED}
921
    fsf_renegotiation_status_t;
881 trimarchi 922
 
923
/**
924
   The operation reports on the status of the last renegotiation
925
   operation enqueued for the specified server. It is callable even
926
   after notification of the completion of such operation, if
983 lipari 927
   requested.
881 trimarchi 928
 
983 lipari 929
   @param [in] server server id
930
   @param [out] renegotiation_status the status of the renegotiation;
931
 
932
   @retval 0 if succesful completion;
933
   @retval FSF_ERR_BAD_ARGUMENT  if the renegotiation_status argument is
881 trimarchi 934
       NULL or the value of the server argument is not in range
983 lipari 935
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 936
       scheduled under the FSF
983 lipari 937
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or not
938
       running
939
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 940
       has been cancelled or it is not valid
941
*/
942
int
943
fsf_get_renegotiation_status
944
  (fsf_server_id_t server,
945
   fsf_renegotiation_status_t *renegotiation_status);
946
 
983 lipari 947
 
948
//Data types
949
 
950
/// List of contracts to negotiate
951
typedef struct {
952
  int  size;
953
  fsf_contract_parameters_t*  contracts[FSF_MAX_N_SERVERS];
954
} fsf_contracts_group_t;
955
 
956
/// List of servers to cancel
957
typedef  struct {
958
  int             size;
959
  fsf_server_id_t servers[FSF_MAX_N_SERVERS];
960
} fsf_servers_group_t;
961
 
962
 
963
/**
964
   This operation analizes the schedulability of the context that
965
   results from negitiating the contracts specified in the
966
   contracts_up list and cacelling the contracts referenced by the
967
   servers_down list. If the overall negotiation is successful, a new
968
   server will be created for each of the elements of the contracts_up
969
   group, the servers in servers_down will be cancelled, the list of
970
   new server ids will be returned in the variable pointed to by
971
   servers_up, and the variable pointed to by accepted will be made
972
   true. Otherwise, this variable will be made false, and no other
973
   effect will take place. The function returns the corresponding
974
   error code if any of the contracts is not correct or any of the
975
   server is is not valid.
976
 
977
   @param [in] contracts_up list of contracts to negotiate
978
   @param [in] servers_down list of contracts to be canceled
979
   @param [out] servers_up list of server ids that have been created, they are
980
      given in the same order as the contract_up list of contracts;
981
   @param [out] accepted if the operation is succesful;
982
 
983
   @retval 0 if succesful completion;
984
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
985
           not running
986
   @retval FSF_ERR_INTERNAL_ERROR erroneous binding or malfunction of the FSF
987
       main scheduler
988
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is
989
           not scheduled under the FSF
990
   @retval FSF_ERR_BAD_ARGUMENT if any of the servers_up or accepted arguments
991
       is NULL, if the contracts_up and servers_down arguments are both NULL,
992
       or any of them has erroneous size or its elements are NULL or not in the
993
       valid range respectively
994
*/
995
int
996
fsf_negotiate_group
997
   (const fsf_contracts_group_t *contracts_up,
998
    const fsf_servers_group_t   *servers_down,
999
    fsf_servers_group_t         *servers_up,
1000
    bool                        *accepted);
1001
 
1002
 
881 trimarchi 1003
/*@}*/
1004
 
1005
 
1006
////////////////////////////////////////////////////
1007
//           OBTAINING INFORMATION FROM THE SCHEDULER
1008
////////////////////////////////////////////////////
1009
 
1010
 
1011
/**
983 lipari 1012
   \ingroup coremodule
1013
 
1014
   \defgroup core_sched_info Obtaining information from the scheduler.
1015
 
1016
   This group of function is used to get informations from the
1017
   scheduler, like execution time of a task, remaining budget of a
1018
   server, etc.
1019
 
1020
   @{
1021
 */
1022
 
1023
/**
1024
   Returns true if the system is configured with the on-line admission
1025
   test enabled, or false otherwise.
881 trimarchi 1026
*/
1027
bool
1028
fsf_is_admission_test_enabled();
1029
 
1030
/**
1031
   This function stores the current execution time spent by the
1032
   threads bound to the specified server in the variable pointed to by
1033
   cpu_time.
1034
 
983 lipari 1035
   @param [in] server server id
1036
   @param [out] cpu_time pointer to a timespec structure that will contain
1037
         the cpu time consumed by the threads that are bound to the
1038
         specific server, since its creation.
1039
 
1040
   @retval 0 if succesful completion
1041
   @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument is
1042
       not in range or cpu_time is NULL
1043
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 1044
       scheduled under the FSF
983 lipari 1045
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
1046
       not running
1047
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 1048
       has been cancelled or it is not valid
1049
*/
1050
int
1051
fsf_get_cpu_time
1052
   (fsf_server_id_t server,
1053
    struct timespec *cpu_time);
1054
 
1055
/**
1056
   This function stores in the variable pointed to by budget the
1057
   remaining execution-time budget associated with the specified
983 lipari 1058
   server.
881 trimarchi 1059
 
983 lipari 1060
   @param [in] server server id
1061
   @param [out] budget pointer to a timespec structure that will
1062
     contain the remaining budget
1063
 
1064
   @retval 0 if succesful completion
1065
   @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument is
1066
       not in range or budget is NULL
1067
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 1068
       scheduled under the FSF
983 lipari 1069
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
1070
       not running
1071
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 1072
       has been cancelled or it is not valid
1073
*/
1074
int
1075
fsf_get_remaining_budget
1076
   (fsf_server_id_t server,
1077
    struct timespec *budget);
1078
 
1079
 
1080
/**
983 lipari 1081
   This function stores in the variables pointed to by budget and
1082
   period, the execution-time budget and the period respectively
1083
   associated with the specified server. If any of these pointers is
1084
   NULL, the corresponding information is not stored.
881 trimarchi 1085
 
983 lipari 1086
   @param [in] server server id
1087
   @param [out] budget budget available for the current server instance
1088
   @param [out] period period available for the current server instance
1089
 
1090
   @retval 0 if succesful completion
1091
   @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument is
1092
       not in range, budget is NULL or period is NULL
1093
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 1094
       scheduled under the FSF
983 lipari 1095
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or not
1096
     running
1097
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 1098
       has been cancelled or it is not valid
1099
*/
1100
int
1101
fsf_get_budget_and_period
1102
   (fsf_server_id_t server,
1103
    struct timespec *budget,
1104
    struct timespec *period);
1105
 
983 lipari 1106
/* @} */
881 trimarchi 1107
 
1108
/////////////////////////////////////////////////////////////////////
1109
//           SERVICE THREAD TUNING
1110
/////////////////////////////////////////////////////////////////////
1111
 
1112
/**
983 lipari 1113
   \ingroup coremodule
1114
 
1115
   \defgroup core_service_thread Service Thread
1116
 
1117
   These functions are to the initialization and tuning of the service
1118
   thread.
1119
 
1120
   Implementation dependency: in the fixed priority implementation of
1121
   fsf, the default priority is lower than the priority of any server,
1122
   but higher than the background. According to the
1123
   implementation-dependent module the priority is adjustable by means
1124
   of a function that changes its preemption level.
1125
 
1126
   @{
1127
 */
1128
 
1129
 
1130
/**
1131
   This function allows the application to change the period and
1132
   budget of the service thread that makes the
881 trimarchi 1133
   negotiations. Increasing the utilization of this thread makes the
1134
   negotiations faster, but introduces additional load in the system
1135
   that may decrease the bandwidth available for the servers. For this
983 lipari 1136
   call, the system will make a schedulability analysis to determine
1137
   if the new situation is acceptable or not. This is reported back in
1138
   the variable pointed to by accepted. If the new service thread data
1139
   is accepted, the system will reassign budgets and periods to the
1140
   servers according to the new bandwidth available, in the same way
1141
   as it does for a regular contract negotiation.
881 trimarchi 1142
 
1143
   When its budget is exhausted, the service thread may run in the
983 lipari 1144
   background.
881 trimarchi 1145
 
1146
   The service thread starts with a default budget and period that are
983 lipari 1147
   configurable.
881 trimarchi 1148
 
983 lipari 1149
   @param [in] budget budget for the service thread
1150
   @param [in] period for the service thread
1151
   @param [out] accepted true is the change has been accepted
881 trimarchi 1152
 
983 lipari 1153
 
1154
   @retval 0 is the operation is succesful
1155
   @retval FSF_ERR_BAD_ARGUMENT if any of the pointer arguments is NULL or
881 trimarchi 1156
       the budget value is greater than the period value
983 lipari 1157
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 1158
       scheduled under the FSF
983 lipari 1159
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or
1160
       not running
1161
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 1162
       has been cancelled or it is not valid
1163
*/
1164
int
1165
fsf_set_service_thread_data
1166
   (const struct timespec *budget,
1167
    const struct timespec *period,
1168
    bool                  *accepted);
1169
 
1170
/**
1171
   this function returns in the variables pointed by budget and
1172
   period, respectively, the current budget and period of the service
1173
   thread.
983 lipari 1174
 
1175
   @param [out] budget   current budget of the service thread
1176
   @param [out] period   current period of the service thread
881 trimarchi 1177
 
983 lipari 1178
   @retval FSF_ERR_BAD_ARGUMENT if any of the pointer arguments is NULL
1179
   @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
881 trimarchi 1180
       scheduled under the FSF
983 lipari 1181
   @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong
1182
       or not running
1183
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling thread
881 trimarchi 1184
       has been cancelled or it is not valid
1185
*/
1186
int
1187
fsf_get_service_thread_data
1188
   (struct timespec *budget,
1189
    struct timespec *period);
1190
 
983 lipari 1191
/* @} */
881 trimarchi 1192
 
1193
#endif // _FSF_CORE_H_