#include <EC_Kokyu_Dispatching.h>
Inheritance diagram for TAO_EC_Kokyu_Dispatching:
Public Member Functions | |
TAO_EC_Kokyu_Dispatching (TAO_EC_Event_Channel_Base *ec, int sched_policy, int sched_scope) | |
virtual void | activate (void) |
virtual void | shutdown (void) |
virtual void | push (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, const RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info) |
virtual void | push_nocopy (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info) |
Private Member Functions | |
void | setup_lanes (void) |
Private Attributes | |
ACE_Allocator * | allocator_ |
Kokyu::Dispatcher_Auto_Ptr | dispatcher_ |
The dispatcher. | |
RtecScheduler::Scheduler_var | scheduler_ |
The scheduler. | |
int | lanes_setup_ |
int | disp_sched_policy_ |
int | disp_sched_scope_ |
This strategy uses multiple queues, each serviced by a thread at different priority. This minimizes priority inversion because the consumers at higher priority are serviced before consumers at lower priority. It is more flexible than using the supplier thread to dispatch because it allows high-priority suppliers to push events to low-priority consumers (and vice-versa). It also isolates the supplier threads from the time spent on upcalls to the consumer objects, making the system easier to analyze and schedule.
Definition at line 55 of file EC_Kokyu_Dispatching.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_Kokyu_Dispatching::TAO_EC_Kokyu_Dispatching | ( | TAO_EC_Event_Channel_Base * | ec, | |
int | sched_policy, | |||
int | sched_scope | |||
) |
The scheduler is used to find the range of priorities and similar info.
Definition at line 27 of file EC_Kokyu_Dispatching.cpp.
References TAO_Pseudo_Var_T< T >::in(), and ACE_Allocator::instance().
00028 :allocator_ (0), 00029 dispatcher_ (0), 00030 lanes_setup_ (0), 00031 disp_sched_policy_ (sched_policy), 00032 disp_sched_scope_ (sched_scope) 00033 { 00034 CORBA::Object_var tmp = ec->scheduler (); 00035 this->scheduler_ = RtecScheduler::Scheduler::_narrow (tmp.in ()); 00036 00037 //@@VS - need to revisit this - should be some other allocator 00038 if (this->allocator_ == 0) 00039 { 00040 this->allocator_ = ACE_Allocator::instance (); 00041 } 00042 }
void TAO_EC_Kokyu_Dispatching::activate | ( | void | ) | [virtual] |
Initialize all the data structures, activate any internal threads, etc.
Implements TAO_EC_Dispatching.
Definition at line 45 of file EC_Kokyu_Dispatching.cpp.
References dispatcher_, lanes_setup_, and setup_lanes().
00046 { 00047 if (!lanes_setup_) 00048 setup_lanes (); 00049 00050 this->dispatcher_->activate (); 00051 00052 //ACE_DEBUG ((LM_DEBUG, "Kokyu dispatcher activated\n")); 00053 }
void TAO_EC_Kokyu_Dispatching::push | ( | TAO_EC_ProxyPushSupplier * | proxy, | |
RtecEventComm::PushConsumer_ptr | consumer, | |||
const RtecEventComm::EventSet & | event, | |||
TAO_EC_QOS_Info & | qos_info | |||
) | [virtual] |
The consumer represented by proxy should receive event. It can use the information in qos_info to determine the event priority (among other things).
Implements TAO_EC_Dispatching.
Definition at line 111 of file EC_Kokyu_Dispatching.cpp.
References push_nocopy().
00115 { 00116 RtecEventComm::EventSet event_copy = event; 00117 this->push_nocopy (proxy, consumer, event_copy, qos_info); 00118 }
void TAO_EC_Kokyu_Dispatching::push_nocopy | ( | TAO_EC_ProxyPushSupplier * | proxy, | |
RtecEventComm::PushConsumer_ptr | consumer, | |||
RtecEventComm::EventSet & | event, | |||
TAO_EC_QOS_Info & | qos_info | |||
) | [virtual] |
Implements TAO_EC_Dispatching.
Definition at line 121 of file EC_Kokyu_Dispatching.cpp.
References allocator_, CORBA::COMPLETED_NO, dispatcher_, ACE_Allocator::malloc(), TAO_EC_QOS_Info::rt_info, scheduler_, and TAO::VMCID.
Referenced by push().
00125 { 00126 if (this->dispatcher_.get () == 0) 00127 this->setup_lanes (); 00128 00129 void* buf = 00130 this->allocator_->malloc (sizeof (TAO_EC_Kokyu_Push_Command )); 00131 00132 if (buf == 0) 00133 throw CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_NO); 00134 00135 // Create Dispatch_Command 00136 TAO_EC_Kokyu_Push_Command *cmd = 00137 new (buf) TAO_EC_Kokyu_Push_Command (proxy, 00138 consumer, 00139 event, this->allocator_); 00140 00141 /* 00142 TAO_EC_Kokyu_Push_Command *cmd = 00143 new TAO_EC_Kokyu_Push_Command (proxy, 00144 consumer, 00145 event, 0); 00146 */ 00147 00148 // Convert TAO_EC_QOS_Info to QoSDescriptor 00149 RtecScheduler::RT_Info *rt_info = 00150 this->scheduler_->get(qos_info.rt_info); 00151 00152 Kokyu::QoSDescriptor qosd; 00153 qosd.preemption_priority_ = rt_info->preemption_priority; 00154 qosd.deadline_ = rt_info->period; 00155 ORBSVCS_Time::TimeT_to_Time_Value (qosd.execution_time_, 00156 rt_info->worst_case_execution_time); 00157 00158 this->dispatcher_->dispatch(cmd,qosd); 00159 }
void TAO_EC_Kokyu_Dispatching::setup_lanes | ( | void | ) | [private] |
Definition at line 56 of file EC_Kokyu_Dispatching.cpp.
References disp_sched_policy_, disp_sched_scope_, dispatcher_, lanes_setup_, and scheduler_.
Referenced by activate().
00057 { 00058 // Query the scheduler togetConfig_Infos 00059 RtecScheduler::Config_Info_Set_var configs; 00060 try 00061 { 00062 this->scheduler_->get_config_infos(configs.out()); 00063 } 00064 catch (const CORBA::Exception&) 00065 { 00066 // Ignore exceptions.. 00067 } 00068 00069 //might be no Config_Infos in the set (if none passed to scheduler_) 00070 00071 // Convert RtecScheduler::Config_Info_Set to Kokyu::ConfigInfoSet 00072 // OK to assume exact correspondence betwen Config_Info and ConfigInfo? 00073 Kokyu::ConfigInfoSet kconfigs(configs->length()); 00074 for(CORBA::ULong i=0; i<configs->length(); ++i) { 00075 kconfigs[i].preemption_priority_ = configs[i].preemption_priority; 00076 kconfigs[i].thread_priority_ = configs[i].thread_priority; 00077 switch (configs[i].dispatching_type) { 00078 case RtecScheduler::STATIC_DISPATCHING: 00079 kconfigs[i].dispatching_type_ = Kokyu::FIFO_DISPATCHING; 00080 break; 00081 case RtecScheduler::DEADLINE_DISPATCHING: 00082 kconfigs[i].dispatching_type_ = Kokyu::DEADLINE_DISPATCHING; 00083 break; 00084 case RtecScheduler::LAXITY_DISPATCHING: 00085 kconfigs[i].dispatching_type_ = Kokyu::LAXITY_DISPATCHING; 00086 break; 00087 } 00088 } 00089 00090 Kokyu::Dispatcher_Attributes attrs; 00091 attrs.config_info_set_ = kconfigs; 00092 attrs.sched_policy (disp_sched_policy_); 00093 attrs.sched_scope (disp_sched_scope_); 00094 00095 // Create Kokyu::Dispatcher using factory 00096 Kokyu::Dispatcher_Auto_Ptr 00097 tmp(Kokyu::Dispatcher_Factory::create_dispatcher(attrs)); 00098 this->dispatcher_ = tmp; 00099 this->lanes_setup_ = 1; 00100 00101 //ACE_DEBUG ((LM_DEBUG, "Kokyu dispatcher setup\n")); 00102 }
void TAO_EC_Kokyu_Dispatching::shutdown | ( | void | ) | [virtual] |
Deactivate any internal threads and cleanup internal data structures, it should only return once the threads have finished their jobs.
Implements TAO_EC_Dispatching.
Definition at line 105 of file EC_Kokyu_Dispatching.cpp.
References dispatcher_.
00106 { 00107 this->dispatcher_->shutdown(); 00108 }
int TAO_EC_Kokyu_Dispatching::disp_sched_policy_ [private] |
int TAO_EC_Kokyu_Dispatching::disp_sched_scope_ [private] |
Kokyu::Dispatcher_Auto_Ptr TAO_EC_Kokyu_Dispatching::dispatcher_ [private] |
The dispatcher.
Definition at line 82 of file EC_Kokyu_Dispatching.h.
Referenced by activate(), push_nocopy(), setup_lanes(), and shutdown().
int TAO_EC_Kokyu_Dispatching::lanes_setup_ [private] |
RtecScheduler::Scheduler_var TAO_EC_Kokyu_Dispatching::scheduler_ [private] |
The scheduler.
Definition at line 85 of file EC_Kokyu_Dispatching.h.
Referenced by push_nocopy(), and setup_lanes().