Subversion Repositories shark

Rev

Rev 811 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
221 giacomo 1
//=====================================================================
2
//       FFFFFFIII   RRRRR      SSTTTTTTT
3
//      FF         IIR   RR    SS
4
//     FF           IR        SS
5
//    FFFFFF         RRRR    SSSSST      
6
//   FF       FI       RRR  SS
7
//  FF         II     RRR  SS
8
// FF           IIIIIR    RS 
9
//       
10
// Basic FSF(FIRST Scheduling Framework) contract management
11
// S.Ha.R.K. Implementation
12
//=====================================================================
13
 
14
#include "fsf_contract.h"
15
 
16
int fsf_initialize_contract
17
  (fsf_contract_parameters_t *contract)
18
{
19
  struct timespec default_deadline = FSF_DEFAULT_DEADLINE;
20
 
21
  /* Check */
22
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
23
 
24
  /* Set to default value */
25
  NULL_TIMESPEC(&contract->budget_min);
26
  NULL_TIMESPEC(&contract->budget_max);
27
  NULL_TIMESPEC(&contract->period_min);
28
  NULL_TIMESPEC(&contract->period_max);
29
 
30
  contract->workload = FSF_DEFAULT_WORKLOAD;
31
 
32
  contract->local_scheduler_id = FSF_DEFAULT_SCHEDULER;
33
 
34
  contract->d_equals_t = FSF_DEFAULT_D_EQUALS_T;
35
 
36
  TIMESPEC_ASSIGN(&contract->deadline,&default_deadline);
37
 
38
  contract->budget_overrun_sig_notify = 0;
39
  memset(&contract->budget_overrun_sig_value,0,sizeof(union sigval));
40
 
41
  contract->deadline_miss_sig_notify = 0;
42
  memset(&contract->deadline_miss_sig_value,0,sizeof(union sigval));
43
 
44
  contract->granularity = FSF_DEFAULT_GRANULARITY;
45
  contract->utilization_set.size = 0;
46
  contract->quality = FSF_DEFAULT_QUALITY;
47
  contract->importance = FSF_DEFAULT_IMPORTANCE;
48
 
49
  contract->preemption_level = 0;
50
  contract->critical_sections.size = 0;
51
 
52
  return 0;
53
 
54
}
55
 
56
int fsf_set_contract_basic_parameters
57
  (fsf_contract_parameters_t *contract,
58
   const struct timespec  *budget_min,
59
   const struct timespec  *period_max,
60
   const struct timespec  *budget_max,
61
   const struct timespec  *period_min,
62
   fsf_workload_t          workload)
63
{
64
 
65
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
66
 
67
  if (budget_min) TIMESPEC_ASSIGN(&contract->budget_min,budget_min);
68
  if (period_max) TIMESPEC_ASSIGN(&contract->period_max,period_max);
69
  if (budget_max) TIMESPEC_ASSIGN(&contract->budget_max,budget_max);
70
  if (period_min) TIMESPEC_ASSIGN(&contract->period_min,period_min);
71
 
72
  contract->workload = workload;
73
 
74
  return 0;
75
 
76
}
77
 
78
int fsf_get_contract_basic_parameters
79
  (const fsf_contract_parameters_t *contract,
80
   struct timespec  *budget_min,
81
   struct timespec  *period_max,
82
   struct timespec  *budget_max,
83
   struct timespec  *period_min,
84
   fsf_workload_t   *workload)
85
{
86
 
87
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
88
 
89
  TIMESPEC_ASSIGN(budget_min,&contract->budget_min);
90
  TIMESPEC_ASSIGN(period_max,&contract->period_max);
91
  TIMESPEC_ASSIGN(budget_max,&contract->budget_max);
92
  TIMESPEC_ASSIGN(period_min,&contract->period_min);
93
 
94
  *workload = contract->workload;
95
 
96
  return 0;
97
 
98
}
99
 
100
int fsf_set_contract_timing_requirements
101
  (fsf_contract_parameters_t *contract,
102
   bool                   d_equals_t,
103
   const struct timespec *deadline,
104
   int                    budget_overrun_sig_notify,
105
   union sigval           budget_overrun_sig_value,
106
   int                    deadline_miss_sig_notify,
107
   union sigval           deadline_miss_sig_value)
108
{
109
 
110
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
111
 
112
  contract->d_equals_t = d_equals_t;
113
 
114
  if (deadline) TIMESPEC_ASSIGN(&contract->deadline,deadline);
115
 
116
  contract->budget_overrun_sig_notify = budget_overrun_sig_notify;
117
  contract->budget_overrun_sig_value = budget_overrun_sig_value;
118
  contract->deadline_miss_sig_notify = deadline_miss_sig_notify;
119
  contract->deadline_miss_sig_value = deadline_miss_sig_value;
120
 
121
  return 0;
122
 
123
}
124
 
125
int fsf_get_contract_timing_requirements
126
  (const fsf_contract_parameters_t *contract,
127
   bool                            *d_equals_t,
128
   struct timespec                 *deadline,
129
   int                             *budget_overrun_sig_notify,
130
   union sigval                    *budget_overrun_sig_value,
131
   int                             *deadline_miss_sig_notify,
132
   union sigval                    *deadline_miss_sig_value)
133
{
134
 
135
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
136
 
137
  *d_equals_t = contract->d_equals_t;
138
 
139
  TIMESPEC_ASSIGN(deadline,&contract->deadline);
140
 
141
  *budget_overrun_sig_notify = contract->budget_overrun_sig_notify;
142
  *budget_overrun_sig_value = contract->budget_overrun_sig_value;
143
  *deadline_miss_sig_notify = contract->deadline_miss_sig_notify;
144
  *deadline_miss_sig_value = contract->deadline_miss_sig_value;
145
 
146
  return 0;
147
 
148
}
149
 
150
int fsf_set_contract_reclamation_parameters
151
  (fsf_contract_parameters_t    *contract,
152
   fsf_granularity_t            granularity,
153
   const fsf_utilization_set_t  *utilization_set,
154
   int                          quality,
155
   int                          importance)
156
{
157
 
158
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
159
 
160
  contract->granularity = granularity;
161
 
162
  if (utilization_set) memcpy(&contract->utilization_set,utilization_set,sizeof(fsf_utilization_set_t));
163
 
164
  contract->quality = quality;
165
  contract->importance = importance;
166
 
167
  return 0;
168
 
169
}
170
 
171
int fsf_get_contract_reclamation_parameters
172
  (const fsf_contract_parameters_t *contract,
173
   fsf_granularity_t               *granularity,
174
   fsf_utilization_set_t           *utilization_set,
175
   int                             *quality,
176
   int                             *importance)
177
{
178
 
179
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
180
 
181
  *granularity = contract->granularity;
182
 
183
  memcpy(utilization_set,&contract->utilization_set,sizeof(fsf_utilization_set_t));
184
 
185
  *quality = contract->quality;
186
  *importance = contract->importance;
187
 
188
  return 0;
189
 
190
}
191
 
192
int fsf_set_contract_synchronization_parameters
193
  (fsf_contract_parameters_t     *contract,
194
   fsf_preemption_level_t         preemption_level,
195
   const fsf_critical_sections_t *critical_sections)
196
{
197
 
198
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
199
 
200
  contract->preemption_level = preemption_level;
201
 
202
  if (critical_sections) memcpy(&contract->critical_sections,critical_sections,sizeof(fsf_critical_sections_t));
203
 
204
  return 0;
205
 
206
}
207
 
208
int
209
fsf_get_contract_synchronization_parameters
210
  (const fsf_contract_parameters_t *contract,
211
   fsf_preemption_level_t          *preemption_level,
212
   fsf_critical_sections_t         *critical_sections)
213
{
214
 
215
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
216
 
217
  *preemption_level = contract->preemption_level;
218
 
219
  memcpy(critical_sections,&contract->critical_sections,sizeof(fsf_critical_sections_t));
220
 
221
  return 0;
222
 
223
}
224
 
225
int
226
fsf_set_local_scheduler_parameter
227
  (fsf_contract_parameters_t *contract,
228
   fsf_scheduler_id_t local_scheduler_id)
229
{
230
 
231
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
232
 
233
  contract->local_scheduler_id = local_scheduler_id;
234
 
235
  return 0;
236
 
237
}
238
 
239
int
240
fsf_get_local_scheduler_parameter
241
  (const fsf_contract_parameters_t *contract,
242
   fsf_scheduler_id_t *local_scheduler_id)
243
{
244
 
245
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
246
 
247
  *local_scheduler_id = contract->local_scheduler_id;
248
 
249
  return 0;
250
 
251
}
252
 
253
 
254