4 #include "orbsvcs/Event/EC_Event_Channel.h"
5 #include "orbsvcs/Sched/Config_Scheduler.h"
6 #include "orbsvcs/Event_Utilities.h"
7 #include "orbsvcs/Scheduler_Factory.h"
8 #include "orbsvcs/Time_Utilities.h"
9 #include "ace/Get_Opt.h"
10 #include "ace/Sched_Params.h"
15 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
18 return driver
.run (argc
, argv
);
21 // ****************************************************************
23 EC_Schedule::EC_Schedule (void)
29 EC_Schedule::parse_args (int& argc
, ACE_TCHAR
* argv
[])
31 if (this->EC_Driver::parse_args (argc
, argv
) != 0)
38 EC_Schedule::print_args (void) const
40 this->EC_Driver::print_args ();
44 EC_Schedule::print_usage (void)
46 this->EC_Driver::print_usage ();
50 EC_Schedule::initialize_ec_impl (void)
52 this->scheduler_impl_
= new ACE_Config_Scheduler
;
53 this->scheduler_
= this->scheduler_impl_
->_this ();
55 this->EC_Driver::initialize_ec_impl ();
59 EC_Schedule::modify_attributes (TAO_EC_Event_Channel_Attributes
& attr
)
61 attr
.scheduler
= this->scheduler_
.in (); // no need to dup
65 EC_Schedule::cleanup_ec (void)
67 this->EC_Driver::cleanup_ec ();
68 delete this->scheduler_impl_
;
72 EC_Schedule::execute_test (void)
74 CORBA::Long min_priority
=
75 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
76 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
77 CORBA::Long max_priority
=
78 ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
);
82 "EC_Schedule (%P|%t) computing schedule\n"));
84 RtecScheduler::RT_Info_Set_var infos
;
85 RtecScheduler::Dependency_Set_var deps
;
86 RtecScheduler::Config_Info_Set_var configs
;
87 RtecScheduler::Scheduling_Anomaly_Set_var anomalies
;
88 this->scheduler_
->compute_scheduling (min_priority
, max_priority
,
96 "EC_Schedule (%P|%t) schedule prepared\n"));
98 ACE_Scheduler_Factory::dump_schedule (infos
.in (),
103 if (this->verbose ())
104 ACE_DEBUG ((LM_DEBUG
,
105 "EC_Schedule (%P|%t) schedule dumped\n"));
110 EC_Schedule::build_consumer_qos (
112 RtecEventChannelAdmin::ConsumerQOS
& qos
,
113 int& shutdown_event_type
)
116 ACE_OS::sprintf (name
, "EC_Schedule::Consumer::%04x", i
);
118 RtecScheduler::handle_t rt_info
=
119 this->scheduler_
->create (name
);
121 // The worst case execution time is far less than 2
122 // milliseconds, but that is a safe estimate....
123 ACE_Time_Value
tv (0, 2000);
124 TimeBase::TimeT time
;
125 ORBSVCS_Time::Time_Value_to_TimeT (time
, tv
);
126 this->scheduler_
->set (rt_info
,
127 RtecScheduler::VERY_HIGH_CRITICALITY
,
130 RtecScheduler::VERY_LOW_IMPORTANCE
,
133 RtecScheduler::OPERATION
);
136 this->consumer_type_start_
137 + i
* this->consumer_type_shift_
;
139 shutdown_event_type
= type_start
+ this->consumer_type_count_
;
141 ACE_ConsumerQOS_Factory qos_factory
;
142 qos_factory
.start_disjunction_group ();
143 qos_factory
.insert_type (shutdown_event_type
, rt_info
);
145 for (int j
= 0; j
!= this->consumer_type_count_
; ++j
)
146 qos_factory
.insert_type (type_start
+ j
, rt_info
);
148 qos
= qos_factory
.get_ConsumerQOS ();
152 EC_Schedule::build_supplier_qos (
154 RtecEventChannelAdmin::SupplierQOS
& qos
,
155 int& shutdown_event_type
)
158 ACE_OS::sprintf (name
, "EC_Schedule::Supplier::%04x", i
);
160 RtecScheduler::handle_t rt_info
=
161 this->scheduler_
->create (name
);
163 ACE_Time_Value
tv (0, this->burst_pause_
);
164 RtecScheduler::Period_t rate
= tv
.usec () * 10;
166 // The execution times are set to reasonable values, but
167 // actually they are changed on the real execution, i.e. we
168 // lie to the scheduler to obtain right priorities; but we
169 // don't care if the set is schedulable.
171 TimeBase::TimeT time
;
172 ORBSVCS_Time::Time_Value_to_TimeT (time
, tv
);
173 this->scheduler_
->set (rt_info
,
174 RtecScheduler::VERY_HIGH_CRITICALITY
,
177 RtecScheduler::VERY_LOW_IMPORTANCE
,
180 RtecScheduler::OPERATION
);
182 int type_start
= this->supplier_type_start_
+ i
*this->supplier_type_shift_
;
183 int supplier_id
= i
+ 1;
184 shutdown_event_type
= type_start
+ this->supplier_type_count_
;
186 ACE_SupplierQOS_Factory qos_factory
;
187 for (int j
= 0; j
!= this->supplier_type_count_
; ++j
)
188 qos_factory
.insert (supplier_id
,
192 qos_factory
.insert (supplier_id
,
196 qos
= qos_factory
.get_SupplierQOS ();
200 EC_Schedule::dump_results (void)