TAO_EC_Kokyu_Dispatching Class Reference

Dispatching strategy that minimizes priority inversion. More...

#include <EC_Kokyu_Dispatching.h>

Inheritance diagram for TAO_EC_Kokyu_Dispatching:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Kokyu_Dispatching:

Collaboration graph
[legend]
List of all members.

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 ACE_ENV_ARG_DECL)
virtual void push_nocopy (TAO_EC_ProxyPushSupplier *proxy, RtecEventComm::PushConsumer_ptr consumer, RtecEventComm::EventSet &event, TAO_EC_QOS_Info &qos_info ACE_ENV_ARG_DECL)

Private Member Functions

void setup_lanes (void)

Private Attributes

ACE_Allocatorallocator_
Kokyu::Dispatcher_Auto_Ptr dispatcher_
 The dispatcher.

RtecScheduler::Scheduler_var scheduler_
 The scheduler.

int lanes_setup_
int disp_sched_policy_
int disp_sched_scope_

Detailed Description

Dispatching strategy that minimizes priority inversion.

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.


Constructor & Destructor Documentation

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 ACE_Allocator::instance(), and TAO_EC_Event_Channel_Base::scheduler().

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 }


Member Function Documentation

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  ACE_ENV_ARG_DECL
[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 114 of file EC_Kokyu_Dispatching.cpp.

References ACE_ENV_ARG_PARAMETER, RtecEventComm::EventSet, and push_nocopy().

00119 {
00120   RtecEventComm::EventSet event_copy = event;
00121   this->push_nocopy (proxy, consumer, event_copy, qos_info ACE_ENV_ARG_PARAMETER);
00122 }

void TAO_EC_Kokyu_Dispatching::push_nocopy TAO_EC_ProxyPushSupplier proxy,
RtecEventComm::PushConsumer_ptr  consumer,
RtecEventComm::EventSet event,
TAO_EC_QOS_Info &qos_info  ACE_ENV_ARG_DECL
[virtual]
 

Implements TAO_EC_Dispatching.

Definition at line 125 of file EC_Kokyu_Dispatching.cpp.

References ACE_THROW, dispatcher_, RtecEventComm::EventSet, ACE_Allocator::malloc(), and setup_lanes().

Referenced by push().

00130 {
00131     if (this->dispatcher_.get () == 0)
00132         this->setup_lanes ();
00133 
00134     void* buf =
00135       this->allocator_->malloc (sizeof (TAO_EC_Kokyu_Push_Command ));
00136 
00137     if (buf == 0)
00138       ACE_THROW (CORBA::NO_MEMORY (TAO::VMCID,
00139                                    CORBA::COMPLETED_NO));
00140 
00141   // Create Dispatch_Command
00142   TAO_EC_Kokyu_Push_Command *cmd =
00143     new (buf) TAO_EC_Kokyu_Push_Command (proxy,
00144                                          consumer,
00145                                          event, this->allocator_);
00146 
00147   /*
00148   TAO_EC_Kokyu_Push_Command *cmd =
00149     new TAO_EC_Kokyu_Push_Command (proxy,
00150                                    consumer,
00151                                  event, 0);
00152   */
00153 
00154   // Convert TAO_EC_QOS_Info to QoSDescriptor
00155   RtecScheduler::RT_Info *rt_info =
00156     this->scheduler_->get(qos_info.rt_info);
00157 
00158   Kokyu::QoSDescriptor qosd;
00159   qosd.preemption_priority_ = rt_info->preemption_priority;
00160   qosd.deadline_ = rt_info->period;
00161   ORBSVCS_Time::TimeT_to_Time_Value (qosd.execution_time_,
00162                                      rt_info->worst_case_execution_time);
00163 
00164   this->dispatcher_->dispatch(cmd,qosd);
00165 }

void TAO_EC_Kokyu_Dispatching::setup_lanes void   )  [private]
 

Definition at line 56 of file EC_Kokyu_Dispatching.cpp.

References ACE_CATCHANY, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_TRY, ACE_TRY_CHECK, disp_sched_policy_, disp_sched_scope_, dispatcher_, and lanes_setup_.

Referenced by activate(), and push_nocopy().

00057 {
00058   ACE_DECLARE_NEW_CORBA_ENV;
00059   // Query the scheduler togetConfig_Infos
00060   RtecScheduler::Config_Info_Set_var configs;
00061   ACE_TRY
00062     {
00063       this->scheduler_->get_config_infos(configs.out());
00064       ACE_TRY_CHECK;
00065     }
00066   ACE_CATCHANY
00067     {
00068       // Ignore exceptions..
00069     }
00070   ACE_ENDTRY;
00071 
00072   //might be no Config_Infos in the set (if none passed to scheduler_)
00073 
00074   // Convert RtecScheduler::Config_Info_Set     to Kokyu::ConfigInfoSet
00075   // OK to assume exact correspondence betwen Config_Info and ConfigInfo?
00076   Kokyu::ConfigInfoSet kconfigs(configs->length());
00077   for(CORBA::ULong i=0; i<configs->length(); ++i) {
00078         kconfigs[i].preemption_priority_ = configs[i].preemption_priority;
00079         kconfigs[i].thread_priority_ = configs[i].thread_priority;
00080         switch (configs[i].dispatching_type) {
00081                 case RtecScheduler::STATIC_DISPATCHING:
00082                         kconfigs[i].dispatching_type_ = Kokyu::FIFO_DISPATCHING;
00083                         break;
00084                 case RtecScheduler::DEADLINE_DISPATCHING:
00085                         kconfigs[i].dispatching_type_ = Kokyu::DEADLINE_DISPATCHING;
00086                         break;
00087                 case RtecScheduler::LAXITY_DISPATCHING:
00088                         kconfigs[i].dispatching_type_ = Kokyu::LAXITY_DISPATCHING;
00089                         break;
00090         }
00091   }
00092 
00093   Kokyu::Dispatcher_Attributes attrs;
00094   attrs.config_info_set_ = kconfigs;
00095   attrs.sched_policy (disp_sched_policy_);
00096   attrs.sched_scope (disp_sched_scope_);
00097 
00098   // Create Kokyu::Dispatcher using factory
00099   Kokyu::Dispatcher_Auto_Ptr
00100     tmp(Kokyu::Dispatcher_Factory::create_dispatcher(attrs));
00101   this->dispatcher_ = tmp;
00102   this->lanes_setup_ = 1;
00103 
00104   //ACE_DEBUG ((LM_DEBUG, "Kokyu dispatcher setup\n"));
00105 }

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 108 of file EC_Kokyu_Dispatching.cpp.

References dispatcher_.

00109 {
00110   this->dispatcher_->shutdown();
00111 }


Member Data Documentation

ACE_Allocator* TAO_EC_Kokyu_Dispatching::allocator_ [private]
 

Definition at line 79 of file EC_Kokyu_Dispatching.h.

int TAO_EC_Kokyu_Dispatching::disp_sched_policy_ [private]
 

Definition at line 90 of file EC_Kokyu_Dispatching.h.

Referenced by setup_lanes().

int TAO_EC_Kokyu_Dispatching::disp_sched_scope_ [private]
 

Definition at line 91 of file EC_Kokyu_Dispatching.h.

Referenced by setup_lanes().

Kokyu::Dispatcher_Auto_Ptr TAO_EC_Kokyu_Dispatching::dispatcher_ [private]
 

The dispatcher.

Definition at line 84 of file EC_Kokyu_Dispatching.h.

Referenced by activate(), push_nocopy(), setup_lanes(), and shutdown().

int TAO_EC_Kokyu_Dispatching::lanes_setup_ [private]
 

Definition at line 89 of file EC_Kokyu_Dispatching.h.

Referenced by activate(), and setup_lanes().

RtecScheduler::Scheduler_var TAO_EC_Kokyu_Dispatching::scheduler_ [private]
 

The scheduler.

Definition at line 87 of file EC_Kokyu_Dispatching.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:14:53 2006 for TAO_RTEvent by doxygen 1.3.6