1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
// ============================================================================
//
// $Id$
//
// ============================================================================
#include "orbsvcs/Time_Utilities.h"
#include "orbsvcs/Scheduler_Factory.h"
#if defined (TAO_USES_STRATEGY_SCHEDULER)
#include "Strategy_Scheduler.h"
#else
#include "Scheduler_Generic.h"
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
#include "Config_Scheduler.h"
#if defined (__ACE_INLINE__)
#include "Config_Scheduler.i"
#endif /* __ACE_INLINE__ */
ACE_Config_Scheduler::ACE_Config_Scheduler (void)
#if defined (TAO_USES_STRATEGY_SCHEDULER)
: scheduler_strategy_ ((RtecScheduler::Preemption_Priority) TAO_MIN_CRITICAL_PRIORITY)
, impl (new ACE_Strategy_Scheduler (scheduler_strategy_))
#else
: impl (new Scheduler_Generic)
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
{
// impl->output_level (10);
}
ACE_Config_Scheduler::~ACE_Config_Scheduler (void)
{
delete impl;
}
RtecScheduler::handle_t
ACE_Config_Scheduler::create (const char * entry_point,
CORBA::Environment &)
TAO_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::DUPLICATE_NAME))
{
typedef RtecScheduler::RT_Info* RT_Info_ptr;
RtecScheduler::RT_Info** rt_info;
ACE_NEW_RETURN (rt_info, RT_Info_ptr[1], -1);
ACE_NEW_RETURN (rt_info[0], RtecScheduler::RT_Info, -1);
rt_info[0]->entry_point = CORBA::string_dup(entry_point);
rt_info[0]->handle = -1;
rt_info[0]->worst_case_execution_time = ORBSVCS_Time::zero;
rt_info[0]->typical_execution_time = ORBSVCS_Time::zero;
rt_info[0]->cached_execution_time = ORBSVCS_Time::zero;
rt_info[0]->period = 0;
rt_info[0]->importance = RtecScheduler::VERY_LOW_IMPORTANCE;
rt_info[0]->quantum = ORBSVCS_Time::zero;
rt_info[0]->threads = 0;
rt_info[0]->priority = 0;
rt_info[0]->preemption_subpriority = 0;
rt_info[0]->preemption_priority = 0;
RtecScheduler::handle_t handle = -1;
#if defined (TAO_USES_STRATEGY_SCHEDULER)
switch (impl->register_task (rt_info[0], handle))
#else
switch (impl->register_task (rt_info, 1, handle))
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
{
case BaseSchedImplType::SUCCEEDED:
break;
case BaseSchedImplType::ST_VIRTUAL_MEMORY_EXHAUSTED:
case BaseSchedImplType::ST_TASK_ALREADY_REGISTERED:
default:
delete rt_info[0];
delete[] rt_info;
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::create - register_task failed\n"));
// @@ TODO: throw something.
break;
}
return handle;
}
RtecScheduler::handle_t
ACE_Config_Scheduler::lookup (const char * entry_point,
CORBA::Environment &)
TAO_THROW_SPEC ((CORBA::SystemException))
{
RtecScheduler::RT_Info* rt_info = 0;
switch (impl->get_rt_info (entry_point, rt_info))
{
case BaseSchedImplType::SUCCEEDED:
return rt_info->handle;
ACE_NOTREACHED (break);
case BaseSchedImplType::FAILED:
case BaseSchedImplType::ST_UNKNOWN_TASK:
default:
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::lookup - get_rt_info failed\n"));
// @@ TODO: throw something.
break;
}
return -1;
}
RtecScheduler::RT_Info*
ACE_Config_Scheduler::get (RtecScheduler::handle_t handle,
CORBA::Environment &)
TAO_THROW_SPEC((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK))
{
RtecScheduler::RT_Info* rt_info = 0;
switch (impl->lookup_rt_info (handle, rt_info))
{
case BaseSchedImplType::SUCCEEDED:
{
// IDL memory managment semantics require the we return a copy
RtecScheduler::RT_Info* copy;
ACE_NEW_RETURN (copy, RtecScheduler::RT_Info (*rt_info), 0);
return copy;
}
ACE_NOTREACHED (break);
case BaseSchedImplType::FAILED:
case BaseSchedImplType::ST_UNKNOWN_TASK:
default:
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::get - lookup_rt_info failed\n"));
// @@ TODO: throw something.
break;
}
return 0;
}
void ACE_Config_Scheduler::set (RtecScheduler::handle_t handle,
RtecScheduler::Criticality criticality,
const RtecScheduler::Time &time,
const RtecScheduler::Time &typical_time,
const RtecScheduler::Time &cached_time,
RtecScheduler::Period period,
RtecScheduler::Importance importance,
const RtecScheduler::Quantum &quantum,
CORBA::Long threads,
RtecScheduler::Info_Type info_type,
CORBA::Environment &)
TAO_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK))
{
RtecScheduler::RT_Info* rt_info = 0;
switch (impl->lookup_rt_info (handle, rt_info))
{
case BaseSchedImplType::SUCCEEDED:
rt_info->criticality = criticality,
rt_info->worst_case_execution_time = time;
rt_info->typical_execution_time = typical_time;
rt_info->cached_execution_time = cached_time;
rt_info->period = period;
rt_info->importance = importance;
rt_info->quantum = quantum;
rt_info->threads = threads;
rt_info->info_type = info_type;
break;
case BaseSchedImplType::FAILED:
case BaseSchedImplType::ST_UNKNOWN_TASK:
default:
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::set - lookup_rt_info failed\n"));
// @@ TODO: throw something.
break;
}
}
void ACE_Config_Scheduler::priority (RtecScheduler::handle_t handle,
RtecScheduler::OS_Priority& priority,
RtecScheduler::Preemption_Subpriority& p_subpriority,
RtecScheduler::Preemption_Priority& p_priority,
CORBA::Environment &_env)
TAO_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::NOT_SCHEDULED))
{
ACE_UNUSED_ARG (_env);
if (impl->priority (handle, priority, p_subpriority, p_priority) == -1)
{
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::priority - priority failed\n"));
// TODO: throw something.
}
}
void ACE_Config_Scheduler::entry_point_priority (const char * entry_point,
RtecScheduler::OS_Priority& priority,
RtecScheduler::Preemption_Subpriority& p_subpriority,
RtecScheduler::Preemption_Priority& p_priority,
CORBA::Environment &_env)
TAO_THROW_SPEC((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::NOT_SCHEDULED))
{
this->priority (lookup (entry_point, _env),
priority, p_subpriority, p_priority,
_env);
}
void ACE_Config_Scheduler::add_dependency (RtecScheduler::handle_t handle,
RtecScheduler::handle_t dependency,
CORBA::Long number_of_calls,
RtecScheduler::Dependency_Type
dependency_type,
CORBA::Environment &_env)
TAO_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK))
{
ACE_UNUSED_ARG (_env);
RtecScheduler::RT_Info* rt_info = 0;
switch (impl->lookup_rt_info (handle, rt_info))
{
case BaseSchedImplType::SUCCEEDED:
{
RtecScheduler::Dependency_Info dep;
dep.rt_info = dependency;
dep.number_of_calls = number_of_calls;
dep.dependency_type = dependency_type;
#if defined (TAO_USES_STRATEGY_SCHEDULER)
impl->add_dependency (rt_info, dep);
#else
BaseSchedImplType::add_dependency (rt_info, dep);
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
}
break;
case BaseSchedImplType::FAILED:
case BaseSchedImplType::ST_UNKNOWN_TASK:
default:
ACE_ERROR ((LM_ERROR,
"cannot find %d to add dependency", handle));
// TODO: throw something.
break;
}
}
void ACE_Config_Scheduler::compute_scheduling (CORBA::Long minimum_priority,
CORBA::Long maximum_priority,
RtecScheduler::RT_Info_Set_out infos,
CORBA::Environment &_env)
TAO_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UTILIZATION_BOUND_EXCEEDED,
RtecScheduler::INSUFFICIENT_THREAD_PRIORITY_LEVELS,
RtecScheduler::TASK_COUNT_MISMATCH))
{
ACE_UNUSED_ARG (_env);
impl->init (minimum_priority, maximum_priority);
if (impl->schedule () != BaseSchedImplType::SUCCEEDED)
{
// TODO: throw something.
ACE_ERROR ((LM_ERROR, "schedule failed\n"));
return;
}
if (infos == 0)
{
infos = new RtecScheduler::RT_Info_Set(impl->tasks ());
}
infos->length (impl->tasks ());
for (RtecScheduler::handle_t handle = 1;
handle <= (RtecScheduler::handle_t) impl->tasks ();
++handle)
{
RtecScheduler::RT_Info* rt_info = 0;
switch (impl->lookup_rt_info (handle, rt_info))
{
case BaseSchedImplType::SUCCEEDED:
// We know that handles start at 1.
infos[CORBA::ULong(handle - 1)] = *rt_info;
break;
case BaseSchedImplType::FAILED:
case BaseSchedImplType::ST_UNKNOWN_TASK:
default:
ACE_ERROR ((LM_ERROR,
"Config_Scheduler::schedule - lookup_rt_info failed\n"));
// TODO: throw something.
break;
}
}
ACE_DEBUG ((LM_DEBUG, "schedule prepared\n"));
ACE_DEBUG ((LM_DEBUG, "dumping to stdout\n"));
ACE_Scheduler_Factory::dump_schedule (*(infos.ptr()), 0);
ACE_DEBUG ((LM_DEBUG, "dump done\n"));
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
#if defined (TAO_USES_STRATEGY_SCHEDULER)
#if defined (TAO_USES_MUF_SCHEDULING)
template class ACE_Strategy_Scheduler_Factory<ACE_MUF_Scheduler_Strategy>;
#elif defined (TAO_USES_MLF_SCHEDULING)
template class ACE_Strategy_Scheduler_Factory<ACE_MLF_Scheduler_Strategy>;
#elif defined (TAO_USES_EDF_SCHEDULING)
template class ACE_Strategy_Scheduler_Factory<ACE_EDF_Scheduler_Strategy>;
#elif defined (TAO_USES_RMS_SCHEDULING)
template class ACE_Strategy_Scheduler_Factory<ACE_RMS_Scheduler_Strategy>;
#elif defined (TAO_USES_RMS_DYN_SCHEDULING)
template class ACE_Strategy_Scheduler_Factory<ACE_RMS_Dyn_Scheduler_Strategy>;
#else
#error scheduling strategy must be defined
#endif /* defined (TAO_USES_MUF_SCHEDULING) */
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#if defined (TAO_USES_STRATEGY_SCHEDULER)
#if defined (TAO_USES_MUF_SCHEDULING)
#pragma instantiate ACE_Strategy_Scheduler_Factory<ACE_MUF_Scheduler_Strategy>
#elif defined (TAO_USES_MLF_SCHEDULING)
#pragma instantiate ACE_Strategy_Scheduler_Factory<ACE_MLF_Scheduler_Strategy>
#elif defined (TAO_USES_EDF_SCHEDULING)
#pragma instantiate ACE_Strategy_Scheduler_Factory<ACE_EDF_Scheduler_Strategy>
#elif defined (TAO_USES_RMS_SCHEDULING)
#pragma instantiate ACE_Strategy_Scheduler_Factory<ACE_RMS_Scheduler_Strategy>
#elif defined (TAO_USES_RMS_DYN_SCHEDULING)
#pragma instantiate ACE_Strategy_Scheduler_Factory<ACE_RMS_Dyn_Scheduler_Strategy>
#else
#error scheduling strategy must be defined
#endif /* defined (TAO_USES_MUF_SCHEDULING) */
#endif /* defined (TAO_USES_STRATEGY_SCHEDULER) */
#endif /* defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) */
|