Subversion Repositories shark

Rev

Rev 1039 | Details | Compare with Previous | Last modification | View Log | RSS feed

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