Subversion Repositories shark

Rev

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