Subversion Repositories shark

Rev

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

Rev Author Line No. Line
881 trimarchi 1
//fsf_basic_types.h
2
//=======================================================================
3
//       FFFFFFIII   RRRRR      SSTTTTTTT
4
//      FF         IIR   RR    SS
5
//     FF           IR        SS
6
//    FFFFFF         RRRR    SSSSST
7
//   FF       FI       RRR  SS
8
//  FF         II     RRR  SS
9
// FF           IIIIIR    RS
10
//
11
// Basic FSF(FIRST Scheduling Framework) common types
12
//=======================================================================
13
// 
14
 
993 lipari 15
/**
16
   \file fsf_basic_types.h
17
 */
18
 
881 trimarchi 19
#include <time.h>
20
#include "fsf_opaque_types.h"
21
#include "fsf_configuration_parameters.h"
22
 
23
#ifndef _FSF_BASIC_TYPES_H_
24
#define _FSF_BASIC_TYPES_H_
25
 
26
 
27
// Definition of types and constants used in fsf modules
28
 
29
 
30
//
31
// Types for the core module
32
//
33
 
993 lipari 34
/**
35
   This data type is used for defining the workload parameter in the
36
   contract specification functions.
37
 
38
   It can have the following values:
39
 
40
   - FSF_BOUNDED:  The workload generated by the task(s) in the server is bounded
41
 
42
   - FSF_INDETERMINATE: The workload generated by the task(s) in the server is indeterminate
43
 
44
   - FSF_OVERHEAD: The workload generated by the task(s) in the server is TBD
45
 
46
 */
881 trimarchi 47
typedef enum {FSF_BOUNDED, FSF_INDETERMINATE, FSF_OVERHEAD} fsf_workload_t;                          
48
 
993 lipari 49
/// Default value for the workload parameter
50
#define FSF_DEFAULT_WORKLOAD       FSF_INDETERMINATE
889 trimarchi 51
 
993 lipari 52
/// Default value for the parameter d_equal_t in the contract initialization
881 trimarchi 53
#define FSF_DEFAULT_D_EQUALS_T     false
993 lipari 54
 
55
// Default value for the server relative deadline
881 trimarchi 56
#define FSF_DEFAULT_DEADLINE       {0,0} //struct timespec
57
 
889 trimarchi 58
// Constants for omitting the assignment of values
59
// to specific arguments in calls to
60
// initialization functions
61
 
993 lipari 62
/// A null deadline
881 trimarchi 63
#define FSF_NULL_DEADLINE     (struct timespec *)NULL
993 lipari 64
 
65
/// A null signal
881 trimarchi 66
#define FSF_NULL_SIGNAL       0
67
 
971 trimarchi 68
/**
993 lipari 69
   This data type is used to express the list of possible values
70
   returned by fsf_get_renegotiation_status. It can assume the
71
   following values:
72
 
73
 
971 trimarchi 74
*/
75
typedef enum {FSF_IN_PROGRESS,
76
              FSF_REJECTED,
77
              FSF_ADMITTED,
78
              FSF_NOT_REQUESTED}
79
    fsf_renegotiation_status_t;
889 trimarchi 80
 
971 trimarchi 81
 
985 julio 82
/**
83
    Contract parameters type; it is an opaque type (i.e. the internal
84
    structure of this data type is implementation dependent). The user
85
    can access and modify the parameters of a contract only with the
86
    proper functions, and should never access the data directly.
87
*/
88
typedef FSF_CONTRACT_PARAMETERS_T_OPAQUE fsf_contract_parameters_t;
89
 
90
 
91
/**
92
    Synchronization object handle type, this an opaque type
93
    used to signaling of servers
94
*/
95
typedef FSF_SYNCH_OBJ_HANDLE_T_OPAQUE fsf_synch_obj_handle_t;
96
 
97
 
98
 
99
/**
100
    Server Id type, that identifies a server created to manage a given
101
    contract
102
*/
103
typedef int      fsf_server_id_t;             // => 0
104
 
105
/**
106
    The type references a function that may become a thread's
107
    code
108
*/
109
typedef void * (*fsf_thread_code_t) (void *);
110
 
111
 
112
/// List of contracts to negotiate
113
typedef struct {
114
  int  size;
115
  fsf_contract_parameters_t*  contracts[FSF_MAX_N_SERVERS];
116
} fsf_contracts_group_t;
117
 
118
/// List of servers to cancel
119
typedef  struct {
120
  int             size;
121
  fsf_server_id_t servers[FSF_MAX_N_SERVERS];
122
} fsf_servers_group_t;
123
 
124
 
125
 
126
 
881 trimarchi 127
//
128
// Types for the spare capacity module
129
//
130
 
993 lipari 131
/**
132
   Granularity of spare capacity requirements.  This data type is used
133
   in the spare capacity module to specify the kind of granularity in
134
   spare capacity allocation when creating a new contract.
135
 
136
   A variable of this type can assume the following values:
137
 
138
   - FSF_CONTINUOUS the utilization assigned to the server by the
139
     spare capacity module can assume any value between the minimum
140
     (Cmin / Tmax) and the maximum (Cmax/Tmin).
141
 
142
   - FSF_DISCRETE the utilization assigned to the server can assume
143
     only values in a discrete set of pairs (C,T) (to be specified
144
     with a variable of type fsf_utilization_set_t)
145
 
146
*/
881 trimarchi 147
typedef enum {FSF_CONTINUOUS, FSF_DISCRETE} fsf_granularity_t;
148
 
993 lipari 149
/**
150
   This data type is used in the spare capacity module to specify
151
   pairs of (budget,period) that can be assigned by the spare capacity
152
   distribution algorithm to the server.
153
   respectively.
154
*/
881 trimarchi 155
typedef struct {
993 lipari 156
  /// server capacity
157
  struct timespec    budget;
158
  /// server period
159
  struct timespec    period;
881 trimarchi 160
} fsf_utilization_value_t;
161
 
993 lipari 162
 
163
/**
164
   This data type is used in the spare capacity module to specify a
165
   set of possible pairs (C,T) that can be assigned to the server.
166
 */
881 trimarchi 167
typedef struct {
993 lipari 168
  /// lenght of the array
881 trimarchi 169
  int                         size; // = 0
993 lipari 170
  /// array of pairs (C,T)
881 trimarchi 171
  fsf_utilization_value_t    
172
      value[FSF_MAX_N_UTILIZATION_VALUES];
173
} fsf_utilization_set_t;
174
 
993 lipari 175
 
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
971 trimarchi 266
typedef enum {FSF_FP, FSF_EDF, FSF_TABLE_DRIVEN, FSF_RR, 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
 
326
 
901 trimarchi 327
//
328
// Types for the distributed services module
329
//
881 trimarchi 330
 
901 trimarchi 331
// Type designating the network ids. They need not
332
// be sequential numbers.
333
typedef unsigned int       fsf_network_id_t;
881 trimarchi 334
 
901 trimarchi 335
#define FSF_DEFAULT_NETWORK_ID          1
336
#define FSF_NULL_NETWORK_ID             0
337
 
985 julio 338
//opaque types for fsf endpoints
339
typedef FSF_SEND_ENDPOINT_T_OPAQUE   fsf_send_endpoint_t;
340
typedef FSF_RECEIVE_ENDPOINT_T_OPAQUE fsf_receive_endpoint_t;
901 trimarchi 341
 
985 julio 342
/**
343
   \ingroup distjmodule
344
 
345
   The node_address type specifies the node address in a
346
   communication-protocol-independent way. The actual address is
347
   obtained via a configuration dependent mapping function
348
*/
349
typedef unsigned int  fsf_node_address_t;
350
 
351
/**
352
   \ingroup distjmodule
353
 
354
   The port type specifies the information that is necessary to get in
355
   contact with the thread in the receiving node, in a
356
   protocol-independent way.  The actual port number is obtained via a
357
   configuration dependent mapping function
358
*/
359
typedef unsigned int  fsf_port_t;
360
 
361
 
362
 
363
 
889 trimarchi 364
// Error codes
971 trimarchi 365
#define FSF_ERR_BASE_VALUE                      0x02004000
889 trimarchi 366
 
971 trimarchi 367
#define FSF_ERR_TOO_MANY_TASKS                  0x02004001
368
#define FSF_ERR_BAD_ARGUMENT                    0x02004002
369
#define FSF_ERR_INVALID_SYNCH_OBJ_HANDLE        0x02004003
370
#define FSF_ERR_NO_RENEGOTIATION_REQUESTED      0x02004004
371
#define FSF_ERR_CONTRACT_REJECTED               0x02004005
372
#define FSF_ERR_NOT_SCHEDULED_CALLING_THREAD    0x02004006
985 julio 373
#define FSF_ERR_NOT_BOUND                       0x02004007
971 trimarchi 374
#define FSF_ERR_UNKNOWN_SCHEDULED_THREAD        0x02004008
375
#define FSF_ERR_NOT_CONTRACTED_SERVER           0x02004009
376
#define FSF_ERR_NOT_SCHEDULED_THREAD            0x0200400A
377
#define FSF_ERR_TOO_MANY_SERVICE_JOBS           0x0200400B
378
#define FSF_ERR_TOO_MANY_SYNCH_OBJS             0x0200400C
379
#define FSF_ERR_TOO_MANY_SERVERS_IN_SYNCH_OBJ   0x0200400D
380
#define FSF_ERR_TOO_MANY_EVENTS_IN_SYNCH_OBJ    0x0200400E
381
#define FSF_ERR_INTERNAL_ERROR                  0x0200400F
382
#define FSF_ERR_TOO_MANY_SERVERS                0x02004010
383
#define FSF_ERR_INVALID_SCHEDULER_REPLY         0x02004011
384
#define FSF_ERR_TOO_MANY_PENDING_REPLENISHMENTS 0x02004012
385
#define FSF_ERR_SYSTEM_ALREADY_INITIALIZED      0x02004013
386
#define FSF_ERR_SHARED_OBJ_ALREADY_INITIALIZED  0x02004014
387
#define FSF_ERR_SHARED_OBJ_NOT_INITIALIZED      0x02004015
388
#define FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE     0x02004016
389
#define FSF_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE  0x02004017
390
#define FSF_ERR_ALREADY_BOUND                   0x02004018
391
#define FSF_ERR_WRONG_NETWORK                   0x02004019
392
#define FSF_ERR_TOO_LARGE                       0x0200401A
393
#define FSF_ERR_BUFFER_FULL                     0x0200401B
394
#define FSF_ERR_NO_SPACE                        0x0200401C
395
#define FSF_ERR_NO_MESSAGES                     0x0200401D
396
#define FSF_WRN_MODULE_NOT_SUPPORTED            0x0200401E
397
#define FSF_ERR_SYSTEM_NOT_INITIALIZED          0x0200401F
398
#define FSF_ERR_TOO_MANY_SHARED_OBJS            0x02004020
889 trimarchi 399
 
971 trimarchi 400
#define FSF_ERR_LAST_VALUE                      0x02004020
401
 
889 trimarchi 402
 
901 trimarchi 403
 
881 trimarchi 404
#endif // _FSF_BASIC_TYPES_H_