Subversion Repositories shark

Rev

Rev 881 | Rev 928 | 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
 
889 trimarchi 57
//fsf_init_local_scheduler: This call has the following effects:
58
//    FP:  none
59
//    EDF: none
60
//    TABLE_DRIVEN :
61
//       Records the schedule duration, and starts the
62
//       schedule at the time of the call. After the
63
//       schedule duration has elapsed, the schedule in
64
//       the table is repeated.
65
/*
66
    [ERR@RETURNED:
67
     FSF_ERR_BAD_ARGUMENT : if the value of the server argument is not in range,
68
       or info is NULL
69
     FSF_ERR_NOT_SCHEDULED_CALLING_THREAD : if the calling thread is not
70
       scheduled under the FSF
71
     FSF_ERR_INVALID_SCHEDULER_REPLY : the scheduler is wrong or not running
72
     FSF_ERR_NOT_CONTRACTED_SERVER : if the server of the calling thread
73
       has been cancelled or it is not valid
74
    ]
881 trimarchi 75
*/
76
int fsf_init_local_scheduler(
77
   fsf_server_id_t       server,
78
   fsf_sched_init_info_t info);
79
 
80
 
889 trimarchi 81
// Constants for assigning default values
82
#define FSF_DEFAULT_SCHED_POLICY        FSF_NONE
83
 
84
 
881 trimarchi 85
/////////////////////////////////////////////////
86
//                       CONTRACT PARAMETERS
87
////////////////////////////////////////////////
88
 
889 trimarchi 89
//fsf_set_contract_scheduling_policy: The operation updates the
90
//specified contract parameters object by setting its scheduling
91
//policy to the specified input parameter.  The default policy is
92
//FSF_NONE, which means that only one thread may be bound to the
93
//server
94
/*
95
    [ERR@RETURNED:
96
     FSF_ERR_BAD_ARGUMENT : if sched_policy is not in range,
97
       or contract is NULL
98
    ]
99
*/
881 trimarchi 100
 
101
int
102
fsf_set_contract_scheduling_policy
103
  (fsf_contract_parameters_t *contract,
104
   fsf_sched_policy_t         sched_policy);
105
 
106
 
889 trimarchi 107
//fsf_get_contract_scheduling_policy: This operation obtains from the
108
//specified contract parameters object its scheduling policy, and
109
//copies it to the place pointed to by the corresponding input
110
//parameter.
111
/*
112
    [ERR@RETURNED:
113
     FSF_ERR_BAD_ARGUMENT : if sched_policy or contract are NULL
114
    ]
115
*/
881 trimarchi 116
 
117
int
118
fsf_get_contract_scheduling_policy
119
  (const fsf_contract_parameters_t *contract,
120
   fsf_sched_policy_t              *sched_policy);
121
 
122
 
889 trimarchi 123
//fsf_create_local_thread: : This operation creates a thread and binds
124
//it to the specified server, which must have a policy different than
125
//FSF_NONE. The new thread is created with the arguments thread, attr,
126
//thread_code and arg as they are defined for the pthread_create()
127
//POSIX function call, and its local scheduling parameters are set to
128
//the value stored in the variable pointed to by sched_params, which
129
//must be compatible with the server's scheduling policy. Then, the
130
//function binds the created thread to the new server. The attr
131
//parameter is overwritten as necessary to introduce the adequate
132
//scheduling policy and priority, according to the preemption level
133
//given in the contract and the fsf_priority_map() function defined by
134
//the user.
135
/*
136
    [ERR@RETURNED:
137
     FSF_ERR_BAD_ARGUMENT : if the value of the server argument is not in range,
138
       or sched_params is NULL
139
     FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE : if the scheduling policy
881 trimarchi 140
       in sched_params is not compatible to the server's one.
889 trimarchi 141
     FSF_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FSF
881 trimarchi 142
       main scheduler
889 trimarchi 143
     FSF_ERR_NOT_CONTRACTED_SERVER : if the referenced server is not valid
144
     FSF_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
145
       of the server is FSF_OVERHEAD
881 trimarchi 146
 
889 trimarchi 147
     It may also return any of  the errors that may be returned by the
148
       pthread_create()POSIX function call
149
    ]
881 trimarchi 150
*/
151
 
152
int
153
fsf_create_local_thread
154
  (fsf_server_id_t        server,
155
   fsf_sched_params_t    *sched_params,
156
   pthread_t             *thread,
157
   pthread_attr_t        *attr,
158
   fsf_thread_code_t      thread_code,
159
   void                  *arg);
160
 
889 trimarchi 161
//fsf_bind_local_thread_to_server: This operation associates a thread
162
//with a server, which must have a policy different than FSF_NONE. The
163
//thread's local scheduling parameters are set to the value stored in
164
//the variable pointed to by sched_params, which must be compatible
165
//with the server's scheduling policy. After the call the thread
166
//starts consuming the server's budget and is executed according to
167
//the contract established for that server and to its scheduling
168
//policy. If the thread was already bound to another server, it is
169
//effectively unbound from it and bound to the specified one.
881 trimarchi 170
 
889 trimarchi 171
//Implementation dependent issue: In order to allow the usage of
172
//application defined schedulers, the given thread must not have the
173
//scheduling policy SCHED_APP and at the same time be attached to an
174
//application scheduler different than the fsf scheduler.
881 trimarchi 175
 
889 trimarchi 176
/*
177
    [ERR@RETURNED:
178
     FSF_ERR_BAD_ARGUMENT : if the server argument does not complain with
881 trimarchi 179
       the expected format or valid range, the given thread does not exist,
180
       or sched_params is NULL
889 trimarchi 181
     FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE : if the scheduling policy
881 trimarchi 182
       in sched_params is not compatible to the server's one.
889 trimarchi 183
     FSF_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FSF
881 trimarchi 184
       main scheduler
889 trimarchi 185
     FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
881 trimarchi 186
       an application defined scheduler different than the fsf scheduler
889 trimarchi 187
     FSF_ERR_NOT_CONTRACTED_SERVER : if the referenced server is not valid
188
     FSF_ERR_SERVER_WORKLOAD_NOT_COMPATIBLE: if the kind of workload
189
       of the server is FSF_OVERHEAD
190
    ]
881 trimarchi 191
*/
889 trimarchi 192
 
881 trimarchi 193
int  
194
fsf_bind_local_thread_to_server
195
  (fsf_server_id_t      server,
196
   pthread_t            thread,
197
   fsf_sched_params_t  *sched_params);
198
 
199
 
889 trimarchi 200
// fsf_set_local_thread_sched_parameters: this function changes the
201
// local scheduling parameters of the thread to the value pointed to
202
// by sched_params. This value must be compatible with the scheduling
203
// policy of the server to which the thread is bound.
204
/*
205
    [ERR@RETURNED:
206
     FSF_ERR_BAD_ARGUMENT : if the given thread does not exist,
881 trimarchi 207
       or sched_params is NULL
889 trimarchi 208
     FSF_ERR_SCHED_POLICY_NOT_COMPATIBLE : if the thread is already bound
881 trimarchi 209
       and the scheduling policy in sched_params is not compatible to the
210
       one of the thread's server.
889 trimarchi 211
     FSF_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
881 trimarchi 212
       under the FSF
889 trimarchi 213
     FSF_ERR_INTERNAL_ERROR : erroneous binding or malfunction of the FSF
881 trimarchi 214
       main scheduler
889 trimarchi 215
     FSF_ERR_UNKNOWN_APPSCHEDULED_THREAD : if the thread is attached to
881 trimarchi 216
       an application defined scheduler different than the fsf scheduler
889 trimarchi 217
     FSF_ERR_NOT_CONTRACTED_SERVER : if the thread is bound and its server
881 trimarchi 218
       is not valid
889 trimarchi 219
    ]
881 trimarchi 220
*/
889 trimarchi 221
 
881 trimarchi 222
int  
223
fsf_set_local_thread_sched_parameters
224
  (pthread_t                     thread,
225
   const fsf_sched_params_t  *sched_params);
226
 
227
 
889 trimarchi 228
// fsf_get_local_thread_sched_parameters: this function stores the
229
// local scheduling parameters of the specified thread in the variable
230
// pointed to by sched_params
231
/*
232
    [ERR@RETURNED:
233
     FSF_ERR_BAD_ARGUMENT : if sched_params is NULL or the thread does
234
        not exist
235
     FSF_ERR_NOT_SCHEDULED_THREAD : if the given thread is not scheduled
881 trimarchi 236
       under the FSF
889 trimarchi 237
    ]
881 trimarchi 238
*/
889 trimarchi 239
 
881 trimarchi 240
int  
241
fsf_get_local_thread_sched_parameters
242
  (pthread_t            thread,
243
   fsf_sched_params_t  *sched_params);
244
 
245
 
246
#endif // _FSF_HIERARCHICAL_H_