Subversion Repositories shark

Rev

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

Rev Author Line No. Line
881 trimarchi 1
//fsf_hierarchical.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
// FSF(FIRST Scheduling Framework) 
12
// hierarchical scheduling management
13
//===================================================================
14
 
15
#include <time.h>
16
#include "fsf_basic_types.h"
17
#include "fsf_core.h"
18
 
19
#ifndef _FSF_HIERARCHICAL_H_
20
#define _FSF_HIERARCHICAL_H_
21
 
22
#define FSF_HIERARCHICAL_MODULE_SUPPORTED       1
23
 
24
//// The definition of this types is in fsf_basic_types.h
25
//
26
//// Scheduling policies
27
//typedef enum {FSF_FP, FSF_EDF, FSF_TABLE_DRIVEN, FSF_NONE} 
28
//    fsf_sched_policy_t;
29
//
30
//// Scheduling policy and parameters
31
//typedef struct {
32
//  fsf_sched_policy_t    policy;
33
//  void *                params;
34
//} fsf_sched_params_t;
35
//// The params member is a pointer to one of the 
36
//// following:
37
////    FP:  int (priority)
38
////    EDF: struct timespec (deadline)
39
////    TABLE_DRIVEN : struct fsf_table_driven_params_t
40
//
41
//
42
////Scheduling parameters for the table-driven policy (t.b.d)
43
//typedef struct {
44
//  // list of target windows (t.b.d.) 
45
//  // deadline (for the API): end of september
46
//} fsf_table_driven_params_t;
47
//
48
//
49
////Initialization information for a scheduling policy
50
//typedef void * fsf_sched_init_info_t;
51
//// It shall be one of the following:
52
////    FP:  none
53
////    EDF: none
54
////    TABLE_DRIVEN : struct timespec (schedule duration)
55
//
56
 
928 trimarchi 57
 
58
/**
59
   \ingroup hiermodule  
60
 
61
   This call has the following effects:
62
    - FP:  none
63
    - EDF: none
64
    - TABLE_DRIVEN :
65
       Records the schedule duration, and starts the
66
       schedule at the time of the call. After the
67
       schedule duration has elapsed, the schedule in
68
       the table is repeated.
69
 
70
     @param [in] server server id
71
     @param [in] info TBD
72
 
73
     @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument
74
            is not in range or info is NULL
75
     @retval FSF_ERR_NOT_SCHEDULED_CALLING_THREAD if the calling thread is not
76
            scheduled under the FSF
77
     @retval FSF_ERR_INVALID_SCHEDULER_REPLY the scheduler is wrong or not
78
             running
79
     @retval FSF_ERR_NOT_CONTRACTED_SERVER if the server of the calling
80
             thread has been cancelled or it is not valid
881 trimarchi 81
*/
82
int fsf_init_local_scheduler(
83
   fsf_server_id_t       server,
84
   fsf_sched_init_info_t info);
85
 
86
 
87
/////////////////////////////////////////////////
88
//                       CONTRACT PARAMETERS
89
////////////////////////////////////////////////
90
 
928 trimarchi 91
/**
92
   \ingroup hiermodule
93
 
94
   The operation updates the specified contract parameters object by
95
   setting its scheduling policy to the specified input parameter.
96
   The default policy is FSF_NONE, which means that only one thread
97
   may be bound to the server
98
 
99
   @param [in] contract pointer to the contract
100
   @param [in] sched_policy local scheduling policy for this server.
101
     Can be FSF_FP, FSF_EDF, FSF_TABLE_DRIVEN, FSF_NONE.
102
 
103
   @retval 0 if the operation is succesful
104
   @retval FSF_ERR_BAD_ARGUMENT if sched_policy is not one of the supported
105
       ones, or contract is NULL
106
 
889 trimarchi 107
*/
881 trimarchi 108
int
109
fsf_set_contract_scheduling_policy
110
  (fsf_contract_parameters_t *contract,
111
   fsf_sched_policy_t         sched_policy);
112
 
113
 
928 trimarchi 114
/**
115
   \ingroup hiermodule
116
 
117
   This operation obtains from the specified contract parameters
118
   object its scheduling policy, and copies it to the place pointed to
119
   by the corresponding input parameter.
120
 
121
   @param [in] contract pointer to the contract
122
   @param [out] sched_policy pointer to a variable that will contain
123
                the scheduling policy
124
 
125
   @retval 0 if the operation is succesful
126
   @retval FSF_ERR_BAD_ARGUMENT if sched_policy or contract are NULL
127
 
889 trimarchi 128
*/
881 trimarchi 129
int
130
fsf_get_contract_scheduling_policy
131
  (const fsf_contract_parameters_t *contract,
132
   fsf_sched_policy_t              *sched_policy);
133
 
134
 
928 trimarchi 135
/**
136
   \ingroup hiermodule
137
 
138
   This operation creates a thread and binds it to the specified
139
   server, which must have a policy different than FSF_NONE. The new
140
   thread is created with the arguments thread, attr, thread_code and
141
   arg as they are defined for the pthread_create() POSIX function
142
   call, and its local scheduling parameters are set to the value
143
   stored in the variable pointed to by sched_params, which must be
144
   compatible with the server's scheduling policy. Then, the function
145
   binds the created thread to the new server. The attr parameter is
146
   overwritten as necessary to introduce the adequate scheduling
147
   policy and priority, according to the preemption level given in the
148
   contract and the fsf_priority_map() function defined by the user.
149
 
150
   @param [in] server server id
151
   @param [in] sched_params scheduling parameters for the thread
152
   @param [out] thread the thread id after creation
153
   @param [in] attr attributes for the task (see pthread_create())
154
   @param [in] thread_code pointer to a function that implements the
155
       thread code
156
   @param [in] arg arguments for the thread
157
 
158
   @retval 0 if the operation is succesful
159
   @retval FSF_ERR_BAD_ARGUMENT if the value of the server argument
160
           is not in range, or sched_params is NULL
161
   @retval FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE if the scheduling policy
881 trimarchi 162
       in sched_params is not compatible to the server's one.
928 trimarchi 163
   @retval FSF_ERR_INTERNAL_ERROR erroneous binding or malfunction of the FSF
881 trimarchi 164
       main scheduler
928 trimarchi 165
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the referenced server is not valid
881 trimarchi 166
 
928 trimarchi 167
   @retval others It may also return any of  the errors that may be
168
       returned by the pthread_create()POSIX function call
881 trimarchi 169
*/
170
 
171
int
172
fsf_create_local_thread
173
  (fsf_server_id_t        server,
174
   fsf_sched_params_t    *sched_params,
175
   pthread_t             *thread,
176
   pthread_attr_t        *attr,
177
   fsf_thread_code_t      thread_code,
178
   void                  *arg);
179
 
928 trimarchi 180
/**
181
   \ingroup hiermodule
182
 
183
   This operation associates a thread with a server, which must have a
184
   policy different than FSF_NONE. The thread's local scheduling
185
   parameters are set to the value stored in the variable pointed to
186
   by sched_params, which must be compatible with the server's
187
   scheduling policy. After the call the thread starts consuming the
188
   server's budget and is executed according to the contract
189
   established for that server and to its scheduling policy. If the
190
   thread was already bound to another server, it is effectively
191
   unbound from it and bound to the specified one.
881 trimarchi 192
 
928 trimarchi 193
   Implementation dependent issue: In order to allow the usage of
194
   application defined schedulers, the given thread must not have the
195
   scheduling policy SCHED_APP and at the same time be attached to an
196
   application scheduler different than the fsf scheduler.
881 trimarchi 197
 
928 trimarchi 198
   @param [in] server server id
199
   @param [in] thread thread id
200
   @param [in] sched_params scheduling parameters for the thread
201
 
202
   @retval 0 if the operation is succesful
203
   @retval FSF_ERR_BAD_ARGUMENT if the server argument does not complain with
881 trimarchi 204
       the expected format or valid range, the given thread does not exist,
205
       or sched_params is NULL
928 trimarchi 206
   @retval FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE if the scheduling policy
881 trimarchi 207
       in sched_params is not compatible to the server's one.
928 trimarchi 208
   @retval FSF_ERR_INTERNAL_ERROR erroneous binding or malfunction of the FSF
881 trimarchi 209
       main scheduler
928 trimarchi 210
   @retval FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD if the thread is attached to
881 trimarchi 211
       an application defined scheduler different than the fsf scheduler
928 trimarchi 212
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the referenced server is not valid
985 julio 213
   @retval FSF_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
214
       of the server is FSF_OVERHEAD
881 trimarchi 215
*/
216
int  
217
fsf_bind_local_thread_to_server
218
  (fsf_server_id_t      server,
219
   pthread_t            thread,
220
   fsf_sched_params_t  *sched_params);
221
 
222
 
928 trimarchi 223
/**
224
   \ingroup hiermodule
225
 
226
   This function changes the local scheduling parameters of the thread
227
   to the value pointed to by sched_params. This value must be
228
   compatible with the scheduling policy of the server to which the
229
   thread is bound.
230
 
231
   @param [in] thread thread id
232
   @param [in] sched_params scheduling parameters
233
 
234
   @retval 0 if the operation is succesful
235
   @retval FSF_ERR_BAD_ARGUMENT if the given thread does not exist,
881 trimarchi 236
       or sched_params is NULL
928 trimarchi 237
   @retval FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE if the thread is already bound
881 trimarchi 238
       and the scheduling policy in sched_params is not compatible to the
239
       one of the thread's server.
928 trimarchi 240
   @retval FSF_ERR_NOT_SCHEDULED_THREAD if the given thread is not scheduled
881 trimarchi 241
       under the FSF
928 trimarchi 242
   @retval FSF_ERR_INTERNAL_ERROR erroneous binding or malfunction of the FSF
881 trimarchi 243
       main scheduler
928 trimarchi 244
   @retval FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD if the thread is attached to
881 trimarchi 245
       an application defined scheduler different than the fsf scheduler
928 trimarchi 246
   @retval FSF_ERR_NOT_CONTRACTED_SERVER if the thread is bound and its server
881 trimarchi 247
       is not valid
248
*/
249
int  
250
fsf_set_local_thread_sched_parameters
251
  (pthread_t                     thread,
252
   const fsf_sched_params_t  *sched_params);
253
 
254
 
928 trimarchi 255
/**
256
   \ingroup hiermodule
257
 
258
   This function stores the local scheduling parameters of the
259
   specified thread in the variable pointed to by sched_params
260
 
261
   @param [in] thread thread id
262
   @param [out] sched_params scheduling parameters
263
 
264
   @retval 0 if the operation is succesful
265
   @retval FSF_ERR_BAD_ARGUMENT if sched_params is NULL or the thread does
266
           not exist
267
   @retval FSF_ERR_NOT_SCHEDULED_THREAD if the given thread is not scheduled
881 trimarchi 268
       under the FSF
269
*/
270
int  
271
fsf_get_local_thread_sched_parameters
272
  (pthread_t            thread,
273
   fsf_sched_params_t  *sched_params);
274
 
275
 
276
#endif // _FSF_HIERARCHICAL_H_