diff options
author | storri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-01-28 01:35:45 +0000 |
---|---|---|
committer | storri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-01-28 01:35:45 +0000 |
commit | 8297869c95fc61db327c9abf699801976d3d1ddf (patch) | |
tree | 22269078847c444188ffea515e3f1118d523623a | |
parent | 8f8d33a8e27c9ac69c15fdd8bd7e03ab8883f5f8 (diff) | |
download | ATCD-8297869c95fc61db327c9abf699801976d3d1ddf.tar.gz |
Tue Jan 27 16:38:00 2004 Stephen Torri <storri@cse.wustl.edu>
89 files changed, 11201 insertions, 0 deletions
diff --git a/Kokyu/Dispatch_Deferrer.cpp b/Kokyu/Dispatch_Deferrer.cpp new file mode 100644 index 00000000000..9cc8ccdc706 --- /dev/null +++ b/Kokyu/Dispatch_Deferrer.cpp @@ -0,0 +1,112 @@ +// $Id$ + +#include "ace/Sched_Params.h" +#include "Dispatch_Deferrer.h" +#include "Dispatcher_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Dispatch_Deferrer.i" +#endif /* __ACE_INLINE__ */ + +#include "kokyu_config.h" +#include "kokyu_dsui_families.h" +#include <dsui.h> +ACE_RCSID(Kokyu, Dispatch_Deferrer, "$Id$") + +namespace Kokyu +{ + +int +Dispatch_Deferrer::init(const Dispatch_Deferrer_Attributes& attr) +{ + //set up reactor for timeouts + this->react_.open(0); + //Don't need any handles, since we're only using it for timeouts + + this->timers_.open(); + + this->task_ = attr.task_; + + return 0; +} + +int +Dispatch_Deferrer::dispatch (Dispatch_Queue_Item *qitem) +{ + ACE_ASSERT(qitem != 0); + + //setup timout + //For now, assume period = deadline + ACE_Time_Value tv; + tv = ACE_OS::gettimeofday() + qitem->qos_info().deadline_; + long timer_id = this->react_.schedule_timer(this, + 0, //NULL arg + tv); + if (timer_id < 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("EC (%P|%t) cannot schedule Release Guard timer.") + ACE_TEXT ("ACE_Reactor.schedule_timer() returned -1\n")), + -1); + } + //else valid timer_id + this->timers_.bind(qitem,timer_id); + + //@BT INSTRUMENT with event ID: EVENT_DEFERRED_ENQUEUE Measure time + //between release and enqueue into dispatch queue because of RG + DSUI_EVENT_LOG(DISP_DEFERRER_FAM, EVENT_DEFERRED_ENQUEUE, timer_id, 0, NULL); + + //buffer until timer expires + return this->rgq_.enqueue_deadline(qitem,&tv); +} + + +int +Dispatch_Deferrer::handle_timeout (const ACE_Time_Value &, + const void *) +{ + //get all expired Dispatch_Queue_Items + ACE_Message_Block *begin,*end; + this->rgq_.remove_messages(begin,end, + (u_int) (ACE_Dynamic_Message_Strategy::LATE + | ACE_Dynamic_Message_Strategy::BEYOND_LATE)); + + //dispatch them back to Dispatcher_Impl + while (begin <= end) + { + Dispatch_Queue_Item *qitem = + ACE_dynamic_cast(Dispatch_Queue_Item*, begin); + + if (qitem == 0) + { + ACE_Message_Block::release (begin); + continue; + } + + + //remove timer for each enqueued qitem from reactor + long timer_id; + if (this->timers_.find(qitem,timer_id) < 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Could not cancel Release Guard timer.") + ACE_TEXT ("Unknown timer ID\n")), + -1); + } + //else got timer_id + this->react_.cancel_timer(timer_id); + + //@BT INSTRUMENT with event ID: EVENT_DEFERRED_DEQUEUE Measure + //time between release and enqueue into dispatch queue because + //of RG + DSUI_EVENT_LOG (DISP_DEFERRER_FAM, EVENT_DEFERRED_DEQUEUE, timer_id, 0, NULL); + + this->task_->enqueue(qitem); + + ++begin; + } + + return 0; +} + +} //namespace Kokyu diff --git a/Kokyu/Dispatch_Deferrer.h b/Kokyu/Dispatch_Deferrer.h new file mode 100644 index 00000000000..f110070a74c --- /dev/null +++ b/Kokyu/Dispatch_Deferrer.h @@ -0,0 +1,95 @@ +/* -*- C++ -*- */ +/** + * @file Dispatch_Deferrer.h + * + * $Id$ + * + * @author Bryan Thrall (thrall@cse.wustl.edu) + * + */ + +#ifndef DISPATCH_DEFERRER_H +#define DISPATCH_DEFERRER_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "kokyu_export.h" +#include "Kokyu_defs.h" +#include "ace/Event_Handler.h" +#include "ace/Thread_Mutex.h" +#include "ace/Synch_T.h" +#include "ace/Message_Block.h" +#include "ace/Message_Queue.h" +#include "ace/Reactor.h" +#include "ace/Map.h" + +namespace Kokyu +{ + +class Dispatch_Task; //forward decl +class Dispatch_Queue_Item; //forward decl + +/** + * @class Dispatch_Deferrer + * + * @brief Part of the Release Guard protocol. When a Dispatch_Command + * needs to be dispatched later rather than when dispatch_i() is + * called on the Default_Dispatcher_Impl, it is passed to this + * object. When the appropriate time to dispatch the Dispatch_Command + * comes (last release time + period), this object calls enqueue() on + * the Dispatcher_Task. + */ +class Dispatch_Deferrer : public ACE_Event_Handler +{ + public: + Dispatch_Deferrer(); + //Default constructor + + ~Dispatch_Deferrer(); + //Destructor + + int init(const Dispatch_Deferrer_Attributes& attr); + + int dispatch (Dispatch_Queue_Item *qitem); + + virtual int handle_timeout (const ACE_Time_Value ¤t_time, + const void *act = 0); + //TODO: what if need higher resolution timers? + + private: + ACE_Deadline_Message_Strategy msg_strat_; + + ///Stores the Dispatch_Commands in earliest-release-time order, + ///until they are dispatched. I decided to use an + ///ACE_Dynamic_Message_Queue because it supports deadline + ///ordering. This decision is also good because we can simply store + ///the Dispatch_Queue_Item given to us by the + ///Default_Dispatcher_Impl rather than allocate some structure to + ///hold the Dispatch_Command and QoSDescriptor. + ACE_Dynamic_Message_Queue<ACE_SYNCH> rgq_; + + //Stores timer_ids from the Reactor (longs) using the + //Dispatch_Queue_Item the timer is for as the key. Used to + //cancel timers if they expire and are enqueued before the + //callback happens. + typedef ACE_Map_Manager<Dispatch_Queue_Item*,long,ACE_Thread_Mutex> Timer_Map; + + Timer_Map timers_; + + ///Manages timers for the Dispatch_Commands + ACE_Reactor react_; + + Dispatcher_Task* task_; +}; + +} //namespace Kokyu + +#if defined (__ACE_INLINE__) +#include "Dispatch_Deferrer.i" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif //DISPATCH_DEFERRER_H diff --git a/Kokyu/Dispatch_Deferrer.i b/Kokyu/Dispatch_Deferrer.i new file mode 100644 index 00000000000..315afce5598 --- /dev/null +++ b/Kokyu/Dispatch_Deferrer.i @@ -0,0 +1,29 @@ +// $Id$ + +namespace Kokyu +{ + +ACE_INLINE +Dispatch_Deferrer_Attributes::Dispatch_Deferrer_Attributes() +{ +} + +ACE_INLINE +Dispatch_Deferrer::Dispatch_Deferrer() + : msg_strat_() + , rgq_(this->msg_strat_) + , timers_() + , react_() + , task_(0) +{ +} + +ACE_INLINE +Dispatch_Deferrer::~Dispatch_Deferrer() +{ + this->react_.close(); + + this->timers_.close(); +} + +} //namespace Kokyu diff --git a/Kokyu/Kokyu.dsui b/Kokyu/Kokyu.dsui new file mode 100644 index 00000000000..ab1e86740a1 --- /dev/null +++ b/Kokyu/Kokyu.dsui @@ -0,0 +1,37 @@ +# DSRT Dispatcher Impl (DSRT_Dispatcher_Impl.cpp) +DSTRM_EVENT DSRT_DISPATCH_IMPL 10 INIT2 0 "Initialize Dispatcher object" print_string + +# Dispatcher Task (Dispatcher_Task.cpp) +DSTRM_EVENT DISP_TASK 9 EVENT_DEFERRED 3 "Time event is deferred" print_string +DSTRM_EVENT DISP_TASK 9 EVENT_FINISHED_DISPATCHING 2 "End time of dispatching event" print_string +DSTRM_EVENT DISP_TASK 9 EVENT_START_DISPATCHING 1 "Start time of actually dispatching event" print_string +DSTRM_EVENT DISP_TASK 9 EVENT_DEQUEUED 0 "Time of event duqueue" print_string + +# Dispatch Deferrer (Dispatch_Deferrer.cpp) +DSTRM_EVENT DISP_DEFERRER 8 EVENT_DEFERRED_DEQUEUE 1 "Enqueue event in dispatch queue" print_string +DSTRM_EVENT DISP_DEFERRER 8 EVENT_DEFERRED_ENQUEUE 0 "Buffer event until timer expires" print_string + +# DSRT DIRECT Dispatcher (DSRT_DIRECT_Dispatcher_Impl_T.cpp) +DSTRM_EVENT DSRT_DIRECT_DISPATCH 7 SCHEDULE_EXIT 1 "Exit Schedule_i" print_string +DSTRM_EVENT DSRT_DIRECT_DISPATCH 7 SCHEDULE_ENTER 0 "Enter Schedule_i" print_string + +# DSRT CV Dispatcher (DSRT_CV_Dispatcher_Impl_T.cpp) +DSTRM_EVENT DSRT_CV_DISPATCH 6 INIT 13 "Enter DSRT_Dispatcher_Impl init" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 SHUTDOWN 12 "Enter shutdown_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 CANCEL_SCHEDULE_END 11 "Exit cancel_schedule_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 CANCEL_SCHEDULE_START 10 "Enter cancel_schedule_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 UPDATE_SCHEDULE_END 9 "Exit update_schedule_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 UPDATE_SCHEDULE_START 8 "Enter update_schedule_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 RELEASE_GUARD_END 7 "Exit release_guard_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 RELEASE_GUARD_START 6 "Enter release_guard_i function" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 INIT_I 5 "Initialization" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 NONRG_EVENT_RELEASED 4 "Event release time on the server side" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 RG_DELAYED_EVENT_RELEASED 3 "Event delayed by release guard release time on the server side" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 RG_EVENT_RELEASED 2 "Release guard Event release time on the server side" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 SCHEDULE_EXIT 1 "Exit Schedule_i" print_string +DSTRM_EVENT DSRT_CV_DISPATCH 6 SCHEDULE_ENTER 0 "Enter Schedule_i" print_string + +# DSRT_Dispatcher (Kokyu_dsrt.cpp) +DSTRM_EVENT DSRT_DISPATCH 5 CREATE_DSRT_DISPATCH_SCHED_END 2 "Done creating appropriate Scheduler" print_string +DSTRM_EVENT DSRT_DISPATCH 5 CREATE_DSRT_DISPATCH_SCHED_START 1 "Create appropriate Scheduler" print_string +DSTRM_EVENT DSRT_DISPATCH 5 SCHEDULE 0 "Schedule task" print_string diff --git a/Kokyu/kokyu_config.h b/Kokyu/kokyu_config.h new file mode 100644 index 00000000000..4eab747376e --- /dev/null +++ b/Kokyu/kokyu_config.h @@ -0,0 +1,10 @@ +/* $Id$ */ +#ifndef KOKYU_CONFIG_H +#define KOKYU_CONFIG_H + +#define CONFIG_DSTREAM_DSRT_DISPATCH +#define CONFIG_DSTREAM_DSRT_CV_DISPATCH +#define CONFIG_DSTREAM_DSRT_DIRECT_DISPATCH +#define CONFIG_DSTREAM_DSRT_DISPATCH_IMPL + +#endif /* KOKYU_CONFIG_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp new file mode 100644 index 00000000000..782346a1b7e --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.cpp @@ -0,0 +1,859 @@ +//$Id$ + +#include "EDF_Scheduler.h" +#include "Kokyu_qosC.h" +#include "utils.h" +#include "tao/RTScheduling/Request_Interceptor.h" +#include "tao/ORB_Constants.h" + +#include "edf_scheduler_config.h" +#include "edf_sched_dsui_families.h" +#include <dsui.h> + +#include <iostream> +using namespace std; + +EDF_Scheduling::SchedulingParameter +EDF_Sched_Param_Policy::value (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->value_; +} + +void +EDF_Sched_Param_Policy::value (const EDF_Scheduling::SchedulingParameter& value ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->value_ = value; +} + +EDF_Scheduler::EDF_Scheduler (CORBA::ORB_ptr orb, + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type, + int ace_sched_policy, + int ace_sched_scope) + : orb_ (orb), + disp_impl_type_ (disp_impl_type), + ace_sched_policy_ (ace_sched_policy), + ace_sched_scope_ (ace_sched_scope) +{ + ACE_DECLARE_NEW_ENV; + + Kokyu::DSRT_ConfigInfo config; + + config.impl_type_ = this->disp_impl_type_; + config.sched_policy_ = ace_sched_policy_; + config.sched_scope_ = ace_sched_scope_; + + Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>::DSRT_Dispatcher_Auto_Ptr + tmp( Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>:: + create_DSRT_dispatcher (config) ); + DSUI_EVENT_LOG (EDF_SCHED_FAM, CONSTRUCTOR, 0, 0, NULL); + + kokyu_dispatcher_ = tmp; + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->current_ = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + IOP::CodecFactory_var codec_factory; + CORBA::Object_var obj = + orb->resolve_initial_references ("CodecFactory" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil(obj.in ())) + { + ACE_ERROR ((LM_ERROR, "Nil Codec factory\n")); + } + else + { + codec_factory = IOP::CodecFactory::_narrow (obj.in ()); + } + + IOP::Encoding encoding; + encoding.format = IOP::ENCODING_CDR_ENCAPS; + encoding.major_version = 1; + encoding.minor_version = 2; + + codec_ = codec_factory->create_codec (encoding); +} + +EDF_Scheduler::~EDF_Scheduler (void) +{ +} + +void +EDF_Scheduler::shutdown (void) +{ + kokyu_dispatcher_->shutdown (); + DSUI_EVENT_LOG (EDF_SCHED_FAM, DISPATCHER_SHUTDOWN, 0, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "kokyu DSRT dispatcher shutdown\n")); +} + +EDF_Scheduling::SchedulingParameterPolicy_ptr +EDF_Scheduler::create_scheduling_parameter (const EDF_Scheduling::SchedulingParameter & value ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + /* MEASURE: Time to create scheduling parameter */ + DSUI_EVENT_LOG (EDF_SCHED_FAM, CREATE_SCHED_PARAM, 0, 0, NULL); + + EDF_Scheduling::SchedulingParameterPolicy_ptr sched_param_policy; + ACE_NEW_THROW_EX (sched_param_policy, + EDF_Sched_Param_Policy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + + sched_param_policy->value (value); + + return sched_param_policy; +} + + +void +EDF_Scheduler::begin_new_scheduling_segment (const RTScheduling::Current::IdType &guid, + const char *, + CORBA::Policy_ptr sched_policy, + CORBA::Policy_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)) +{ +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):EDF_Scheduler::begin_new_scheduling_segment enter\n")); +#endif + + //#ifdef KOKYU_DSRT_LOGGING + int int_guid; + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + // ACE_DEBUG ((LM_DEBUG, "(%t|%T): guid is %d\n", int_guid)); + //#endif + + DSUI_EVENT_LOG (EDF_SCHED_FAM, BEGIN_SCHED_SEGMENT_START, int_guid, 0, NULL); + EDF_Scheduler_Traits::QoSDescriptor_t qos; + EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = + EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); + + EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); + + qos.deadline_ = sched_param->deadline; + qos.importance_ = sched_param->importance; + + kokyu_dispatcher_->schedule (guid, qos); + + DSUI_EVENT_LOG (EDF_SCHED_FAM, BEGIN_SCHED_SEGMENT_END, int_guid, 0, NULL); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):EDF_Scheduler::begin_new_scheduling_segment exit\n")); +#endif +} + + +void +EDF_Scheduler::begin_nested_scheduling_segment (const RTScheduling::Current::IdType &guid, + const char *name, + CORBA::Policy_ptr sched_param, + CORBA::Policy_ptr implicit_sched_param + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, BEGIN_NESTED_SCHED_SEGMENT, int_guid, 0, NULL); + this->begin_new_scheduling_segment (guid, + name, + sched_param, + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +EDF_Scheduler::update_scheduling_segment (const RTScheduling::Current::IdType& guid, + const char* name, + CORBA::Policy_ptr sched_policy, + CORBA::Policy_ptr implicit_sched_param + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)) +{ + ACE_UNUSED_ARG ((name)); + ACE_UNUSED_ARG ((implicit_sched_param)); + + int int_guid ; + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, BEGIN_UPDATE_SCHED_SEGMENT, int_guid, 0, NULL); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): update_sched_seg::guid is %d\n", int_guid)); +#endif + + EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = + EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); + + EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); + EDF_Scheduler_Traits::QoSDescriptor_t qos; + + qos.deadline_ = sched_param->deadline; + qos.importance_ = sched_param->importance; + + kokyu_dispatcher_->update_schedule (guid, qos); + DSUI_EVENT_LOG (EDF_SCHED_FAM, END_UPDATE_SCHED_SEGMENT, int_guid, 0, NULL); +} + +void +EDF_Scheduler::end_scheduling_segment (const RTScheduling::Current::IdType &guid, + const char * + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + int int_guid; + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T) call to end_sched_segment for guid %d\n", int_guid)); +#endif + + DSUI_EVENT_LOG (EDF_SCHED_FAM, END_SCHED_SEGMENT, int_guid, 0, NULL); + kokyu_dispatcher_->cancel_schedule (guid); +} + +void +EDF_Scheduler::end_nested_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char *, + CORBA::Policy_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, END_NESTED_SCHED_SEGMENT, int_guid, 0, NULL); +} + + +void +EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + this->current_->id ()->get_buffer (), + this->current_->id ()->length ()); + + DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_CLIENT_SCHED_TIME, int_guid, 0, NULL); + Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; + + CORBA::String_var operation = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): send_request " + "from \"%s\"\n", + operation.in ())); +#endif + + // Make the context to send the context to the target + IOP::ServiceContext sc; + sc.context_id = Client_Interceptor::SchedulingInfo; + + CORBA::Policy_ptr sched_policy = + this->current_->scheduling_parameter(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long importance; + TimeBase::TimeT deadline; + TimeBase::TimeT period; + int task_id=-1; + + if (CORBA::is_nil (sched_policy)) + { + //24 hrs from now - infinity + ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); + deadline = deadline_tv.sec () * 10000000 + deadline_tv.usec () * 10; //100s of nanoseconds for TimeBase::TimeT + importance = 0; + period = 0; //set period 0 as default. +// task_id = ID_BEGIN ++; + } + else + { + EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = + EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); + + EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); + deadline = sched_param->deadline; + importance = sched_param->importance; + period = sched_param->period; + task_id = sched_param->task_id; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): send_request guid = %d\n", + int_guid)); +#endif + } + //Fill the guid in the SC Qos struct + sc_qos.guid.length (this->current_->id ()->length ()); + guid_copy (sc_qos.guid, *(this->current_->id ())); + sc_qos.deadline = deadline; + sc_qos.importance = importance; + sc_qos.task_id = task_id; + sc_qos.period = period; + CORBA::Any sc_qos_as_any; + sc_qos_as_any <<= sc_qos; + + sc.context_data = + ACE_reinterpret_cast(IOP::ServiceContext:: + _tao_seq_CORBA_Octet_ &, + *codec_->encode (sc_qos_as_any)); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t|%T): send_request : about to add sched SC\n"))); +#endif + + // Add this context to the service context list. + ri->add_request_service_context (sc, 0 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%t|%T): send_request : ") + ACE_LIB_TEXT ("about to call scheduler to inform block\n") + )); +#endif + + DSUI_EVENT_LOG (EDF_SCHED_FAM, CALL_KOKYU_DISPATCH_UPDATE_SCHEDULE, + int_guid, 0, NULL); + kokyu_dispatcher_->update_schedule (*(this->current_->id ()), + Kokyu::BLOCK); + DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_KOKYU_DISPATCH_UPDATE_SCHEDULE, + int_guid,0,NULL); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%t|%T): send_request interceptor done\n"))); +#endif + DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_CLIENT_SCHED_TIME, int_guid, 0, NULL); +} + +void +EDF_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri, + RTScheduling::Current::IdType_out guid_out, + CORBA::String_out /*name*/, + CORBA::Policy_out sched_param_out, + CORBA::Policy_out /*implicit_sched_param_out*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + + Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr; + RTScheduling::Current::IdType guid; + int int_guid; + + DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SERVER_SCHED_TIME, 0, 0, NULL); + + + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T):entered EDF_Scheduler::receive_request\n")); +#endif + + + CORBA::String_var operation = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): receive_request from " + "\"%s\"\n", + operation.in ())); +#endif + + // Ignore the "_is_a" operation since it may have been invoked + // locally on the server side as a side effect of another call, + // meaning that the client hasn't added the service context yet. + if (ACE_OS::strcmp ("_is_a", operation.in ()) == 0) + return; + + IOP::ServiceContext_var sc = + ri->get_request_service_context (Server_Interceptor::SchedulingInfo + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long importance; + TimeBase::TimeT deadline; + TimeBase::TimeT period; + CORBA::Long task_id=-1; + + if (sc.ptr () == 0) + { + //Since send_request will add an QoS for any request, why can this case happen? + //24 hrs from now - infinity + ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); + deadline = deadline_tv.sec ()*1000000 + deadline_tv.usec ()*10; //100s of nanoseconds for TimeBase::TimeT + importance = 0; + period = 0; +// task_id = ID_BEGIN ++; + } + else + { + CORBA::OctetSeq oc_seq = CORBA::OctetSeq (sc->context_data.length (), + sc->context_data.length (), + sc->context_data.get_buffer (), + 0); + CORBA::Any sc_qos_as_any; + sc_qos_as_any = *codec_->decode (oc_seq); + //Don't store in a _var, since >>= returns a pointer to an + //internal buffer and we are not supposed to free it. + sc_qos_as_any >>= sc_qos_ptr; + + deadline = sc_qos_ptr->deadline; + importance = sc_qos_ptr->importance; + period = sc_qos_ptr->period; + task_id = sc_qos_ptr->task_id; + + guid.length (sc_qos_ptr->guid.length ()); + guid_copy (guid, sc_qos_ptr->guid); + + ACE_NEW (guid_out.ptr (), + RTScheduling::Current::IdType); + guid_out.ptr ()->length (guid.length ()); + *(guid_out.ptr ()) = guid; + + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): Importance = %d, guid = %d " + "in recvd service context\n", + importance, + int_guid)); +#endif + + EDF_Scheduling::SchedulingParameter sched_param; + sched_param.importance = importance; + sched_param.deadline = deadline; + sched_param.period = period; + sched_param.task_id = task_id; + sched_param_out = this->create_scheduling_parameter (sched_param); + } + + EDF_Scheduler_Traits::QoSDescriptor_t qos; + qos.importance_ = importance; + qos.deadline_ = deadline; + qos.period_ = period; + qos.task_id_ = task_id; + + DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SERVER_DISPATCH_SCHEDULE, int_guid, 0, NULL); + +/*DTTIME: + record the entering dispatcher time on the server side. + Tenth Time. +*/ +#ifdef KOKYU_HAS_RELEASE_GUARD + this->kokyu_dispatcher_->release_guard (guid, qos); +#else + this->kokyu_dispatcher_->schedule (guid, qos); +#endif +/*DTTIME: + record the leaving dispatcher time on the server side. + Eleventh Time. +*/ + + DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_SERVER_DISPATCH_SCHEDULE, int_guid, 0, NULL); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): receive_request interceptor done\n")); +#endif + + DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_SERVER_SCHED_TIME, 0, 0, NULL); +} + +void +EDF_Scheduler::send_poll (PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + this->current_->id ()->get_buffer (), + this->current_->id ()->length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_POLL, int_guid, 0, NULL); +} + +void +EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + this->current_->id ()->get_buffer (), + this->current_->id ()->length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SEND_REPLY, int_guid, 0, NULL); + + Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; + + CORBA::String_var operation = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): send_reply from \"%s\"\n", + ri->operation ())); +#endif + + // Make the context to send the context to the target + IOP::ServiceContext sc; + sc.context_id = Server_Interceptor::SchedulingInfo; + + + CORBA::Long importance; + TimeBase::TimeT deadline; + + CORBA::Policy_ptr sched_policy = + this->current_->scheduling_parameter(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (sched_policy)) + { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): sched_policy nil.\n ")); +#endif + //24 hrs from now - infinity + ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); + deadline = deadline_tv.sec ()*1000000 + deadline_tv.usec ()*10; //100s of nanoseconds for TimeBase::TimeT + importance = 0; + } + else + { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):sched_policy not nil. ", + "sched params set\n")); +#endif + EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = + EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); + EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); + + + sc_qos.guid.length (this->current_->id ()->length ()); + guid_copy (sc_qos.guid, *(this->current_->id ())); + + deadline = sched_param->deadline; + importance = sched_param->importance; + sc_qos.deadline = deadline; + sc_qos.importance = importance; + + CORBA::Any sc_qos_as_any; + sc_qos_as_any <<= sc_qos; + + sc.context_data = ACE_reinterpret_cast( + IOP::ServiceContext:: + _tao_seq_CORBA_Octet_ &, + *codec_->encode (sc_qos_as_any)); + + // Add this context to the service context list. + ri->add_reply_service_context (sc, 1 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T):reply sc added\n")); +#endif + } + + kokyu_dispatcher_->update_schedule (*(this->current_->id ()), + Kokyu::BLOCK); + + DSUI_EVENT_LOG (EDF_SCHED_FAM, EXIT_SEND_REPLY, int_guid, 0, NULL); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_reply interceptor done\n")); +#endif +} + +void +EDF_Scheduler::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + this->current_->id ()->get_buffer (), + this->current_->id ()->length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_EXCEPTION, int_guid, 0, NULL); + + send_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +EDF_Scheduler::send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + int int_guid; + ACE_OS::memcpy (&int_guid, + this->current_->id ()->get_buffer (), + this->current_->id ()->length ()); + DSUI_EVENT_LOG (EDF_SCHED_FAM, SEND_OTHER, int_guid, 0, NULL); + + send_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +EDF_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + int int_guid; + + DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_RECEIVE_REPLY, 0, 0, NULL); + + RTScheduling::Current::IdType guid; + + CORBA::String_var operation = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var target = ri->target (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_CString opname = operation.in (); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):receive_reply from " + "\"%s\"\n", + opname.c_str ())); +#endif + + // Check that the reply service context was received as + // expected. + + IOP::ServiceContext_var sc = + ri->get_reply_service_context (Client_Interceptor::SchedulingInfo + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Long importance; + TimeBase::TimeT deadline; + + if (sc.ptr () == 0) + { + ACE_DEBUG ((LM_DEBUG, "service context was not filled\n")); + //24 hrs from now - infinity + ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); + deadline = deadline_tv.sec ()*1000000 + deadline_tv.usec ()*10; //100s of nanoseconds for TimeBase::TimeT + importance = 0; + } + else + { + CORBA::OctetSeq oc_seq = CORBA::OctetSeq (sc->context_data.length (), + sc->context_data.length (), + sc->context_data.get_buffer (), + 0); + + //Don't store in a _var, since >>= returns a pointer to an internal buffer + //and we are not supposed to free it. + Kokyu::Svc_Ctxt_DSRT_QoS* sc_qos_ptr; + CORBA::Any sc_qos_as_any; + sc_qos_as_any = *codec_->decode (oc_seq); + sc_qos_as_any >>= sc_qos_ptr; + + deadline = sc_qos_ptr->deadline; + importance = sc_qos_ptr->importance; + + guid.length (sc_qos_ptr->guid.length ()); + guid_copy (guid, sc_qos_ptr->guid); + + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):Importance = %d in recvd service context\n", + importance)); + } + + ACE_OS::memcpy (&int_guid, + guid.get_buffer (), + guid.length ()); + + EDF_Scheduler_Traits::QoSDescriptor_t qos; + qos.deadline_ = qos.importance_ = importance; + qos.deadline_ = deadline; + this->kokyu_dispatcher_->schedule (guid, qos); + DSUI_EVENT_LOG (EDF_SCHED_FAM, EXIT_RECEIVE_REPLY, int_guid, 0, NULL); +} + +void +EDF_Scheduler::receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + DSUI_EVENT_LOG (EDF_SCHED_FAM, RECEIVE_EXCEPTION, 0, 0, NULL); + + receive_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +EDF_Scheduler::receive_other (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + + DSUI_EVENT_LOG (EDF_SCHED_FAM, RECEIVE_OTHER, 0, 0, NULL); + +//Otherwise Segmentation fault when oneway call happens. +/* receive_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +*/ +} + +void +EDF_Scheduler::cancel (const RTScheduling::Current::IdType & + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CORBA::PolicyList* +EDF_Scheduler::scheduling_policies (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +void +EDF_Scheduler::scheduling_policies (const CORBA::PolicyList & + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CORBA::PolicyList* +EDF_Scheduler::poa_policies (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +char * +EDF_Scheduler::scheduling_discipline_name (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +RTScheduling::ResourceManager_ptr +EDF_Scheduler::create_resource_manager (const char *, + CORBA::Policy_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +void +EDF_Scheduler::set_scheduling_parameter (PortableServer::Servant &, + const char *, + CORBA::Policy_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>; +template class Kokyu::DSRT_Dispatcher<EDF_Scheduler_Traits>; +template class Kokyu::DSRT_Dispatcher_Impl<EDF_Scheduler_Traits>; +template class Kokyu::DSRT_Direct_Dispatcher_Impl<EDF_Scheduler_Traits>; +template class Kokyu::DSRT_CV_Dispatcher_Impl<EDF_Scheduler_Traits>; +template class Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>; +template class Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>; +template class Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Manager_Ex<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *, Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>::Guid_Hash, ACE_Equal_To<EDF_Scheduler_Traits::Guid_t>, ACE_Null_Mutex>; + +template class ACE_RB_Tree<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>; + +template class ACE_RB_Tree_Iterator<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Entry<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *>; + +template class ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> >; + +template class Kokyu::EDF_Comparator<EDF_Scheduler_Traits::QoSDescriptor_t>; + +template class ACE_Hash_Map_Iterator_Base_Ex<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *, Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>::Guid_Hash, ACE_Equal_To<EDF_Scheduler_Traits::Guid_t>, ACE_Null_Mutex>; + +template class ACE_RB_Tree_Reverse_Iterator<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>; + +template class ACE_RB_Tree_Iterator_Base<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>; + +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::DSRT_Dispatcher<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::DSRT_Dispatcher_Impl<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::DSRT_Direct_Dispatcher_Impl<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::DSRT_CV_Dispatcher_Impl<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> +#pragma instantiate Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits> + +#pragma instantiate Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex> + + +#pragma instantiate ACE_Hash_Map_Manager_Ex<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *, Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>::Guid_Hash, ACE_Equal_To<EDF_Scheduler_Traits::Guid_t>, ACE_Null_Mutex> + +#pragma instantiate ACE_RB_Tree<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex> + +#pragma instantiate ACE_RB_Tree_Iterator<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex> + +ACE_Hash_Map_Entry<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Koky\ +u::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<\ +EDF_Scheduler_Traits> > + +#pragma instantiate ACE_Hash_Map_Entry<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *> + +#pragma instantiate ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > + +#pragma instantiate Kokyu::EDF_Comparator<EDF_Scheduler_Traits::QoSDescriptor_t> + +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<EDF_Scheduler_Traits::Guid_t, ACE_RB_Tree_Node<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits> > *, Kokyu::Sched_Ready_Queue<EDF_Scheduler_Traits, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex>::Guid_Hash, ACE_Equal_To<EDF_Scheduler_Traits::Guid_t>, ACE_Null_Mutex> + +#pragma instantiate ACE_RB_Tree_Reverse_Iterator<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex> + +#pragma instantiate ACE_RB_Tree_Iterator_Base<Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::DSRT_Dispatch_Item_var<EDF_Scheduler_Traits>, Kokyu::Comparator_Adapter_Generator<EDF_Scheduler_Traits>::MoreEligible, ACE_Null_Mutex> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.dsui b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.dsui new file mode 100644 index 00000000000..5cefd8aef6a --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.dsui @@ -0,0 +1,30 @@ +# EDF_SCHED (EDF_Scheduler.cpp) +DSTRM_EVENT EDF_SCHED 4 CONSTRUCTOR 27 "Dispatcher created in constructor" print_string +DSTRM_EVENT EDF_SCHED 4 RECEIVE_OTHER 26 "Enter receive_other" print_string +DSTRM_EVENT EDF_SCHED 4 RECEIVE_EXCEPTION 25 "Enter receive_exception" print_string +DSTRM_EVENT EDF_SCHED 4 EXIT_RECEIVE_REPLY 24 "Exit receive_reply" print_string +DSTRM_EVENT EDF_SCHED 4 ENTER_RECEIVE_REPLY 23 "Enter receive_reply" print_string +DSTRM_EVENT EDF_SCHED 4 SEND_OTHER 22 "Enter send_other" print_string +DSTRM_EVENT EDF_SCHED 4 SEND_EXCEPTION 21 "Enter send_exception" print_string +DSTRM_EVENT EDF_SCHED 4 EXIT_SEND_REPLY 20 "Exit send_reply" print_string +DSTRM_EVENT EDF_SCHED 4 ENTER_SEND_REPLY 19 "Enter send_reply" print_string +DSTRM_EVENT EDF_SCHED 4 SEND_POLL 18 "Enter send_poll" print_string +DSTRM_EVENT EDF_SCHED 4 END_NESTED_SCHED_SEGMENT 17 "End nested Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 END_SCHED_SEGMENT 16 "Enter end_scheduling_segment" print_string +DSTRM_EVENT EDF_SCHED 4 END_UPDATE_SCHED_SEGMENT 15 "End update Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 BEGIN_UPDATE_SCHED_SEGMENT 14 "Start update Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 BEGIN_NESTED_SCHED_SEGMENT 13 "Start next Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 LEAVE_SERVER_DISPATCH_SCHEDULE 12 "Record the exiting dispatcher time on the server side" print_string +DSTRM_EVENT EDF_SCHED 4 ENTER_SERVER_DISPATCH_SCHEDULE 11 "Record the entering dispatcher time on the server side" print_string +DSTRM_EVENT EDF_SCHED 4 LEAVE_SERVER_SCHED_TIME 10 "Record the exiting scheduler time on the server side" print_string +DSTRM_EVENT EDF_SCHED 4 ENTER_SERVER_SCHED_TIME 9 "Record the entering scheduler time on the server side" print_string +DSTRM_EVENT EDF_SCHED 4 LEAVE_CLIENT_SCHED_TIME 8 "Record the leaving scheduler time on the client side" print_string +DSTRM_EVENT EDF_SCHED 4 LEAVE_KOKYU_DISPATCH_UPDATE_SCHEDULE 7 "Leaving dispatcher time on the client side" print_string +DSTRM_EVENT EDF_SCHED 4 CALL_KOKYU_DISPATCH_UPDATE_SCHEDULE 6 "Entering dispatcher time on the client side" print_string +DSTRM_EVENT EDF_SCHED 4 ENTER_CLIENT_SCHED_TIME 5 "Point which records the entering scheduler time on the client side" print_string +DSTRM_EVENT EDF_SCHED 4 DISPATCHER_SHUTDOWN 4 "Kokyu DSRT Dispatcher shutdown" print_string +DSTRM_EVENT EDF_SCHED 4 CREATE_SCHED_PARAM 3 "Create Scheduling parameter" print_string +DSTRM_EVENT EDF_SCHED 4 BEGIN_SCHED_SEGMENT_START 2 "Start Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 BEGIN_SCHED_SEGMENT_END 1 "End Schedule segment" print_string +DSTRM_EVENT EDF_SCHED 4 KOKYU_SCHED_START 0 "Start Kokyu Schedule call" print_string + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.h b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.h new file mode 100644 index 00000000000..ca3f4263c43 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduler.h @@ -0,0 +1,212 @@ +//$Id$ + +#ifndef EDF_SCHEDULER_H +#define EDF_SCHEDULER_H + +#include "tao/RTScheduling/RTScheduler.h" +#include "EDF_SchedulingC.h" +#include "Kokyu_dsrt.h" +#include "Kokyu_dsrt_schedulers_export.h" +#include "tao/LocalObject.h" +#include "ace/Reactor.h" +#include "tao/ORB_Core.h" + +struct EDF_Scheduler_Traits +{ + typedef RTScheduling::Current::IdType Guid_t; + + typedef TimeBase::TimeT Time_t; + + struct _QoSDescriptor_t + { + typedef long Importance_t; + + typedef TimeBase::TimeT Time_t; + + Importance_t importance_; + Time_t deadline_; + Time_t period_; + int task_id_; + }; + + typedef _QoSDescriptor_t QoSDescriptor_t; + + typedef Kokyu::EDF_Comparator<QoSDescriptor_t> QoSComparator_t; + + class _Guid_Hash + { + public: + u_long operator () (const Guid_t& id) + { + return ACE::hash_pjw ((const char *) id.get_buffer (), + id.length ()); + } + }; + typedef _Guid_Hash Guid_Hash; +}; + +class Kokyu_DSRT_Schedulers_Export EDF_Sched_Param_Policy: +public EDF_Scheduling::SchedulingParameterPolicy, + public TAO_Local_RefCounted_Object +{ + public: + + EDF_Scheduling::SchedulingParameter value (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void value (const EDF_Scheduling::SchedulingParameter & value + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + EDF_Scheduling::SchedulingParameter value_; +}; + +class Kokyu_DSRT_Schedulers_Export EDF_Scheduler: +public EDF_Scheduling::Scheduler, +public TAO_Local_RefCounted_Object +{ + public: + + EDF_Scheduler (CORBA::ORB_ptr orb, + Kokyu::DSRT_Dispatcher_Impl_t, + int ace_sched_policy, + int ace_sched_scope); + + ~EDF_Scheduler (void); + + + virtual EDF_Scheduling::SchedulingParameterPolicy_ptr + create_scheduling_parameter (const EDF_Scheduling::SchedulingParameter & value + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (void); + + virtual void begin_new_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char * name, + CORBA::Policy_ptr sched_param, + CORBA::Policy_ptr implicit_sched_param + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)); + + virtual void begin_nested_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char * name, + CORBA::Policy_ptr sched_param, + CORBA::Policy_ptr implicit_sched_param + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)); + + virtual void update_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char * name, + CORBA::Policy_ptr sched_param, + CORBA::Policy_ptr implicit_sched_param + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE)); + + virtual void end_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char * name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void end_nested_scheduling_segment (const RTScheduling::Current::IdType & guid, + const char * name, + CORBA::Policy_ptr outer_sched_param + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_request (PortableInterceptor::ServerRequestInfo_ptr ri, + RTScheduling::Current::IdType_out guid, + CORBA::String_out name, + CORBA::Policy_out sched_param, + CORBA::Policy_out implicit_sched_param + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void cancel (const RTScheduling::Current::IdType & guid + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::PolicyList * scheduling_policies (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void scheduling_policies (const CORBA::PolicyList & scheduling_policies + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::PolicyList * poa_policies (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual char * scheduling_discipline_name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual RTScheduling::ResourceManager_ptr create_resource_manager (const char * name, + CORBA::Policy_ptr scheduling_parameter + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void set_scheduling_parameter (PortableServer::Servant & resource, + const char * name, + CORBA::Policy_ptr scheduling_parameter + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>::DSRT_Dispatcher_Auto_Ptr + kokyu_dispatcher_; + private: + CORBA::ORB_var orb_; + IOP::Codec_var codec_; + RTScheduling::Current_var current_; +// Kokyu::DSRT_Dispatcher_Factory<EDF_Scheduler_Traits>::DSRT_Dispatcher_Auto_Ptr +// kokyu_dispatcher_; + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type_; + int ace_sched_policy_; + int ace_sched_scope_; +}; + +//extern int ID_BEGIN; + +#endif //EDF_SCHEDULER_H diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduling.pidl b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduling.pidl new file mode 100644 index 00000000000..4f16c754a6e --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_Scheduling.pidl @@ -0,0 +1,64 @@ +// $Id$ + +/** + * @file EDF_Scheduling.pidl + * + * EDF_Scheduling.pidl,v 1.2 2003/10/08 13:26:32 venkita Exp + * + * @brief Pre-compiled IDL source to help with the service context + * propagation of dynamic scheduling parameters using Kokyu + * + * This file was used to generate the code in EDF_SchedulingC.{h,i,cpp}. + * The steps to regenerate the code are as follows: + * + * 1. Run the tao_idl compiler on the pidl file. The command used for + * this is: + * + * tao_idl -I $TAO_ROOT -Ge 1 + * -Wb,export_macro=Kokyu_DSRT_Schedulers_Export + * -Wb,export_include=Kokyu_dsrt_schedulers_export.h + * + * + * 2. Then apply the patches in EDF_SchedulingC.h.diff to the generated code. + * The patch will replace the inclusion of RTCORBAC.h and RTSchedulerC.h + * with RTCORBA.h and RTScheduler.h respectively. + * + * Apply patches using the following command: + * + * patch < EDF_SchedulingC.h.diff + * + * Note: The diff was generated in the following way: + * + * Run the idl compiler as in step 1. + * cp EDF_SchedulingC.h EDF_SchedulingC.h.orig + * Modify EDF_SchedulingC.h with changes described in step 2. + * diff -wBbu EDF_SchedulingC.h.orig EDF_SchedulingC.h > EDF_SchedulingC.h.diff + * + */ + +#include <tao/RTScheduling/RTScheduler.pidl> +#include <tao/RTCORBA/RTCORBA.pidl> + +module EDF_Scheduling +{ + struct SchedulingParameter + { + TimeBase::TimeT deadline; + long importance; + TimeBase::TimeT period; + long task_id; + }; + + local interface SchedulingParameterPolicy + : CORBA::Policy + { + attribute SchedulingParameter value; + }; + + local interface Scheduler : RTScheduling::Scheduler + { + SchedulingParameterPolicy + create_scheduling_parameter + (in SchedulingParameter value); + }; +}; diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.cpp b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.cpp new file mode 100644 index 00000000000..b9640a4c8c7 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.cpp @@ -0,0 +1,701 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be/be_codegen.cpp:302 + + +#include "EDF_SchedulingC.h" +#include "tao/Typecode.h" +#include "tao/Any_Impl_T.h" +#include "tao/Any_Dual_Impl_T.h" +#include "ace/OS_NS_string.h" + +#if defined (__BORLANDC__) +#pragma option -w-rvl -w-rch -w-ccc -w-aus -w-sig +#endif /* __BORLANDC__ */ + +#if !defined (__ACE_INLINE__) +#include "EDF_SchedulingC.i" +#endif /* !defined INLINE */ + +// TAO_IDL - Generated from +// be/be_visitor_arg_traits.cpp:60 + +// Arg traits specializations. +namespace TAO +{ +}; + +// TAO_IDL - Generated from +// be/be_visitor_typecode/typecode_defn.cpp:284 + +static const CORBA::Long _oc_EDF_Scheduling_SchedulingParameter[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 43, + ACE_NTOHL (0x49444c3a), + ACE_NTOHL (0x4544465f), + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c69), + ACE_NTOHL (0x6e672f53), + ACE_NTOHL (0x63686564), + ACE_NTOHL (0x756c696e), + ACE_NTOHL (0x67506172), + ACE_NTOHL (0x616d6574), + ACE_NTOHL (0x65723a31), + ACE_NTOHL (0x2e300000), // repository ID = IDL:EDF_Scheduling/SchedulingParameter:1.0 + 20, + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c69), + ACE_NTOHL (0x6e675061), + ACE_NTOHL (0x72616d65), + ACE_NTOHL (0x74657200), // name = SchedulingParameter + 4, // member count + 9, + ACE_NTOHL (0x64656164), + ACE_NTOHL (0x6c696e65), + ACE_NTOHL (0x0), // name = deadline + CORBA::tk_alias, // typecode kind for typedefs + 56, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + 31, + ACE_NTOHL (0x49444c3a), + ACE_NTOHL (0x6f6d672e), + ACE_NTOHL (0x6f72672f), + ACE_NTOHL (0x54696d65), + ACE_NTOHL (0x42617365), + ACE_NTOHL (0x2f54696d), + ACE_NTOHL (0x65543a31), + ACE_NTOHL (0x2e300000), // repository ID = IDL:omg.org/TimeBase/TimeT:1.0 + 6, + ACE_NTOHL (0x54696d65), + ACE_NTOHL (0x54000000), // name = TimeT + CORBA::tk_ulonglong, + + + 11, + ACE_NTOHL (0x696d706f), + ACE_NTOHL (0x7274616e), + ACE_NTOHL (0x63650000), // name = importance + CORBA::tk_long, + + 7, + ACE_NTOHL (0x70657269), + ACE_NTOHL (0x6f640000), // name = period + CORBA::tk_alias, // typecode kind for typedefs + 56, // encapsulation length + TAO_ENCAP_BYTE_ORDER, // byte order + 31, + ACE_NTOHL (0x49444c3a), + ACE_NTOHL (0x6f6d672e), + ACE_NTOHL (0x6f72672f), + ACE_NTOHL (0x54696d65), + ACE_NTOHL (0x42617365), + ACE_NTOHL (0x2f54696d), + ACE_NTOHL (0x65543a31), + ACE_NTOHL (0x2e300000), // repository ID = IDL:omg.org/TimeBase/TimeT:1.0 + 6, + ACE_NTOHL (0x54696d65), + ACE_NTOHL (0x54000000), // name = TimeT + CORBA::tk_ulonglong, + + + 8, + ACE_NTOHL (0x7461736b), + ACE_NTOHL (0x5f696400), // name = task_id + CORBA::tk_long, + +}; + +static CORBA::TypeCode _tc_TAO_tc_EDF_Scheduling_SchedulingParameter ( + CORBA::tk_struct, + sizeof (_oc_EDF_Scheduling_SchedulingParameter), + (char *) &_oc_EDF_Scheduling_SchedulingParameter, + 0, + sizeof (EDF_Scheduling::SchedulingParameter) + ); + +namespace EDF_Scheduling +{ + ::CORBA::TypeCode_ptr _tc_SchedulingParameter = + &_tc_TAO_tc_EDF_Scheduling_SchedulingParameter; +} + +// TAO_IDL - Generated from +// be/be_visitor_structure/structure_cs.cpp:66 + +void +EDF_Scheduling::SchedulingParameter::_tao_any_destructor ( + void *_tao_void_pointer + ) +{ + SchedulingParameter *_tao_tmp_pointer = + ACE_static_cast (SchedulingParameter *, _tao_void_pointer); + delete _tao_tmp_pointer; +} + +// TAO_IDL - Generated from +// be/be_visitor_interface/interface_cs.cpp:60 + +// Traits specializations for EDF_Scheduling::SchedulingParameterPolicy. + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +EDF_Scheduling::SchedulingParameterPolicy_ptr +TAO::Objref_Traits<EDF_Scheduling::SchedulingParameterPolicy>::tao_duplicate ( + EDF_Scheduling::SchedulingParameterPolicy_ptr p + ) +{ + return EDF_Scheduling::SchedulingParameterPolicy::_duplicate (p); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +void +TAO::Objref_Traits<EDF_Scheduling::SchedulingParameterPolicy>::tao_release ( + EDF_Scheduling::SchedulingParameterPolicy_ptr p + ) +{ + CORBA::release (p); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +EDF_Scheduling::SchedulingParameterPolicy_ptr +TAO::Objref_Traits<EDF_Scheduling::SchedulingParameterPolicy>::tao_nil (void) +{ + return EDF_Scheduling::SchedulingParameterPolicy::_nil (); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +CORBA::Boolean +TAO::Objref_Traits<EDF_Scheduling::SchedulingParameterPolicy>::tao_marshal ( + EDF_Scheduling::SchedulingParameterPolicy_ptr p, + TAO_OutputCDR & cdr + ) +{ + return p->marshal (cdr); +} + +// Function pointer for collocation factory initialization. +TAO::Collocation_Proxy_Broker * +(*EDF_Scheduling__TAO_SchedulingParameterPolicy_Proxy_Broker_Factory_function_pointer) ( + CORBA::Object_ptr obj + ) = 0; + +EDF_Scheduling::SchedulingParameterPolicy::SchedulingParameterPolicy (void) +{} + +EDF_Scheduling::SchedulingParameterPolicy::~SchedulingParameterPolicy (void) +{} + +void +EDF_Scheduling::SchedulingParameterPolicy::_tao_any_destructor (void *_tao_void_pointer) +{ + SchedulingParameterPolicy *_tao_tmp_pointer = + ACE_static_cast (SchedulingParameterPolicy *, _tao_void_pointer); + CORBA::release (_tao_tmp_pointer); +} + +EDF_Scheduling::SchedulingParameterPolicy_ptr +EDF_Scheduling::SchedulingParameterPolicy::_narrow ( + CORBA::Object_ptr _tao_objref + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + if (CORBA::is_nil (_tao_objref)) + { + return SchedulingParameterPolicy::_nil (); + } + + SchedulingParameterPolicy_ptr proxy = + dynamic_cast<SchedulingParameterPolicy_ptr> (_tao_objref); + + return SchedulingParameterPolicy::_duplicate (proxy); +} + +EDF_Scheduling::SchedulingParameterPolicy_ptr +EDF_Scheduling::SchedulingParameterPolicy::_duplicate (SchedulingParameterPolicy_ptr obj) +{ + if (! CORBA::is_nil (obj)) + { + obj->_add_ref (); + } + + return obj; +} + +CORBA::Boolean +EDF_Scheduling::SchedulingParameterPolicy::_is_a ( + const char *value + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + if ( + !ACE_OS::strcmp ( + (char *)value, + "IDL:omg.org/CORBA/Policy:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:EDF_Scheduling/SchedulingParameterPolicy:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:omg.org/CORBA/LocalObject:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:omg.org/CORBA/Object:1.0" + ) + ) + { + return 1; // success using local knowledge + } + else + { + return 0; + } +} + +const char* EDF_Scheduling::SchedulingParameterPolicy::_interface_repository_id (void) const +{ + return "IDL:EDF_Scheduling/SchedulingParameterPolicy:1.0"; +} + +CORBA::Boolean +EDF_Scheduling::SchedulingParameterPolicy::marshal (TAO_OutputCDR &) +{ + return 0; +} + +// TAO_IDL - Generated from +// be/be_visitor_typecode/typecode_defn.cpp:284 + +static const CORBA::Long _oc_EDF_Scheduling_SchedulingParameterPolicy[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 49, + ACE_NTOHL (0x49444c3a), + ACE_NTOHL (0x4544465f), + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c69), + ACE_NTOHL (0x6e672f53), + ACE_NTOHL (0x63686564), + ACE_NTOHL (0x756c696e), + ACE_NTOHL (0x67506172), + ACE_NTOHL (0x616d6574), + ACE_NTOHL (0x6572506f), + ACE_NTOHL (0x6c696379), + ACE_NTOHL (0x3a312e30), + ACE_NTOHL (0x0), // repository ID = IDL:EDF_Scheduling/SchedulingParameterPolicy:1.0 + 26, + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c69), + ACE_NTOHL (0x6e675061), + ACE_NTOHL (0x72616d65), + ACE_NTOHL (0x74657250), + ACE_NTOHL (0x6f6c6963), + ACE_NTOHL (0x79000000), // name = SchedulingParameterPolicy + }; + +static CORBA::TypeCode _tc_TAO_tc_EDF_Scheduling_SchedulingParameterPolicy ( + CORBA::tk_objref, + sizeof (_oc_EDF_Scheduling_SchedulingParameterPolicy), + (char *) &_oc_EDF_Scheduling_SchedulingParameterPolicy, + 0, + sizeof (EDF_Scheduling::SchedulingParameterPolicy) + ); + +namespace EDF_Scheduling +{ + ::CORBA::TypeCode_ptr _tc_SchedulingParameterPolicy = + &_tc_TAO_tc_EDF_Scheduling_SchedulingParameterPolicy; +} + +// TAO_IDL - Generated from +// be/be_visitor_interface/interface_cs.cpp:60 + +// Traits specializations for EDF_Scheduling::Scheduler. + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +EDF_Scheduling::Scheduler_ptr +TAO::Objref_Traits<EDF_Scheduling::Scheduler>::tao_duplicate ( + EDF_Scheduling::Scheduler_ptr p + ) +{ + return EDF_Scheduling::Scheduler::_duplicate (p); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +void +TAO::Objref_Traits<EDF_Scheduling::Scheduler>::tao_release ( + EDF_Scheduling::Scheduler_ptr p + ) +{ + CORBA::release (p); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +EDF_Scheduling::Scheduler_ptr +TAO::Objref_Traits<EDF_Scheduling::Scheduler>::tao_nil (void) +{ + return EDF_Scheduling::Scheduler::_nil (); +} + +ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +CORBA::Boolean +TAO::Objref_Traits<EDF_Scheduling::Scheduler>::tao_marshal ( + EDF_Scheduling::Scheduler_ptr p, + TAO_OutputCDR & cdr + ) +{ + return p->marshal (cdr); +} + +// Function pointer for collocation factory initialization. +TAO::Collocation_Proxy_Broker * +(*EDF_Scheduling__TAO_Scheduler_Proxy_Broker_Factory_function_pointer) ( + CORBA::Object_ptr obj + ) = 0; + +EDF_Scheduling::Scheduler::Scheduler (void) +{} + +EDF_Scheduling::Scheduler::~Scheduler (void) +{} + +void +EDF_Scheduling::Scheduler::_tao_any_destructor (void *_tao_void_pointer) +{ + Scheduler *_tao_tmp_pointer = + ACE_static_cast (Scheduler *, _tao_void_pointer); + CORBA::release (_tao_tmp_pointer); +} + +EDF_Scheduling::Scheduler_ptr +EDF_Scheduling::Scheduler::_narrow ( + CORBA::Object_ptr _tao_objref + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + if (CORBA::is_nil (_tao_objref)) + { + return Scheduler::_nil (); + } + + Scheduler_ptr proxy = + dynamic_cast<Scheduler_ptr> (_tao_objref); + + return Scheduler::_duplicate (proxy); +} + +EDF_Scheduling::Scheduler_ptr +EDF_Scheduling::Scheduler::_duplicate (Scheduler_ptr obj) +{ + if (! CORBA::is_nil (obj)) + { + obj->_add_ref (); + } + + return obj; +} + +CORBA::Boolean +EDF_Scheduling::Scheduler::_is_a ( + const char *value + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + if ( + !ACE_OS::strcmp ( + (char *)value, + "IDL:RTScheduling/Scheduler:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:EDF_Scheduling/Scheduler:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:omg.org/CORBA/LocalObject:1.0" + ) || + !ACE_OS::strcmp ( + (char *)value, + "IDL:omg.org/CORBA/Object:1.0" + ) + ) + { + return 1; // success using local knowledge + } + else + { + return 0; + } +} + +const char* EDF_Scheduling::Scheduler::_interface_repository_id (void) const +{ + return "IDL:EDF_Scheduling/Scheduler:1.0"; +} + +CORBA::Boolean +EDF_Scheduling::Scheduler::marshal (TAO_OutputCDR &) +{ + return 0; +} + +// TAO_IDL - Generated from +// be/be_visitor_typecode/typecode_defn.cpp:284 + +static const CORBA::Long _oc_EDF_Scheduling_Scheduler[] = +{ + TAO_ENCAP_BYTE_ORDER, // byte order + 33, + ACE_NTOHL (0x49444c3a), + ACE_NTOHL (0x4544465f), + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c69), + ACE_NTOHL (0x6e672f53), + ACE_NTOHL (0x63686564), + ACE_NTOHL (0x756c6572), + ACE_NTOHL (0x3a312e30), + ACE_NTOHL (0x0), // repository ID = IDL:EDF_Scheduling/Scheduler:1.0 + 10, + ACE_NTOHL (0x53636865), + ACE_NTOHL (0x64756c65), + ACE_NTOHL (0x72000000), // name = Scheduler + }; + +static CORBA::TypeCode _tc_TAO_tc_EDF_Scheduling_Scheduler ( + CORBA::tk_objref, + sizeof (_oc_EDF_Scheduling_Scheduler), + (char *) &_oc_EDF_Scheduling_Scheduler, + 0, + sizeof (EDF_Scheduling::Scheduler) + ); + +namespace EDF_Scheduling +{ + ::CORBA::TypeCode_ptr _tc_Scheduler = + &_tc_TAO_tc_EDF_Scheduling_Scheduler; +} + +// TAO_IDL - Generated from +// be/be_visitor_structure/any_op_cs.cpp:54 + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const EDF_Scheduling::SchedulingParameter &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<EDF_Scheduling::SchedulingParameter>::insert_copy ( + _tao_any, + EDF_Scheduling::SchedulingParameter::_tao_any_destructor, + EDF_Scheduling::_tc_SchedulingParameter, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + EDF_Scheduling::SchedulingParameter *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<EDF_Scheduling::SchedulingParameter>::insert ( + _tao_any, + EDF_Scheduling::SchedulingParameter::_tao_any_destructor, + EDF_Scheduling::_tc_SchedulingParameter, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + EDF_Scheduling::SchedulingParameter *&_tao_elem + ) +{ + return _tao_any >>= ACE_const_cast ( + const EDF_Scheduling::SchedulingParameter *&, + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const EDF_Scheduling::SchedulingParameter *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<EDF_Scheduling::SchedulingParameter>::extract ( + _tao_any, + EDF_Scheduling::SchedulingParameter::_tao_any_destructor, + EDF_Scheduling::_tc_SchedulingParameter, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be/be_visitor_interface/any_op_cs.cpp:50 + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::SchedulingParameterPolicy>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const +{ + _tao_elem = CORBA::Object::_duplicate (this->value_); + return 1; +} + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::SchedulingParameterPolicy>::marshal_value (TAO_OutputCDR &) +{ + return 0; +} + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::SchedulingParameterPolicy>::demarshal_value (TAO_InputCDR &) +{ + return 0; +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + EDF_Scheduling::SchedulingParameterPolicy_ptr _tao_elem + ) +{ + EDF_Scheduling::SchedulingParameterPolicy_ptr _tao_objptr = + EDF_Scheduling::SchedulingParameterPolicy::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + EDF_Scheduling::SchedulingParameterPolicy_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<EDF_Scheduling::SchedulingParameterPolicy>::insert ( + _tao_any, + EDF_Scheduling::SchedulingParameterPolicy::_tao_any_destructor, + EDF_Scheduling::_tc_SchedulingParameterPolicy, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + EDF_Scheduling::SchedulingParameterPolicy_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<EDF_Scheduling::SchedulingParameterPolicy>::extract ( + _tao_any, + EDF_Scheduling::SchedulingParameterPolicy::_tao_any_destructor, + EDF_Scheduling::_tc_SchedulingParameterPolicy, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be/be_visitor_interface/any_op_cs.cpp:50 + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::Scheduler>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const +{ + _tao_elem = CORBA::Object::_duplicate (this->value_); + return 1; +} + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::Scheduler>::marshal_value (TAO_OutputCDR &) +{ + return 0; +} + +ACE_TEMPLATE_SPECIALIZATION +CORBA::Boolean +TAO::Any_Impl_T<EDF_Scheduling::Scheduler>::demarshal_value (TAO_InputCDR &) +{ + return 0; +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + EDF_Scheduling::Scheduler_ptr _tao_elem + ) +{ + EDF_Scheduling::Scheduler_ptr _tao_objptr = + EDF_Scheduling::Scheduler::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + EDF_Scheduling::Scheduler_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<EDF_Scheduling::Scheduler>::insert ( + _tao_any, + EDF_Scheduling::Scheduler::_tao_any_destructor, + EDF_Scheduling::_tc_Scheduler, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + EDF_Scheduling::Scheduler_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<EDF_Scheduling::Scheduler>::extract ( + _tao_any, + EDF_Scheduling::Scheduler::_tao_any_destructor, + EDF_Scheduling::_tc_Scheduler, + _tao_elem + ); +} + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h new file mode 100644 index 00000000000..bfd1d8cdd6f --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h @@ -0,0 +1,429 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be/be_codegen.cpp:150 + +#ifndef _TAO_IDL_EDF_SCHEDULINGC_H_ +#define _TAO_IDL_EDF_SCHEDULINGC_H_ + +#include "tao/ORB.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Kokyu_dsrt_schedulers_export.h" +#include "tao/CDR.h" +#include "tao/Environment.h" +#include "tao/Object.h" +#include "tao/Objref_VarOut_T.h" +#include "tao/VarOut_T.h" + +#include "tao/RTScheduling/RTScheduler.h" +#include "tao/RTCORBA/RTCORBA.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO Kokyu_DSRT_Schedulers_Export + +#if defined (TAO_EXPORT_NESTED_CLASSES) +# if defined (TAO_EXPORT_NESTED_MACRO) +# undef TAO_EXPORT_NESTED_MACRO +# endif /* defined (TAO_EXPORT_NESTED_MACRO) */ +# define TAO_EXPORT_NESTED_MACRO Kokyu_DSRT_Schedulers_Export +#endif /* TAO_EXPORT_NESTED_CLASSES */ + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be/be_visitor_root/root_ch.cpp:63 + +namespace TAO +{ + class Collocation_Proxy_Broker; + + template<typename T> class Narrow_Utils; + template<typename T> class AbstractBase_Narrow_Utils; +} + +// TAO_IDL - Generated from +// be/be_visitor_module/module_ch.cpp:48 + +namespace EDF_Scheduling +{ + + // TAO_IDL - Generated from + // be/be_type.cpp:258 + + struct SchedulingParameter; + + typedef + TAO_Fixed_Var_T< + SchedulingParameter + > + SchedulingParameter_var; + + typedef + SchedulingParameter & + SchedulingParameter_out; + + // TAO_IDL - Generated from + // be/be_visitor_structure/structure_ch.cpp:52 + + struct Kokyu_DSRT_Schedulers_Export SchedulingParameter + { + typedef SchedulingParameter_var _var_type; + + static void _tao_any_destructor (void *); + TimeBase::TimeT deadline; + CORBA::Long importance; + TimeBase::TimeT period; + CORBA::Long task_id; + }; + + // TAO_IDL - Generated from + // be/be_visitor_typecode/typecode_decl.cpp:44 + + TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr _tc_SchedulingParameter; + + // TAO_IDL - Generated from + // be/be_interface.cpp:612 + +#if !defined (_EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY__VAR_OUT_CH_) +#define _EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY__VAR_OUT_CH_ + + class SchedulingParameterPolicy; + typedef SchedulingParameterPolicy *SchedulingParameterPolicy_ptr; + + typedef + TAO_Objref_Var_T< + SchedulingParameterPolicy + > + SchedulingParameterPolicy_var; + + typedef + TAO_Objref_Out_T< + SchedulingParameterPolicy + > + SchedulingParameterPolicy_out; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:54 + +#if !defined (_EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY_CH_) +#define _EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY_CH_ + + class Kokyu_DSRT_Schedulers_Export SchedulingParameterPolicy + : public virtual CORBA::Policy + { + public: + typedef SchedulingParameterPolicy_ptr _ptr_type; + typedef SchedulingParameterPolicy_var _var_type; + + // The static operations. + static SchedulingParameterPolicy_ptr _duplicate (SchedulingParameterPolicy_ptr obj); + + static SchedulingParameterPolicy_ptr _narrow ( + CORBA::Object_ptr obj + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + static SchedulingParameterPolicy_ptr _nil (void) + { + return (SchedulingParameterPolicy_ptr)0; + } + + static void _tao_any_destructor (void *); + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual ::EDF_Scheduling::SchedulingParameter value ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual void value ( + const EDF_Scheduling::SchedulingParameter & value + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:192 + + virtual CORBA::Boolean _is_a ( + const char *type_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + virtual const char* _interface_repository_id (void) const; + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); + + protected: + // Abstract or local interface only. + SchedulingParameterPolicy (void); + + virtual ~SchedulingParameterPolicy (void); + + private: + // Private and unimplemented for concrete interfaces. + SchedulingParameterPolicy (const SchedulingParameterPolicy &); + + void operator= (const SchedulingParameterPolicy &); + }; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_typecode/typecode_decl.cpp:44 + + TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr _tc_SchedulingParameterPolicy; + + // TAO_IDL - Generated from + // be/be_interface.cpp:612 + +#if !defined (_EDF_SCHEDULING_SCHEDULER__VAR_OUT_CH_) +#define _EDF_SCHEDULING_SCHEDULER__VAR_OUT_CH_ + + class Scheduler; + typedef Scheduler *Scheduler_ptr; + + typedef + TAO_Objref_Var_T< + Scheduler + > + Scheduler_var; + + typedef + TAO_Objref_Out_T< + Scheduler + > + Scheduler_out; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:54 + +#if !defined (_EDF_SCHEDULING_SCHEDULER_CH_) +#define _EDF_SCHEDULING_SCHEDULER_CH_ + + class Kokyu_DSRT_Schedulers_Export Scheduler + : public virtual RTScheduling::Scheduler + { + public: + typedef Scheduler_ptr _ptr_type; + typedef Scheduler_var _var_type; + + // The static operations. + static Scheduler_ptr _duplicate (Scheduler_ptr obj); + + static Scheduler_ptr _narrow ( + CORBA::Object_ptr obj + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + static Scheduler_ptr _nil (void) + { + return (Scheduler_ptr)0; + } + + static void _tao_any_destructor (void *); + + // TAO_IDL - Generated from + // be/be_visitor_operation/operation_ch.cpp:46 + + virtual ::EDF_Scheduling::SchedulingParameterPolicy_ptr create_scheduling_parameter ( + const EDF_Scheduling::SchedulingParameter & value + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) = 0; + + // TAO_IDL - Generated from + // be/be_visitor_interface/interface_ch.cpp:192 + + virtual CORBA::Boolean _is_a ( + const char *type_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); + + virtual const char* _interface_repository_id (void) const; + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); + + protected: + // Abstract or local interface only. + Scheduler (void); + + virtual ~Scheduler (void); + + private: + // Private and unimplemented for concrete interfaces. + Scheduler (const Scheduler &); + + void operator= (const Scheduler &); + }; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be/be_visitor_typecode/typecode_decl.cpp:44 + + TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr _tc_Scheduler; + +// TAO_IDL - Generated from +// be/be_visitor_module/module_ch.cpp:66 + +} // module EDF_Scheduling + +// TAO_IDL - Generated from +// be/be_visitor_traits.cpp:50 + +// Traits specializations. +namespace TAO +{ + +#if !defined (_EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY__TRAITS_CH_) +#define _EDF_SCHEDULING_SCHEDULINGPARAMETERPOLICY__TRAITS_CH_ + + ACE_TEMPLATE_SPECIALIZATION + struct Kokyu_DSRT_Schedulers_Export Objref_Traits<EDF_Scheduling::SchedulingParameterPolicy> + { + static EDF_Scheduling::SchedulingParameterPolicy_ptr tao_duplicate ( + EDF_Scheduling::SchedulingParameterPolicy_ptr + ); + static void tao_release ( + EDF_Scheduling::SchedulingParameterPolicy_ptr + ); + static EDF_Scheduling::SchedulingParameterPolicy_ptr tao_nil (void); + static CORBA::Boolean tao_marshal ( + EDF_Scheduling::SchedulingParameterPolicy_ptr p, + TAO_OutputCDR & cdr + ); + }; + +#endif /* end #if !defined */ + +#if !defined (_EDF_SCHEDULING_SCHEDULER__TRAITS_CH_) +#define _EDF_SCHEDULING_SCHEDULER__TRAITS_CH_ + + ACE_TEMPLATE_SPECIALIZATION + struct Kokyu_DSRT_Schedulers_Export Objref_Traits<EDF_Scheduling::Scheduler> + { + static EDF_Scheduling::Scheduler_ptr tao_duplicate ( + EDF_Scheduling::Scheduler_ptr + ); + static void tao_release ( + EDF_Scheduling::Scheduler_ptr + ); + static EDF_Scheduling::Scheduler_ptr tao_nil (void); + static CORBA::Boolean tao_marshal ( + EDF_Scheduling::Scheduler_ptr p, + TAO_OutputCDR & cdr + ); + }; + +#endif /* end #if !defined */ +}; + +// TAO_IDL - Generated from +// be/be_visitor_structure/any_op_ch.cpp:52 + +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, const EDF_Scheduling::SchedulingParameter &); // copying version +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, EDF_Scheduling::SchedulingParameter*); // noncopying version +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator>>= (const CORBA::Any &, EDF_Scheduling::SchedulingParameter *&); // deprecated +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator>>= (const CORBA::Any &, const EDF_Scheduling::SchedulingParameter *&); + +// TAO_IDL - Generated from +// be/be_visitor_interface/any_op_ch.cpp:52 + +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, EDF_Scheduling::SchedulingParameterPolicy_ptr); // copying +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, EDF_Scheduling::SchedulingParameterPolicy_ptr *); // non-copying +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator>>= (const CORBA::Any &, EDF_Scheduling::SchedulingParameterPolicy_ptr &); + +// TAO_IDL - Generated from +// be/be_visitor_interface/any_op_ch.cpp:52 + +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, EDF_Scheduling::Scheduler_ptr); // copying +Kokyu_DSRT_Schedulers_Export void operator<<= (CORBA::Any &, EDF_Scheduling::Scheduler_ptr *); // non-copying +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator>>= (const CORBA::Any &, EDF_Scheduling::Scheduler_ptr &); + +// TAO_IDL - Generated from +// be/be_visitor_root/cdr_op.cpp:48 + +#ifndef __ACE_INLINE__ + +// TAO_IDL - Generated from +// be/be_visitor_structure/cdr_op_ch.cpp:53 + +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator<< (TAO_OutputCDR &, const EDF_Scheduling::SchedulingParameter &); +Kokyu_DSRT_Schedulers_Export CORBA::Boolean operator>> (TAO_InputCDR &, EDF_Scheduling::SchedulingParameter &); + +// TAO_IDL - Generated from +// be/be_visitor_root/cdr_op.cpp:64 + +#endif /* __ACE_INLINE__ */ + +// TAO_IDL - Generated from +// be/be_codegen.cpp:911 + +#if defined (__ACE_INLINE__) +#include "EDF_SchedulingC.i" +#endif /* defined INLINE */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#endif /* ifndef */ + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h.diff b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h.diff new file mode 100644 index 00000000000..d1505d6d604 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.h.diff @@ -0,0 +1,13 @@ +--- EDF_SchedulingC.h.orig 2003-12-04 00:55:30.000000000 -0600 ++++ EDF_SchedulingC.h 2003-12-04 00:55:53.000000000 -0600 +@@ -44,8 +44,8 @@ + #include "tao/Objref_VarOut_T.h" + #include "tao/VarOut_T.h" + +-#include "tao/RTScheduling/RTSchedulerC.h" +-#include "tao/RTCORBA/RTCORBAC.h" ++#include "tao/RTScheduling/RTScheduler.h" ++#include "tao/RTCORBA/RTCORBA.h" + + #if defined (TAO_EXPORT_MACRO) + #undef TAO_EXPORT_MACRO diff --git a/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.i b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.i new file mode 100644 index 00000000000..bdc25a22993 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/EDF_SchedulingC.i @@ -0,0 +1,57 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + + +// TAO_IDL - Generated from +// be/be_visitor_structure/cdr_op_ci.cpp:70 + +ACE_INLINE +CORBA::Boolean operator<< ( + TAO_OutputCDR &strm, + const EDF_Scheduling::SchedulingParameter &_tao_aggregate + ) +{ + return + (strm << _tao_aggregate.deadline) && + (strm << _tao_aggregate.importance) && + (strm << _tao_aggregate.period) && + (strm << _tao_aggregate.task_id); +} + +ACE_INLINE +CORBA::Boolean operator>> ( + TAO_InputCDR &strm, + EDF_Scheduling::SchedulingParameter &_tao_aggregate + ) +{ + return + (strm >> _tao_aggregate.deadline) && + (strm >> _tao_aggregate.importance) && + (strm >> _tao_aggregate.period) && + (strm >> _tao_aggregate.task_id); +} + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile new file mode 100644 index 00000000000..e967cb55981 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile @@ -0,0 +1,69 @@ +#---------------------------------------------------------------------------- +# GNU ACE Workspace +# +# @file Makefile +# +# $Id$ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- + + +MAKE_OPTIONS=$(shell echo $(MAKEFLAGS) | sed 's/--unix *//; s/ .*//') +ifeq ($(findstring k,$(MAKE_OPTIONS)),k) + KEEP_GOING = 1 +else + KEEP_GOING = 0 +endif + +%.tgt0: +ifeq ($(KEEP_GOING),1) +# -@$(MAKE) -f Makefile.dt_oneway_client -C . $(*); + -@$(MAKE) -f Makefile.dt_two_prio_client -C . $(*); +# -@$(MAKE) -f Makefile.dt_prio_client -C . $(*); +# -@$(MAKE) -f Makefile.dt_twoway_client -C . $(*); +else +# @$(MAKE) -f Makefile.dt_oneway_client -C . $(*); + @$(MAKE) -f Makefile.dt_two_prio_client -C . $(*); +# @$(MAKE) -f Makefile.dt_prio_client -C . $(*); +# @$(MAKE) -f Makefile.dt_twoway_client -C . $(*); +endif +%.tgt1: %.tgt0 +ifeq ($(KEEP_GOING),1) +# -@$(MAKE) -f Makefile.dt_oneway_server -C . $(*); + -@$(MAKE) -f Makefile.dt_two_prio_server -C . $(*); +# -@$(MAKE) -f Makefile.dt_prio_server -C . $(*); +# -@$(MAKE) -f Makefile.dt_twoway_server -C . $(*); +else +# @$(MAKE) -f Makefile.dt_oneway_server -C . $(*); + @$(MAKE) -f Makefile.dt_two_prio_server -C . $(*); +# @$(MAKE) -f Makefile.dt_prio_server -C . $(*); +# @$(MAKE) -f Makefile.dt_twoway_server -C . $(*); +endif + + +all: all.tgt0 all.tgt1 + +debug: debug.tgt0 debug.tgt1 + +profile: profile.tgt0 profile.tgt1 + +optimize: optimize.tgt0 optimize.tgt1 + +install: install.tgt0 install.tgt1 + +deinstall: deinstall.tgt0 deinstall.tgt1 + +clean: clean.tgt0 clean.tgt1 + +realclean: realclean.tgt0 realclean.tgt1 + +clobber: clobber.tgt0 clobber.tgt1 + +depend: depend.tgt0 depend.tgt1 + +rcs_info: rcs_info.tgt0 rcs_info.tgt1 + +idl_stubs: idl_stubs.tgt0 idl_stubs.tgt1 diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.backup b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.backup new file mode 100644 index 00000000000..85f19ac396d --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.backup @@ -0,0 +1,61 @@ +#---------------------------------------------------------------------------- +# GNU ACE Workspace +# +# @file Makefile +# +# Makefile,v 1.3 2003/10/17 16:37:52 venkita Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- + + +MAKE_OPTIONS=$(shell echo $(MAKEFLAGS) | sed 's/--unix *//; s/ .*//') +ifeq ($(findstring k,$(MAKE_OPTIONS)),k) + KEEP_GOING = 1 +else + KEEP_GOING = 0 +endif + +%.tgt0: +ifeq ($(KEEP_GOING),1) + -@$(MAKE) -f Makefile.prio_client -C . $(*); + -@$(MAKE) -f Makefile.twoway_client -C . $(*); +else + @$(MAKE) -f Makefile.prio_client -C . $(*); + @$(MAKE) -f Makefile.twoway_client -C . $(*); +endif +%.tgt1: %.tgt0 +ifeq ($(KEEP_GOING),1) + -@$(MAKE) -f Makefile.prio_server -C . $(*); + -@$(MAKE) -f Makefile.twoway_server -C . $(*); +else + @$(MAKE) -f Makefile.prio_server -C . $(*); + @$(MAKE) -f Makefile.twoway_server -C . $(*); +endif + + +all: all.tgt0 all.tgt1 + +debug: debug.tgt0 debug.tgt1 + +profile: profile.tgt0 profile.tgt1 + +optimize: optimize.tgt0 optimize.tgt1 + +install: install.tgt0 install.tgt1 + +deinstall: deinstall.tgt0 deinstall.tgt1 + +clean: clean.tgt0 clean.tgt1 + +realclean: realclean.tgt0 realclean.tgt1 + +clobber: clobber.tgt0 clobber.tgt1 + +depend: depend.tgt0 depend.tgt1 + +rcs_info: rcs_info.tgt0 rcs_info.tgt1 + +idl_stubs: idl_stubs.tgt0 idl_stubs.tgt1 diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_client b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_client new file mode 100644 index 00000000000..634a4802de7 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_client @@ -0,0 +1,128 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.dt_oneway_client +# +# gnu.mpd,v 1.56 2003/10/16 14:03:48 elliott_c Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_oneway_client +DEPENDENCY_FILE = .depend.Makefile.dt_oneway_client +BIN_UNCHECKED = dt_oneway_client + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test1 +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + test1C \ + dt_oneway_client + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lTAO_Svc_Utils -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -ldsui -lTAO_RTCORBA -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/dt_oneway_client + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test1 -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +CURRENT_COMPONENTS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +test1C.cpp dt_oneway_client.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../../orbsvcs -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + +CPPFLAGS += -DKOKYU_DSRT_LOGGING + +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + +DSUI_PARSE=$(DATASTREAM_ROOT)/bin/dsui-parse +DT_ONEWAY_DSUI = dt_oneway_dsui_families.h dt_oneway_dsui_info.h dt_oneway_dsui_table.h +$(DT_ONEWAY_DSUI): dt_oneway.dsui + $(DSUI_PARSE) -n dt_oneway.dsui -t dt_oneway + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + -$(RM) $(DT_ONEWAY_DSUI) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_server b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_server new file mode 100644 index 00000000000..dda5edfb535 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_oneway_server @@ -0,0 +1,125 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.dt_oneway_server +# +# gnu.mpd,v 1.56 2003/10/16 14:03:48 elliott_c Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_oneway_server +DEPENDENCY_FILE = .depend.Makefile.dt_oneway_server +BIN_UNCHECKED = dt_oneway_server + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test1 +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + test1C \ + test1S \ + test1_i \ + dt_oneway_server + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -ldsui -lTAO_RTCORBA -lTAO_PortableServer -lTAO_IORInterceptor -lTAO_Valuetype -lTAO_ObjRefTemplate -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/dt_oneway_server + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test1 -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +test1C.cpp testi1S.cpp test1_i.cpp dt_oneway_server.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include + +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + +CPPFLAGS += -DKOKYU_DSRT_LOGGING + +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Gv -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_client b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_client new file mode 100644 index 00000000000..a74085fcc70 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_client @@ -0,0 +1,122 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.dt_prio_client +# +# $Id$ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_prio_client +DEPENDENCY_FILE = .depend.Makefile.dt_prio_client +BIN_UNCHECKED = dt_prio_client + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + testC \ + dt_prio_client + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lTAO_Svc_Utils -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -ldsui -lTAO_RTCORBA -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/dt_prio_client + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +CURRENT_COMPONENTS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +testC.cpp dt_prio_client.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../../orbsvcs -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + +CPPFLAGS += -DKOKYU_DSRT_LOGGING +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_server b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_server new file mode 100644 index 00000000000..61f7e382ed7 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_prio_server @@ -0,0 +1,123 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.prio_server +# +# gnu.mpd,v 1.56 2003/10/16 14:03:48 elliott_c Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_prio_server +DEPENDENCY_FILE = .depend.Makefile.dt_prio_server +BIN_UNCHECKED = dt_prio_server + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + testC \ + testS \ + test_i \ + dt_prio_server + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -ldsui -lTAO_RTCORBA -lTAO_PortableServer -lTAO_IORInterceptor -lTAO_Valuetype -lTAO_ObjRefTemplate -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/prio_server + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +testC.cpp testS.cpp test_i.cpp prio_server.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif +CPPFLAGS += -DKOKYU_DSRT_LOGGING + +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Gv -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_client b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_client new file mode 100644 index 00000000000..aecbf591ef9 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_client @@ -0,0 +1,122 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.dt_twoway_client +# +# gnu.mpd,v 1.56 2003/10/16 14:03:48 elliott_c Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_twoway_client +DEPENDENCY_FILE = .depend.Makefile.dt_twoway_client +BIN_UNCHECKED = dt_twoway_client + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + testC \ + dt_twoway_client + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lTAO_Svc_Utils -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -ldsui -lTAO_RTCORBA -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/dt_twoway_client + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +CURRENT_COMPONENTS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +testC.cpp dt_twoway_client.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../../orbsvcs -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + + +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_server b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_server new file mode 100644 index 00000000000..8f52893ebd5 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/Makefile.dt_twoway_server @@ -0,0 +1,123 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.dt_twoway_server +# +# gnu.mpd,v 1.56 2003/10/16 14:03:48 elliott_c Exp +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.dt_twoway_server +DEPENDENCY_FILE = .depend.Makefile.dt_twoway_server +BIN_UNCHECKED = dt_twoway_server + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +TAO_IDL = ../../../../bin/tao_idl +IDL_FILES = test +IDL_SRC = $(foreach ext, C.cpp S.cpp, $(foreach file, $(IDL_FILES), $(file)$(ext))) + +FILES = \ + testC \ + testS \ + test_i \ + dt_twoway_server + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lKokyu_DSRT_Schedulers -lTAO_RTScheduler -lwrappers -lKokyu -dsui -lTAO_RTCORBA -lTAO_PortableServer -lTAO_IORInterceptor -lTAO_Valuetype -lTAO_ObjRefTemplate -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/dt_twoway_server + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif + +ifeq ($(rt_corba),1) +BIN = $(BIN_UNCHECKED) +else + all: require_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) + +ifneq ($(BIN),) +all: idl_stubs + +# This rule forces make to run the idl_stubs +# target before building any of the source files. +testC.cpp testS.cpp test_i.cpp dt_twoway_server.cpp: idl_stubs +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../examples/Kokyu_dsrt_schedulers -I../../../../Kokyu -I../../.. -I../../../tao -I../../../.. -I$(DATASTREAM_ROOT)/include +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + + +LDFLAGS += -L../../../../lib -L$(DATASTREAM_ROOT)/lib + +TAO_IDLFLAGS += -Gv -Ge 1 -Sc -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +require_warning: + @echo This project will not be built due to one of the following missing features: + @echo rt_corba + +../../../../lib: + -@mkdir -p "../../../../lib" + + +ADDITIONAL_IDL_TARGETS = +# IDL File Directory: . + +ifneq ($(ADDITIONAL_IDL_TARGETS),) +idl_stubs: $(ADDITIONAL_IDL_TARGETS) +endif + +.PRECIOUS: $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), $(foreach file, $(IDL_FILES), $(file)$(ext))) +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway.dsui b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway.dsui new file mode 100644 index 00000000000..6ae4abe310a --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway.dsui @@ -0,0 +1,23 @@ +# TEST_ONE +DSTRM_EVENT TEST_ONE 3 DEADLINE_MISSED 2 "Deadline missed" print_string +DSTRM_EVENT TEST_ONE 3 STOP_SERVICE 1 "Stop service time" print_string +DSTRM_EVENT TEST_ONE 3 START_SERVICE 0 "Start service time" print_string + +# WORKER GROUP +DSTRM_EVENT WORKER_GROUP 2 ONE_WAY_CALL_DONE 4 "One way call done" print_string +DSTRM_EVENT WORKER_GROUP 2 ONE_WAY_CALL_START 3 "One way call started" print_string +DSTRM_EVENT WORKER_GROUP 2 END_SCHED_SEGMENT 2 "End scheduling segment" print_string +DSTRM_EVENT WORKER_GROUP 2 BEGIN_SCHED_SEGMENT 1 "Start scheduling segment" print_string +DSTRM_EVENT WORKER_GROUP 2 WORKER_STARTED 0 "Start worker thread" print_string + + +# MAIN GROUP +DSTRM_EVENT MAIN_GROUP 1 SCHEDULER_STARTED 8 "Scheduler started" print_string +DSTRM_EVENT MAIN_GROUP 1 SCHEDULER_SHUTDOWN 7 "Scheduler stopped" print_string +DSTRM_EVENT MAIN_GROUP 1 AFTER_SERVER_SHUTDOWN 6 "Server shutdown complete" print_string +DSTRM_EVENT MAIN_GROUP 1 CALL_SERVER_SHUTDOWN 5 "Called server to shutdown" print_string +DSTRM_EVENT MAIN_GROUP 1 WORKER_WAIT_DONE 4 "Worker thread wait() call complete" print_string +DSTRM_EVENT MAIN_GROUP 1 WORKER_ACTIVATED 3 "Worker activated" print_string +DSTRM_EVENT MAIN_GROUP 1 SCHEDULE_SETUP 2 "Scheduler setup" print_string +DSTRM_EVENT MAIN_GROUP 1 STOP 1 "Stop program" print_string +DSTRM_EVENT MAIN_GROUP 1 START 0 "Start program" print_string diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_client.cpp new file mode 100644 index 00000000000..04fe87841b1 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_client.cpp @@ -0,0 +1,465 @@ +//$Id$ + +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "test1C.h" +#include "EDF_Scheduler.h" +#include "orbsvcs/orbsvcs/Time_Utilities.h" +#include "Task_Stats.h" + +#include "dt_oneway_config.h" +#include "dt_oneway_dsui_families.h" +#include <dsui.h> + +ACE_RCSID(MT_Server, client, "client.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp") + +const char *ior = "file://test1.ior"; +int do_shutdown = 1; +int enable_dynamic_scheduling = 1; +int enable_yield = 1; +int enable_rand = 0; +int niteration = 1000; +int workload = 1; +int period = 2; + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb, + Simple_Server1_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load, + int worker_id); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb + + Simple_Server1_var server_; + RTScheduling::Current_var scheduler_current_; + EDF_Scheduler* scheduler_; + TimeBase::TimeT deadline_; + long importance_; + CORBA::Long server_load_; + int sleep_time_; + unsigned int m_id; +}; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:sn:w:p:r"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + + case 's': + enable_yield = 0; + break; + + case 'n': + niteration = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'w': + workload = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'p': + period = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'r': + enable_rand = 1; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-s (disable yield)" + "-n <niterations>" + "-w <workload>" + "-p <period>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ds_control ds_cntrl ("DT_Oneway", "dt_oneway_enable.dsui"); + ACE_High_Res_Timer non_dsui_timer; + non_dsui_timer.calibrate (); + non_dsui_timer.start(); + + /* MEASURE: Program start time */ + DSUI_EVENT_LOG(MAIN_GROUP_FAM, START,1,0,NULL); + + EDF_Scheduler* scheduler=0; + RTScheduling::Current_var current; + int prio; + int max_prio; + ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + long flags; + + if (sched_policy == ACE_SCHED_RR) { + /* MEASURE (DP): Schedule policy */ + char* policy = "ACE_SCHED_RR"; + DSUI_EVENT_LOG (MAIN_GROUP_FAM, SCHEDULE_SETUP, 1, strlen (policy), policy); + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + } + else { + /* MEASURE (DP): Schedule policy */ + char* policy = "ACE_SCHED_FIFO"; + DSUI_EVENT_LOG (MAIN_GROUP_FAM, SCHEDULE_SETUP, 1, strlen (policy), policy); + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + } + + ACE_hthread_t main_thr_handle; + ACE_Thread::self (main_thr_handle); + + max_prio = ACE_Sched_Params::priority_max (sched_policy, + sched_scope); + + ACE_Sched_Params sched_params (sched_policy, max_prio); + + ACE_OS::sched_params (sched_params); + + if (ACE_Thread::getprio (main_thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio)); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var object = + orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Simple_Server1_var server = + Simple_Server1::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior), + 1); + } + + if (enable_dynamic_scheduling) + { + ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n")); + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + /* MEASURE: Scheduler start time */ + DSUI_EVENT_LOG (MAIN_GROUP_FAM, SCHEDULER_STARTED, 1, 0, NULL); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + + TimeBase::TimeT deadline; + int importance=0; + + ORBSVCS_Time::Time_Value_to_TimeT (deadline, + ACE_OS::gettimeofday () + + ACE_Time_Value (50,0) ); + + Worker worker1 (orb.in (), + server.in (), + current.in (), + scheduler, + deadline, + importance, + workload, + 1); + + if (worker1.activate (flags, 1, 0, max_prio) != 0) + { + ACE_ERROR ((LM_ERROR, + "(%t|%T) cannot activate worker thread.\n")); + } + + /* MEASURE: Worker thread activated */ + DSUI_EVENT_LOG (MAIN_GROUP_FAM, WORKER_ACTIVATED, 1, 0, NULL); + + worker1.wait (); + + /* MEASURE: Wait for worker thread done in main thread */ + // char* msg = "(%t): wait for worker threads done in main thread\n"; + // Get thread id + // DSUI_EVENT_LOG (MAIN_GROUP_FAM, WORKER_WAIT_DONE, 1, strlen(msg), msg); + + ACE_DEBUG ((LM_DEBUG, + "(%t): wait for worker threads done in main thread\n")); + + if (do_shutdown) + { + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + sched_param.importance = 0; + sched_param.deadline = 0; + sched_param.task_id = ID_BEGIN++; + sched_param.period = 0; + CORBA::Policy_var sched_param_policy = + scheduler->create_scheduling_parameter (sched_param); + CORBA::Policy_ptr implicit_sched_param = 0; + current->begin_scheduling_segment (0, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_DEBUG ((LM_DEBUG, "(%t): about to call server shutdown\n")); + + /* MEASURE: Call to shutdown server */ + // char* msg = "(%t): wait for worker threads done in main thread\n"; + // Get thread id + DSUI_EVENT_LOG (MAIN_GROUP_FAM, CALL_SERVER_SHUTDOWN, 1, 0, NULL); + + server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + /* MEASURE: After call to server shutdown */ + DSUI_EVENT_LOG (MAIN_GROUP_FAM, AFTER_SERVER_SHUTDOWN, 1, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "after shutdown call in main thread\n")); + + + if (enable_dynamic_scheduling) + { + current->end_scheduling_segment (0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + + scheduler->shutdown (); + + /* MEASURE: Scheduler stop time */ + DSUI_EVENT_LOG (MAIN_GROUP_FAM, SCHEDULER_SHUTDOWN, 1, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + /* MEASURE: Program stop time */ + DSUI_EVENT_LOG(MAIN_GROUP_FAM, STOP, 1, 0, NULL); + + non_dsui_timer.stop(); + ACE_hrtime_t dsui_ovhd_time; + non_dsui_timer.elapsed_time (dsui_ovhd_time); + + ACE_OS::printf ( ACE_TEXT ("Elapsed time: %lu (nsec)\n"), dsui_ovhd_time); + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb, + Simple_Server1_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load, + int worker_id) + : orb_ (CORBA::ORB::_duplicate (orb)), + server_ (Simple_Server1::_duplicate (server_ptr)), + scheduler_current_ (RTScheduling::Current::_duplicate (current)), + scheduler_ (scheduler), + deadline_ (deadline), + importance_ (importance), + server_load_ (server_load), + m_id (worker_id) + // sleep_time_ (sleep_time) +{ +} + +int +Worker::svc (void) +{ + /* MEASURE: Worker start time */ + DSUI_EVENT_LOG (WORKER_GROUP_FAM, WORKER_STARTED, m_id, 0, NULL); + + ACE_DECLARE_NEW_CORBA_ENV; + const char * name = 0; + /* + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to sleep for %d sec\n", sleep_time_)); + ACE_OS::sleep (sleep_time_); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):woke up from sleep for %d sec\n", sleep_time_)); + */ + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + int prio; + + if (ACE_Thread::getprio (thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t|%T) worker activated with prio %d\n", prio)); + + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + CORBA::Policy_var sched_param_policy; + sched_param.importance = importance_; + sched_param.deadline = deadline_; + sched_param.period = period*10000000; + sched_param.task_id = ID_BEGIN++; + sched_param_policy = scheduler_->create_scheduling_parameter (sched_param); + + //If we do not define implicit_sched_param, the new spawned DT will have the default lowest prio. + CORBA::Policy_var implicit_sched_param = sched_param_policy; + + /* MEASURE: Start of scheduling segment */ + DSUI_EVENT_LOG (WORKER_GROUP_FAM, BEGIN_SCHED_SEGMENT, 1, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):before begin_sched_segment\n")); + + scheduler_current_->begin_scheduling_segment (name, + sched_param_policy.in (), + implicit_sched_param.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + /* MEASURE: End of scheduling segment */ + DSUI_EVENT_LOG (WORKER_GROUP_FAM, END_SCHED_SEGMENT, 1, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):after begin_sched_segment\n")); + } + + int rand; + for(int i=0; i<niteration; i++) + { + /* MEASURE: One way call start */ + DSUI_EVENT_LOG (WORKER_GROUP_FAM, ONE_WAY_CALL_START, 1, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to make one way call\n")); + // TAO_debug_level = 1; + server_->test_method (server_load_ ACE_ENV_ARG_PARAMETER); + + ACE_CHECK_RETURN (-1); + + /* MEASURE: One way call done */ + DSUI_EVENT_LOG (WORKER_GROUP_FAM, ONE_WAY_CALL_DONE, m_id, 0, NULL); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):one way call done\n")); + + rand = mrand48()/10000; + if(enable_rand) + { + usleep(period*1000000+rand); + ACE_DEBUG((LM_DEBUG,"NOW I AM GOING TO SLEEP FOR %d\n", period*1000000+rand)); + } + else + { + sleep(period); + ACE_DEBUG((LM_DEBUG,"NOW I AM GOING TO SLEEP FOR %d\n", period*1000000)); + } + } + if (enable_dynamic_scheduling) + { + scheduler_current_->end_scheduling_segment (name); + ACE_CHECK_RETURN (-1); + } + + ACE_DEBUG ((LM_DEBUG, "client worker thread (%t) done\n")); + + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_config.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_config.h new file mode 100644 index 00000000000..62a15f13b6d --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_config.h @@ -0,0 +1,9 @@ +/* $Id$ */ +#ifndef DT_ONEWAY_CONFIG_H +#define DT_ONEWAY_CONFIG_H + +#define CONFIG_DSTREAM_MAIN_GROUP +#define CONFIG_DSTREAM_WORKER_GROUP +#define CONFIG_DSTREAM_TEST_ONE + +#endif /* DT_ONEWAY_CONFIG_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_enable.dsui b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_enable.dsui new file mode 100644 index 00000000000..2c2a3037d4e --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_enable.dsui @@ -0,0 +1,48 @@ +# DSRT DIRECT Dispatcher (DSRT_DIRECT_Dispatcher_Impl_T.cpp) +DSTRM_EVENT DSRT_DIRECT_DISPATCH 7 SCHEDULE_EXIT 1 +DSTRM_EVENT DSRT_DIRECT_DISPATCH 7 SCHEDULE_ENTER 0 + +# DSRT CV Dispatcher (DSRT_CV_Dispatcher_Impl_T.cpp) +DSTRM_EVENT DSRT_CV_DISPATCH 6 SCHEDULE_EXIT 1 +DSTRM_EVENT DSRT_CV_DISPATCH 6 SCHEDULE_ENTER 0 + +# DSRT_Dispatcher +DSTRM_EVENT DSRT_DISPATCH 5 SCHEDULE 0 + +# EDF_SCHED +DSTRM_EVENT EDF_SCHED 4 LEAVE_SERVER_DISPATCH_SCHEDULE 12 +DSTRM_EVENT EDF_SCHED 4 ENTER_SERVER_DISPATCH_SCHEDULE 11 +DSTRM_EVENT EDF_SCHED 4 LEAVE_SERVER_SCHED_TIME 10 +DSTRM_EVENT EDF_SCHED 4 ENTER_SERVER_SCHED_TIME 9 +DSTRM_EVENT EDF_SCHED 4 LEAVE_CLIENT_SCHED_TIME 8 +DSTRM_EVENT EDF_SCHED 4 LEAVE_KOKYU_DISPATCH_UPDATE_SCHEDULE 7 +DSTRM_EVENT EDF_SCHED 4 CALL_KOKYU_DISPATCH_UPDATE_SCHEDULE 6 +DSTRM_EVENT EDF_SCHED 4 ENTER_CLIENT_SCHED_TIME 5 +DSTRM_EVENT EDF_SCHED 4 DISPATCHER_SHUTDOWN 4 +DSTRM_EVENT EDF_SCHED 4 CREATE_SCHED_PARAM 3 +DSTRM_EVENT EDF_SCHED 4 BEGIN_SCHED_SEGMENT 2 +DSTRM_EVENT EDF_SCHED 4 END_SCHED_SEGMENT 1 +DSTRM_EVENT EDF_SCHED 4 KOKYU_SCHED_START 0 + +# TEST_ONE +DSTRM_EVENT TEST_ONE 3 DEADLINE_MISSED 2 +DSTRM_EVENT TEST_ONE 3 STOP_SERVICE 1 +DSTRM_EVENT TEST_ONE 3 START_SERVICE 0 + +# WORKER GROUP +DSTRM_EVENT WORKER_GROUP 2 ONE_WAY_CALL_DONE 4 +DSTRM_EVENT WORKER_GROUP 2 ONE_WAY_CALL_START 3 +DSTRM_EVENT WORKER_GROUP 2 END_SCHED_SEGMENT 2 +DSTRM_EVENT WORKER_GROUP 2 BEGIN_SCHED_SEGMENT 1 +DSTRM_EVENT WORKER_GROUP 2 WORKER_STARTED 0 + +# MAIN GROUP +DSTRM_EVENT MAIN_GROUP 1 SCHEDULER_STARTED 8 +DSTRM_EVENT MAIN_GROUP 1 SCHEDULER_SHUTDOWN 7 +DSTRM_EVENT MAIN_GROUP 1 AFTER_SERVER_SHUTDOWN 6 +DSTRM_EVENT MAIN_GROUP 1 CALL_SERVER_SHUTDOWN 5 +DSTRM_EVENT MAIN_GROUP 1 WORKER_WAIT_DONE 4 +DSTRM_EVENT MAIN_GROUP 1 WORKER_ACTIVATED 3 +DSTRM_EVENT MAIN_GROUP 1 SCHEDULE_SETUP 2 +DSTRM_EVENT MAIN_GROUP 1 STOP 1 +DSTRM_EVENT MAIN_GROUP 1 START 0 diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp new file mode 100644 index 00000000000..001d7a5163f --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp @@ -0,0 +1,263 @@ +//$Id$ + +#include "test1_i.h" +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "EDF_Scheduler.h" +#include "Task_Stats.h" + +#include <dsui.h> + +ACE_RCSID(MT_Server, server, "server.cpp,v 1.3 2003/10/14 05:57:01 jwillemsen Exp") + +const char *ior_output_file = "test1.ior"; + +int nthreads = 1; +int enable_dynamic_scheduling = 1; +const CORBA::Short max_importance = 100; +int enable_yield = 1; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:n:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case 'n': + nthreads = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 's': + enable_yield = 0; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "-n (thread num)" + "-s (disable yield)" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb +}; + +Task_Stats task_stats; + +int +main (int argc, char *argv[]) +{ + + ds_control ds_cntrl ("DT_Oneway", "dt_oneway_enable.dsui"); + + EDF_Scheduler* scheduler = 0; + RTScheduling::Current_var current; + long flags; + int sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + + if (sched_policy == ACE_SCHED_RR) + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + else + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + + task_stats.init (100000); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + if (enable_dynamic_scheduling) + { + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + Simple_Server1_i server_impl (orb.in (), + current.in (), + task_stats, + enable_yield); + + Simple_Server1_var server = + server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + +// TAO_debug_level = 1; + Worker worker (orb.in ()); + if (worker.activate (flags, + nthreads, + 0, + ACE_Sched_Params::priority_max(sched_policy, + sched_scope)) != 0) + { + ACE_ERROR ((LM_ERROR, + "Cannot activate threads in RT class.", + "Trying to activate in non-RT class\n")); + + flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND; + if (worker.activate (flags, nthreads) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate server threads\n"), + 1); + } + } + + worker.wait (); + + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n")); + scheduler->shutdown (); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, "Exiting main...\n")); + task_stats.dump_samples ("timeline.txt", + "Time\t\tGUID", + ACE_High_Res_Timer::global_scale_factor ()); + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int +Worker::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_Time_Value tv(5000); + + ACE_TRY + { + this->orb_->run (tv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + ACE_DEBUG ((LM_DEBUG, "(%t|%T): Worker thread exiting...\n")); + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_client.cpp new file mode 100644 index 00000000000..e75d39909d1 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_client.cpp @@ -0,0 +1,384 @@ +//$Id$ + +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "testC.h" +#include "EDF_Scheduler.h" +#include "orbsvcs/orbsvcs/Time_Utilities.h" + +ACE_RCSID(MT_Server, client, "client.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp") + +const char *ior = "file://test.ior"; +int niterations = 5; +int do_shutdown = 1; +int enable_dynamic_scheduling = 1; +int enable_yield = 1; + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb, + Simple_Server_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load); + // int sleep_time); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb + + Simple_Server_var server_; + RTScheduling::Current_var scheduler_current_; + EDF_Scheduler* scheduler_; + TimeBase::TimeT deadline_; + long importance_; + CORBA::Long server_load_; + int sleep_time_; +}; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "xk:i:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'x': + do_shutdown = 1; + break; + + case 'k': + ior = get_opts.opt_arg (); + break; + + case 'i': + niterations = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 's': + enable_yield = 0; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-i <niterations> " + "-d (enable dynamic scheduling)" + "-s (disable yield)" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + EDF_Scheduler* scheduler=0; + RTScheduling::Current_var current; + int prio; + int max_prio; + ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + long flags; + + if (sched_policy == ACE_SCHED_RR) + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + else + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + + ACE_hthread_t main_thr_handle; + ACE_Thread::self (main_thr_handle); + + max_prio = ACE_Sched_Params::priority_max (sched_policy, + sched_scope); + + ACE_Sched_Params sched_params (sched_policy, max_prio); + + ACE_OS::sched_params (sched_params); + + if (ACE_Thread::getprio (main_thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio)); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var object = + orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Simple_Server_var server = + Simple_Server::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior), + 1); + } + + if (enable_dynamic_scheduling) + { + ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n")); + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + + TimeBase::TimeT deadline; + int importance=0; + + ORBSVCS_Time::Time_Value_to_TimeT (deadline, + ACE_OS::gettimeofday () + + ACE_Time_Value (50,0) ); + + Worker worker1 (orb.in (), + server.in (), + current.in (), + scheduler, + deadline, + importance, + 30); + + if (worker1.activate (flags, 1, 0, max_prio) != 0) + { + ACE_ERROR ((LM_ERROR, + "(%t|%T) cannot activate worker thread.\n")); + } + + ACE_OS::sleep(2); + + ORBSVCS_Time::Time_Value_to_TimeT (deadline, + ACE_OS::gettimeofday () + + ACE_Time_Value (30,0) ); + + importance = 0; + Worker worker2 (orb.in (), + server.in (), + current.in (), + scheduler, + deadline, + importance, + 10); + + if (worker2.activate (flags, 1, 0, max_prio) != 0) + { + ACE_ERROR ((LM_ERROR, + "(%t|%T) cannot activate scheduler thread in RT mode.\n")); + } + + + worker1.wait (); + worker2.wait (); + + ACE_DEBUG ((LM_DEBUG, + "(%t): wait for worker threads done in main thread\n")); + + if (do_shutdown) + { + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + sched_param.importance = 0; + sched_param.deadline = 0; + CORBA::Policy_var sched_param_policy = + scheduler->create_scheduling_parameter (sched_param); + CORBA::Policy_ptr implicit_sched_param = 0; + current->begin_scheduling_segment (0, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_DEBUG ((LM_DEBUG, "(%t): about to call server shutdown\n")); + server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "after shutdown call in main thread\n")); + + + if (enable_dynamic_scheduling) + { + current->end_scheduling_segment (0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + + scheduler->shutdown (); + ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb, + Simple_Server_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load) + // int sleep_time) + : orb_ (CORBA::ORB::_duplicate (orb)), + server_ (Simple_Server::_duplicate (server_ptr)), + scheduler_current_ (RTScheduling::Current::_duplicate (current)), + scheduler_ (scheduler), + deadline_ (deadline), + importance_ (importance), + server_load_ (server_load) + // sleep_time_ (sleep_time) +{ +} + +int +Worker::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + const char * name = 0; + /* + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to sleep for %d sec\n", sleep_time_)); + ACE_OS::sleep (sleep_time_); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):woke up from sleep for %d sec\n", sleep_time_)); + */ + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + int prio; + + if (ACE_Thread::getprio (thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t|%T) worker activated with prio %d\n", prio)); + + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + CORBA::Policy_var sched_param_policy; + sched_param.importance = importance_; + sched_param.deadline = deadline_; + sched_param_policy = scheduler_->create_scheduling_parameter (sched_param); + CORBA::Policy_ptr implicit_sched_param = 0; + ACE_DEBUG ((LM_DEBUG, "(%t|%T):before begin_sched_segment\n")); + scheduler_current_->begin_scheduling_segment (name, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):after begin_sched_segment\n")); + } + + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to make two way call\n")); + server_->test_method (server_load_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):two way call done\n")); + + if (enable_dynamic_scheduling) + { + scheduler_current_->end_scheduling_segment (name); + ACE_CHECK_RETURN (-1); + } + + ACE_DEBUG ((LM_DEBUG, "client worker thread (%t) done\n")); + + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_server.cpp new file mode 100644 index 00000000000..604167378bf --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_prio_server.cpp @@ -0,0 +1,261 @@ +//$Id$ + +#include "test_i.h" +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "EDF_Scheduler.h" +#include "Task_Stats.h" + +ACE_RCSID(MT_Server, server, "server.cpp,v 1.3 2003/10/14 05:57:01 jwillemsen Exp") + +const char *ior_output_file = "test.ior"; + +int nthreads = 3; +int enable_dynamic_scheduling = 1; +const CORBA::Short max_importance = 100; +int enable_yield = 1; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:n:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case 'n': + nthreads = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 's': + enable_yield = 0; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "-d (enable dynamic scheduling)" + "-s (disable yield)" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb +}; + +Task_Stats task_stats; + +int +main (int argc, char *argv[]) +{ + EDF_Scheduler* scheduler = 0; + RTScheduling::Current_var current; + long flags; + int sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + + if (sched_policy == ACE_SCHED_RR) + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + else + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + + task_stats.init (100000); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + if (enable_dynamic_scheduling) + { + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + Simple_Server_i server_impl (orb.in (), + current.in (), + task_stats, + enable_yield); + + Simple_Server_var server = + server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG((LM_DEBUG,"(%t|%T) NOW I AM IN THE MAIN THREAD!\n")); + + Worker worker (orb.in ()); + if (worker.activate (flags, + nthreads, + 0, + ACE_Sched_Params::priority_max(sched_policy, + sched_scope)) != 0) + { + ACE_ERROR ((LM_ERROR, + "Cannot activate threads in RT class.", + "Trying to activate in non-RT class\n")); + + flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND; + if (worker.activate (flags, nthreads) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate server threads\n"), + 1); + } + } + + worker.wait (); + + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n")); + scheduler->shutdown (); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, "(%t|%T) NOW I AM ABOUT TO EXIT MAIN!\n")); + + ACE_DEBUG ((LM_DEBUG, "Exiting main...\n")); + task_stats.dump_samples ("timeline.txt", + "Time\t\tGUID", + ACE_High_Res_Timer::global_scale_factor ()); + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int +Worker::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_Time_Value tv(120); + + ACE_TRY + { + this->orb_->run (tv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + ACE_DEBUG ((LM_DEBUG, "(%t|%T): Worker thread exiting...\n")); + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp new file mode 100644 index 00000000000..28bbf435d87 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp @@ -0,0 +1,356 @@ +//$Id$ + +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "testC.h" +#include "EDF_Scheduler.h" +#include "orbsvcs/orbsvcs/Time_Utilities.h" + +ACE_RCSID(MT_Server, client, "client.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp") + +const char *ior = "file://test.ior"; +int do_shutdown = 0; +int enable_dynamic_scheduling = 1; +int enable_yield = 1; + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb, + Simple_Server_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load); + // int sleep_time); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb + + Simple_Server_var server_; + RTScheduling::Current_var scheduler_current_; + EDF_Scheduler* scheduler_; + TimeBase::TimeT deadline_; + long importance_; + CORBA::Long server_load_; + int sleep_time_; +}; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "xk:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'x': + do_shutdown = 1; + break; + + case 'k': + ior = get_opts.opt_arg (); + break; + + case 's': + enable_yield = 0; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-x (do shutdown)" + "-k <ior> " + "-s (disable yield)" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + EDF_Scheduler* scheduler=0; + RTScheduling::Current_var current; + int prio; + int max_prio; + ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + long flags; + + if (sched_policy == ACE_SCHED_RR) + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + else + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + + ACE_hthread_t main_thr_handle; + ACE_Thread::self (main_thr_handle); + + max_prio = ACE_Sched_Params::priority_max (sched_policy, + sched_scope); + + ACE_Sched_Params sched_params (sched_policy, max_prio); + + ACE_OS::sched_params (sched_params); + + if (ACE_Thread::getprio (main_thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio)); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var object = + orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Simple_Server_var server = + Simple_Server::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior), + 1); + } + + if (enable_dynamic_scheduling) + { + ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n")); + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + + TimeBase::TimeT deadline; + int importance=0; + + ORBSVCS_Time::Time_Value_to_TimeT (deadline, + ACE_OS::gettimeofday () + + ACE_Time_Value (50,0) ); + + Worker worker1 (orb.in (), + server.in (), + current.in (), + scheduler, + deadline, + importance, + 30); + + if (worker1.activate (flags, 1, 0, max_prio) != 0) + { + ACE_ERROR ((LM_ERROR, + "(%t|%T) cannot activate worker thread.\n")); + } + + + worker1.wait (); + + ACE_DEBUG ((LM_DEBUG, + "(%t): wait for worker threads done in main thread\n")); + + if (do_shutdown) + { + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + sched_param.importance = 0; + sched_param.deadline = 0; + CORBA::Policy_var sched_param_policy = + scheduler->create_scheduling_parameter (sched_param); + CORBA::Policy_ptr implicit_sched_param = 0; + current->begin_scheduling_segment (0, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_DEBUG ((LM_DEBUG, "(%t): about to call server shutdown\n")); + server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "after shutdown call in main thread\n")); + + + if (enable_dynamic_scheduling) + { + current->end_scheduling_segment (0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + + scheduler->shutdown (); + ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb, + Simple_Server_ptr server_ptr, + RTScheduling::Current_ptr current, + EDF_Scheduler* scheduler, + TimeBase::TimeT deadline, + long importance, + CORBA::Long server_load) + // int sleep_time) + : orb_ (CORBA::ORB::_duplicate (orb)), + server_ (Simple_Server::_duplicate (server_ptr)), + scheduler_current_ (RTScheduling::Current::_duplicate (current)), + scheduler_ (scheduler), + deadline_ (deadline), + importance_ (importance), + server_load_ (server_load) + // sleep_time_ (sleep_time) +{ +} + +int +Worker::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + const char * name = 0; + /* + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to sleep for %d sec\n", sleep_time_)); + ACE_OS::sleep (sleep_time_); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):woke up from sleep for %d sec\n", sleep_time_)); + */ + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + int prio; + + if (ACE_Thread::getprio (thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("getprio not supported\n") + )); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n") + ACE_TEXT ("thr_getprio failed"))); + } + } + + ACE_DEBUG ((LM_DEBUG, "(%t|%T) worker activated with prio %d\n", prio)); + + if (enable_dynamic_scheduling) + { + EDF_Scheduling::SchedulingParameter sched_param; + CORBA::Policy_var sched_param_policy; + sched_param.importance = importance_; + sched_param.deadline = deadline_; + sched_param_policy = scheduler_->create_scheduling_parameter (sched_param); + CORBA::Policy_ptr implicit_sched_param = 0; + ACE_DEBUG ((LM_DEBUG, "(%t|%T):before begin_sched_segment\n")); + scheduler_current_->begin_scheduling_segment (name, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):after begin_sched_segment\n")); + } + + ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to make two way call\n")); + server_->test_method (server_load_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):two way call done\n")); + + if (enable_dynamic_scheduling) + { + scheduler_current_->end_scheduling_segment (name); + ACE_CHECK_RETURN (-1); + } + + ACE_DEBUG ((LM_DEBUG, "client worker thread (%t) done\n")); + + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp new file mode 100644 index 00000000000..1c0f7c52ef9 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp @@ -0,0 +1,257 @@ +//$Id$ + +#include "test_i.h" +#include "ace/Get_Opt.h" +#include "ace/Task.h" +#include "ace/High_Res_Timer.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "EDF_Scheduler.h" +#include "Task_Stats.h" + +ACE_RCSID(MT_Server, server, "server.cpp,v 1.3 2003/10/14 05:57:01 jwillemsen Exp") + +const char *ior_output_file = "test.ior"; + +int nthreads = 1; +int enable_dynamic_scheduling = 1; +const CORBA::Short max_importance = 100; +int enable_yield = 1; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:n:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case 'n': + nthreads = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 's': + enable_yield = 0; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "-n (thread num)" + "-s (disable yield)" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb); + // ctor + + virtual int svc (void); + // The thread entry point. + +private: + CORBA::ORB_var orb_; + // The orb +}; + +Task_Stats task_stats; + +int +main (int argc, char *argv[]) +{ + EDF_Scheduler* scheduler = 0; + RTScheduling::Current_var current; + long flags; + int sched_policy = ACE_SCHED_RR; + int sched_scope = ACE_SCOPE_THREAD; + + if (sched_policy == ACE_SCHED_RR) + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; + else + flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; + + task_stats.init (100000); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + if (enable_dynamic_scheduling) + { + CORBA::Object_ptr manager_obj = + orb->resolve_initial_references ("RTSchedulerManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_RTScheduler_Manager_var manager = + TAO_RTScheduler_Manager::_narrow (manager_obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; + if (enable_yield) + { + disp_impl_type = Kokyu::DSRT_CV_BASED; + } + else + { + disp_impl_type = Kokyu::DSRT_OS_BASED; + } + + ACE_NEW_RETURN (scheduler, + EDF_Scheduler (orb.in (), + disp_impl_type, + sched_policy, + sched_scope), -1); + + manager->rtscheduler (scheduler); + + CORBA::Object_var object = + orb->resolve_initial_references ("RTScheduler_Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + current = + RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + Simple_Server_i server_impl (orb.in (), + current.in (), + task_stats, + enable_yield); + + Simple_Server_var server = + server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + Worker worker (orb.in ()); + if (worker.activate (flags, + nthreads, + 0, + ACE_Sched_Params::priority_max(sched_policy, + sched_scope)) != 0) + { + ACE_ERROR ((LM_ERROR, + "Cannot activate threads in RT class.", + "Trying to activate in non-RT class\n")); + + flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND; + if (worker.activate (flags, nthreads) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate server threads\n"), + 1); + } + } + + worker.wait (); + + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n")); + scheduler->shutdown (); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, "Exiting main...\n")); + task_stats.dump_samples ("timeline.txt", + "Time\t\tGUID", + ACE_High_Res_Timer::global_scale_factor ()); + return 0; +} + +// **************************************************************** + +Worker::Worker (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int +Worker::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_Time_Value tv(120); + + ACE_TRY + { + this->orb_->run (tv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + ACE_DEBUG ((LM_DEBUG, "(%t|%T): Worker thread exiting...\n")); + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_client.xml b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_client.xml new file mode 100644 index 00000000000..6cf9e4b3a3c --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_client.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "ec_config.dtd"> +<testconfig> + <sink> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW"/> + <importance value="VERY_LOW"/> + <num_entities>10</num_entities> + </sink> + <sink> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH" /> + <importance value="VERY_HIGH" /> + <num_entities>10</num_entities> + </sink> +</testconfig> diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.dtd b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.dtd new file mode 100644 index 00000000000..31a4cdaf457 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.dtd @@ -0,0 +1,11 @@ + <!ELEMENT testconfig (test_config_t*) > + <!ELEMENT sink (type,period,criticality,importance,num_entities) > + <!ELEMENT source (type,period,criticality,importance,num_entities) > + <!ELEMENT type (#PCDATA) > +<!-- period is in milliseconds --> + <!ELEMENT period (#PCDATA) > + <!ELEMENT criticality EMPTY > + <!ELEMENT importance EMPTY > + <!ELEMENT num_entities (#PCDATA) > + <!ATTLIST criticality value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > + <!ATTLIST importance value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.xml b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.xml new file mode 100644 index 00000000000..d5d6274062e --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_config.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "ec_config.dtd"> +<testconfig> + <source> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW" /> + <importance value="VERY_LOW" /> + <num_entities>10</num_entities> + </source> + <source> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH"/> + <importance value="VERY_HIGH"/> + <num_entities>10</num_entities> + </source> + + <sink> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW"/> + <importance value="VERY_LOW"/> + <num_entities>10</num_entities> + </sink> + <sink> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH" /> + <importance value="VERY_HIGH" /> + <num_entities>10</num_entities> + </sink> +</testconfig> diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.cpp new file mode 100644 index 00000000000..b8934f4c91e --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.cpp @@ -0,0 +1,202 @@ +// $Id$ + +#include "Consumer.h" + +#include <sstream> //for ostringstream + +#include "ace/Thread.h" +#include "orbsvcs/Event_Utilities.h" //for ACE_Supplier/ConsumerQOS_Factory +#include "orbsvcs/RtecSchedulerC.h" + +ACE_RCSID(EC_Examples, Consumer, "$Id$") + +Consumer::Consumer (void) + : _consumer(this) + , _consumer_id(-1) +{ +} + +Consumer::~Consumer(void) +{ +} + +void +Consumer::connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->connect_impl(false, + scheduler, + entry_prefix, + consumer_id, + event_type, + 0, //period; ignored + RtecScheduler::VERY_LOW_IMPORTANCE, //ignored + RtecScheduler::VERY_LOW_CRITICALITY, //ignored + ec + ACE_ENV_ARG_PARAMETER); +} + +void +Consumer::connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->connect_impl(true, + scheduler, + entry_prefix, + consumer_id, + event_type, + period, + importance, + criticality, + ec + ACE_ENV_ARG_PARAMETER); +} + +void +Consumer::connect_impl (bool set_rtinfo, //true if should set RT_Info + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->_consumer_id = consumer_id; + + //create consumer RT_Info + std::ostringstream cons_entry_pt; + cons_entry_pt << entry_prefix; //unique RT_Info entry point + ACE_DEBUG((LM_DEBUG,"Creating %s\n",cons_entry_pt.str().c_str())); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\tcriticality: %d\n",importance,criticality)); + RtecScheduler::handle_t rt_info = scheduler->create (cons_entry_pt.str().c_str() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (set_rtinfo) + { + //ignore period, since it will propagate from Supplier + RtecScheduler::Period_t p = 0;//period; + + ACE_Time_Value tv (0,0); + TimeBase::TimeT tmp; + ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv); + scheduler->set (rt_info, + criticality, + tmp,tmp,tmp, + p, + importance, + tmp, + 0, + RtecScheduler::OPERATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ACE_DEBUG((LM_DEBUG,"Set Consumer %d RT_Info\n",this->_consumer_id)); + ACE_DEBUG((LM_DEBUG,"\tcriticality: %d\n",criticality)); + ACE_DEBUG((LM_DEBUG,"\tTimes (worst,typical,cached): %d, %d, %d\n",tmp,tmp,tmp)); + ACE_DEBUG((LM_DEBUG,"\tperiod: %d\n",p)); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\n",importance)); + ACE_DEBUG((LM_DEBUG,"\tquantum: %d\n",tmp)); + } else + { + ACE_DEBUG((LM_DEBUG,"NOT Set Consumer %d RT_Info\n",this->_consumer_id)); + } + + // Register as consumer of appropriate event type + ACE_ConsumerQOS_Factory consQoS; + consQoS.insert_type(event_type, + rt_info); + + RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = + ec->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = + consumer_admin->obtain_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventComm::PushConsumer_var consumerv = + this->_consumer._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy->connect_push_consumer (consumerv.in (), + consQoS.get_ConsumerQOS () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG((LM_DEBUG,"Consumer %d connected\n",this->_consumer_id)); + ACE_DEBUG((LM_DEBUG,"\tEvent type: %d\n",event_type)); +} + +void +Consumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + //disconnect consumer + + if (! CORBA::is_nil (this->_supplier_proxy.in())) + { + this->_supplier_proxy->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = RtecEventChannelAdmin::ProxyPushSupplier::_nil(); + + //Deactivate the servant + PortableServer::POA_var poa = + this->_consumer._default_POA(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (&this->_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object(id.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ACE_DEBUG((LM_DEBUG,"Consumer %d disconnected\n",this->_consumer_id)); + } else + { + ACE_DEBUG((LM_DEBUG,"Cannot disconnect; Consumer %d not connected!\n",this->_consumer_id)); + } +} + +void +Consumer::push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (events.length () == 0) + { + ACE_DEBUG ((LM_DEBUG, + "Consumer (%P|%t) no events\n")); + return; + } + + int prio = -1; + ACE_hthread_t handle; + ACE_Thread::self(handle); + ACE_Thread::getprio(handle,prio); + //ACE_thread_t tid = ACE_Thread::self(); + ACE_DEBUG ((LM_DEBUG, "Consumer #%d @%d (%P|%t) we received event type %d\n", + this->_consumer_id,prio,events[0].header.type)); +} + +void +Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.h new file mode 100644 index 00000000000..800bc309f3b --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_consumer.h @@ -0,0 +1,109 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Consumer +// +// = AUTHOR +// Bryan A. Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef CONSUMER_H +#define CONSUMER_H + +#include "orbsvcs/RtecEventChannelAdminC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Channel_Clients_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Consumer +{ + // = TITLE + // Simple consumer object + // + // = DESCRIPTION + // This class is a consumer of the events pushed by a TimeoutConsumer + // every timeout. + // + // It simply registers for the event type specified in its connect() + // function. + // +public: + Consumer (void); + // Default Constructor. + + virtual ~Consumer (void); + + void connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the consumer to the EC without setting anything + // in the RT_Info (such as period, criticality, etc.). The consumer + // subscribes to events with the specified event_type. + + void connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the consumer to the EC, setting RT_Info values + // for period, criticality, and importance. The consumer subscribes + // to events with the specified event_type. + + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + // Disconnect from the EC. + + // = The RtecEventComm::PushConsumer methods + + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +protected: + void connect_impl (bool set_rtinfo, //true if should set RT_Info + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method implements the Consumer::connect() methods; if the first + // parameter is false, then the RT_Info values are ignored. Otherwise, + // they are set. + +private: + RtecEventChannelAdmin::ProxyPushSupplier_var _supplier_proxy; + // We talk to the EC (as a consumer) using this proxy. + + ACE_PushConsumer_Adapter<Consumer> _consumer; + // We connect to the EC as a consumer so we can receive the + // timeout events. + + int _consumer_id; +}; + +#endif /* CONSUMER_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_server.xml b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_server.xml new file mode 100644 index 00000000000..8c10985f066 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_server.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "ec_config.dtd"> +<testconfig> + <source> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW" /> + <importance value="VERY_LOW" /> + <num_entities>10</num_entities> + </source> + <source> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH"/> + <importance value="VERY_HIGH"/> + <num_entities>10</num_entities> + </source> +</testconfig> diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.cpp new file mode 100644 index 00000000000..006adaa3ae2 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.cpp @@ -0,0 +1,193 @@ +// $Id$ + +#include "Supplier.h" +#include "orbsvcs/Event_Utilities.h" //for ACE_Supplier/ConsumerQOS_Factory +#include "orbsvcs/Event_Service_Constants.h" + +ACE_RCSID(EC_Examples, Supplier, "$Id$") + +Supplier::Supplier (void) + : timeoutconsumer(this) + , _supplier(this) +{ +} + +Supplier::~Supplier() +{ +} + +void +Supplier::update(ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_DEBUG((LM_DEBUG,"Supplier %d (%P|%t) received update\n",this->_supplier_id)); + + if (this->_num_sent < this->_to_send) + { + //send this->_events + this->_consumer_proxy->push(this->_events ACE_ENV_ARG_PARAMETER); + + ++this->_num_sent; + ACE_DEBUG((LM_DEBUG,"Sent events; %d sent\t%d total\n",this->_num_sent,this->_to_send)); + if (this->_num_sent >= this->_to_send) + { + //just finished; only want to do this once! + ACE_DEBUG((LM_DEBUG,"RELEASE read lock from Supplier %d\n", + this->_supplier_id)); + this->_done->release(); + this->_hold_mtx = 0; + } + } + else + { + //do nothing + } +} + +void +Supplier::connect (ACE_RW_Mutex* done, + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventComm::EventSourceID supplier_id, + size_t to_send, + const RtecEventComm::EventSet& events, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->_supplier_id = supplier_id; + this->_to_send = to_send; + this->_num_sent = 0; + this->_hold_mtx = 0; + this->_done = done; + if (this->_done!= 0 && this->_num_sent<this->_to_send) + { + int ret = done->acquire_read(); + if (ret == -1) + { + ACE_DEBUG((LM_DEBUG,"ERROR: Could not acquire read lock for Supplier: %s\n", + ACE_OS::strerror(errno))); + } else + { + ACE_DEBUG((LM_DEBUG,"ACQUIRED read lock for Supplier %d\n",this->_supplier_id)); + this->_hold_mtx = 1; + } + } else + { + ACE_DEBUG((LM_DEBUG,"Already done; did not grab read lock for Supplier %d\n",this->_supplier_id)); + } + + this->_events.length(events.length()); + for (size_t i=0; i<events.length(); ++i) + { + this->_events[i] = events[i]; //copy event to local set + this->_events[i].header.source = this->_supplier_id; //make sure event source is this + } + + //create supplier RT_Info + std::ostringstream supp_entry_pt; + supp_entry_pt << entry_prefix << " Supplier " << this->_supplier_id; //unique RT_Info entry point + ACE_DEBUG((LM_DEBUG,"Creating %s\n",supp_entry_pt.str().c_str())); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\tcriticality: %d\n",importance,criticality)); + RtecScheduler::handle_t rt_info = scheduler->create (supp_entry_pt.str().c_str() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ACE_Time_Value tv (0,0); + TimeBase::TimeT tmp; + ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv); + scheduler->set (rt_info, + criticality, + tmp,tmp,tmp, + period, + importance, + tmp, + 0, + RtecScheduler::OPERATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Register as supplier of events + ACE_SupplierQOS_Factory supplierQOS; + for (size_t i=0; i<events.length(); ++i) + { + //insert type for each event + supplierQOS.insert (this->_supplier_id, + events[i].header.type, + rt_info, + 1); + } + + RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = + ec->for_suppliers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy = + supplier_admin->obtain_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventComm::PushSupplier_var supplierv = + this->_supplier._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy->connect_push_supplier (supplierv.in (), + supplierQOS.get_SupplierQOS () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG((LM_DEBUG,"Supplier %d connected\n",this->_supplier_id)); + for (size_t i=0; i<events.length(); ++i) + { + ACE_DEBUG((LM_DEBUG,"\tEvent Type: %d\n",events[i].header.type)); + } + + //connect TimeoutConsumer for timeouts. + this->timeoutconsumer.connect(scheduler,supp_entry_pt.str().c_str(),period, + importance,criticality,ec ACE_ENV_ARG_PARAMETER); + + //Add Scheduler dependency between TimeoutConsumer and Supplier + scheduler->add_dependency (this->timeoutconsumer.get_RT_Info(), + rt_info, + 1, + RtecBase::TWO_WAY_CALL + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + +} + +void +Supplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + if (! CORBA::is_nil (this->_consumer_proxy.in ())) + { + this->_consumer_proxy->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy = + RtecEventChannelAdmin::ProxyPushConsumer::_nil (); + + // Deactivate the servant + PortableServer::POA_var poa = + this->_supplier._default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (&this->_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + this->timeoutconsumer.disconnect(ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +Supplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.h new file mode 100644 index 00000000000..3d31dce16d3 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_supplier.h @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Supplier +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef SUPPLIER_H +#define SUPPLIER_H + +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Channel_Clients_T.h" +#include "ace/RW_Mutex.h" +#include "TimeoutConsumer.h" +#include <sstream> //for ostringstream + + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Supplier : Timeout_Observer +{ + // = TITLE + // Simple supplier object which responds to timeout events. + // + // = DESCRIPTION + // This class is an event supplier which responds to EC timeouts. + // For each timeout event it is notified of (via a TimeoutConsumer object), + // it pushes a specified EventSet into the EC. + // + // There are several ways to connect and disconnect this class, + // and it is up to the driver program to use the right one. + // +public: + Supplier (void); + // Default Constructor. + + virtual ~Supplier (void); + + virtual void update(ACE_ENV_SINGLE_ARG_DECL); + + void connect (ACE_RW_Mutex* done, + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventComm::EventSourceID supplier_id, + size_t to_send, + const RtecEventComm::EventSet& events, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the supplier to the EC. + + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + // Disconnect from the EC. + + // = The RtecEventComm::PushSupplier methods + + virtual void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +private: + size_t _to_send; //number of times to push on timeout + size_t _num_sent; //number of pushes so far + int _hold_mtx; //1 when hold _done mutex; 0 else + ACE_RW_Mutex* _done; //release read lock when _num_sent >= _to_send + + TimeoutConsumer timeoutconsumer; + + RtecEventComm::EventSourceID _supplier_id; + // We generate an id based on the name.... + + RtecEventChannelAdmin::ProxyPushConsumer_var _consumer_proxy; + // We talk to the EC (as a supplier) using this proxy. + + ACE_PushSupplier_Adapter<Supplier> _supplier; + // We connect to the EC as a supplier so we can push events + // every time we receive a timeout event. + + RtecEventComm::EventSet _events; + // set of events to push when a timeout event is received. +}; + +#endif /* SUPPLIER_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.cpp new file mode 100644 index 00000000000..38856c00c9b --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.cpp @@ -0,0 +1,148 @@ +// $Id$ + +#include <dsui_types.h> +#include "ace/Array.h" +#include "ace/Bound_Ptr.h" +#include "ace/Synch.h" +#include "ace/Get_Opt.h" +#include "ace/String_Base.h" +#include "ace/Dynamic_Service.h" +#include "orbsvcs/Event/EC_Kokyu_Factory.h" +#include "orbsvcs/Event/EC_Gateway_IIOP_Factory.h" +#include "ACEXML/parser/parser/Parser.h" +#include "ACEXML/common/InputSource.h" +#include "ACEXML/common/FileCharStream.h" +#include "ACEXML/common/DefaultHandler.h" + +#include "Config_Factory.h" +#include "Test_Handler.h" + +using namespace TestConfig; +using namespace ConfigFactory; + +struct Arguments +{ + ACE_CString filename_; +}; + +int parse_args (int argc, char *argv[],Arguments &args); + +int +main (int argc, char *argv[]) +{ + TAO_EC_Gateway_IIOP_Factory::init_svcs(); + Default_Config_Factory::init_svcs(); + + int retval = 0; + ds_control ctrl ("Test start","ec_test.dsui"); + + ACEXML_TRY_NEW_ENV + { + ACEXML_Parser parser; + Arguments args; + args.filename_.set(ACE_TEXT("ec_config.xml")); + + // parse args for config filename + if (parse_args(argc,argv,args) == -1) + { + return 1; + } + + ACEXML_FileCharStream *fcs = new ACEXML_FileCharStream(); + if ((retval = fcs->open(args.filename_.c_str())) != 0) { + ACE_DEBUG ((LM_DEBUG, "Could not open file %s\n",args.filename_.c_str())); + return retval; + } + + ACEXML_InputSource is (fcs); //takes responsibility of fcs + + Test_Handler handler (args.filename_.c_str()); + ACEXML_DefaultHandler dflt; + + parser.setContentHandler (&handler); + parser.setDTDHandler (&dflt); + parser.setErrorHandler (&handler); + parser.setEntityResolver (&dflt); + + parser.parse(&is); + ACEXML_TRY_CHECK; + + if ((retval = fcs->close()) != 0) { + ACE_DEBUG ((LM_DEBUG, "Could not close file %s\n",args.filename_.c_str())); + return retval; + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished parsing\n"))); + + // configure according to parsed XML + + //get Config_Factory service + Config_Factory *fact( + ACE_Dynamic_Service<Config_Factory>::instance ("Config_Factory")); + + if (fact == 0) + { + ACE_NEW_RETURN (fact, + Default_Config_Factory,-1); + } + + Test_Config *backend = fact->create_testconfig(); + if (0 == backend) { + ACE_DEBUG((LM_DEBUG, "Error: could not create back end!\n")); + return 1; + } + + TCFG_SET_WPTR cfg_ptr(handler.get_configs()); + + int retval = 0; + if ((retval = backend->configure(cfg_ptr)) != 0) { + ACE_DEBUG((LM_DEBUG, "Error configuring back end! (%d)\n",retval)); + return retval; + } + + if ((retval = backend->run()) != 0) { + ACE_DEBUG((LM_DEBUG, "Error running back end! (%d)\n",retval)); + return retval; + } + + fact->destroy_testconfig(backend); + fact->fini(); + + } + ACEXML_CATCH (ACEXML_SAXException, ex) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred: %s. Exiting...\n"), + ex.message())); + return 1; + } + ACEXML_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished successfully\n"))); + + return retval; +} + +int parse_args (int argc, char *argv[], Arguments &args) +{ + ACE_Get_Opt get_opts (argc, argv, "f:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + args.filename_.set(get_opts.opt_arg()); + ACE_DEBUG((LM_DEBUG,ACE_TEXT("Filename argument: %s\n"),args.filename_.c_str())); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-f <filename>] " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.dsui b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.dsui new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.dsui diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.mpc b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.mpc new file mode 100644 index 00000000000..4b361e601ec --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/ec_test.mpc @@ -0,0 +1,13 @@ +project(ectest_app): orbsvcsexe, rtevent, rtsched, rtschedevent, kokyu, acexml { + exename = ectest + after += test_driver_lib + libs += wrappers Test_Driver + includes += $(TAO_ROOT)/orbsvcs/examples/RtEC/test_driver + + Source_Files { + ec_test.cpp + } + + IDL_Files { + } +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/edf_example.mpc b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/edf_example.mpc new file mode 100644 index 00000000000..37d4286e5c3 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/edf_example.mpc @@ -0,0 +1,33 @@ +project(prio_server): kokyu_dsrt_scheduler_server { + exename = prio_server + Source_Files { + test_i.cpp + dt_prio_server.cpp + } +} + +project(twoway_server): kokyu_dsrt_scheduler_server { + exename = twoway_server + Source_Files { + test_i.cpp + dt_twoway_server.cpp + } +} + +project(prio_client): orbsvcsexe, kokyu_dsrt_scheduler_client { + exename = prio_client + libs += TAO_Svc_Utils + Source_Files { + testC.cpp + dt_prio_client.cpp + } +} +project(twoway_client): orbsvcsexe, kokyu_dsrt_scheduler_client { + exename = twoway_client + libs += TAO_Svc_Utils + Source_Files { + testC.cpp + dt_twoway_client.cpp + } +} + diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/svc.conf b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/svc.conf new file mode 100644 index 00000000000..ae8708fded9 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/svc.conf @@ -0,0 +1,4 @@ +# $Id$ +static EC_Factory "-ECProxyPushConsumerCollection mt:immediate:list -ECProxyPushSupplierCollection mt:immediate:list -ECdispatching kokyu -ECscheduling kokyu -ECfiltering kokyu -ECproxyconsumerlock thread -ECproxysupplierlock thread -ECsupplierfiltering per-supplier -ECObserver basic" +static Config_Factory "-ECConfig edf" +static EC_Gateway_IIOP_Factory "-ECGIIOPConsumerECControl reactive -ECGIIOPUseConsumerProxyMap 0"
\ No newline at end of file diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test.idl b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test.idl new file mode 100644 index 00000000000..8e4147982b9 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test.idl @@ -0,0 +1,8 @@ +//$Id$ + +interface Simple_Server +{ + long test_method (in long x); + + void shutdown (); +}; diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1.idl b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1.idl new file mode 100644 index 00000000000..a2da26ab405 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1.idl @@ -0,0 +1,8 @@ +//$Id$ + +interface Simple_Server1 +{ + oneway void test_method (in long x, in long y); + + void shutdown (); +}; diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp new file mode 100644 index 00000000000..baf9408678b --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp @@ -0,0 +1,159 @@ +//$Id$ + +#include "test1_i.h" +#include "ace/High_Res_Timer.h" +#include "ace/Task.h" +#include "ace/ACE.h" +#include "tao/debug.h" +#include "orbsvcs/orbsvcs/Time_Utilities.h" +#include "EDF_Scheduler.h" +#include "Task_Stats.h" + +#include "dt_oneway_config.h" +#include "dt_oneway_dsui_families.h" +#include <dsui.h> + +#if !defined(__ACE_INLINE__) +#include "test1_i.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(MT_Server, test1_i, "test1_i.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp") + +int Deadline_missed = 0; + +void +Simple_Server1_i::test_method (CORBA::Long exec_duration, CORBA::Long deadline ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + + + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + int prio; + int guid; + + ACE_OS:: + memcpy (&guid, + this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->get_buffer (), + sizeof (this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->length ())); + + DSUI_EVENT_LOG (TEST_ONE_FAM, START_SERVICE, guid, 0, NULL); + + ACE_High_Res_Timer timer; + ACE_Time_Value elapsed_time; + + ACE_DEBUG ((LM_DEBUG, "Request in thread %t\n")); + + if (ACE_Thread::getprio (thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_DEBUG((LM_DEBUG, + ACE_TEXT ("getprio not supported on this platform\n") + )); + return; + } + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("getprio failed")) + ); + } + + ACE_DEBUG ((LM_DEBUG, + "Request in thread %t, prio = %d," + "exec duration = %u\n", prio, exec_duration)); + + static CORBA::ULong prime_number = 9619899; + + ACE_Time_Value compute_count_down_time (exec_duration, 0); + ACE_Countdown_Time compute_count_down (&compute_count_down_time); + + //Applicable only for CV based implementations + //yield every 1 sec + ACE_Time_Value yield_interval (0,100000); + + ACE_Time_Value yield_count_down_time (yield_interval); + ACE_Countdown_Time yield_count_down (&yield_count_down_time); + + timer.start (); + int j=0; + while (compute_count_down_time > ACE_Time_Value::zero) + { + ACE::is_prime (prime_number, + 2, + prime_number / 2); + + ++j; + +#ifdef KOKYU_DSRT_LOGGING +// if (j%1000 == 0) +// { +// ACE_DEBUG ((LM_DEBUG, +// "(%t|%T) loop # = %d, load = %usec\n", j, exec_duration)); +// } +#endif + if (j%1000 == 0) + { + ACE_Time_Value run_time = ACE_OS::gettimeofday (); + task_stats_.sample (ACE_UINT64 (run_time.msec ()), guid); + } + + compute_count_down.update (); + + if (enable_yield_) + { + yield_count_down.update (); + if (yield_count_down_time <= ACE_Time_Value::zero) + { + CORBA::Policy_var sched_param_policy = + CORBA::Policy::_duplicate (current_-> + scheduling_parameter(ACE_ENV_SINGLE_ARG_PARAMETER)); + + const char * name = 0; + + CORBA::Policy_var implicit_sched_param = sched_param_policy; + current_->update_scheduling_segment (name, + sched_param_policy.in (), + implicit_sched_param.in () + ACE_ENV_ARG_PARAMETER); + yield_count_down_time = yield_interval; + yield_count_down.start (); + } + } + } + + TimeBase::TimeT current; + ORBSVCS_Time::Time_Value_to_TimeT (current, ACE_OS::gettimeofday ()); + CORBA::Long temp = (long) current; + if(temp > deadline ) + Deadline_missed=Deadline_missed +1; + + timer.stop (); + timer.elapsed_time (elapsed_time); + + + ACE_DEBUG ((LM_DEBUG, + "Request processing in thread %t done, " + "prio = %d, load = %d, elapsed time = %umsec, deadline_missed = %d\n", + prio, exec_duration, elapsed_time.msec (),Deadline_missed )); +/*DTTIME: + recording the finishing time on the server side. please also record the deadline_missed variable. +*/ + char* format = "Deadline missed: %d"; + char* extra_info = (char*) ACE_Allocator::instance()->malloc (strlen(format) + sizeof (Deadline_missed) - 2); + if (extra_info != 0) { + ACE_OS::sprintf(extra_info, "Deadline missed: %d", Deadline_missed); + DSUI_EVENT_LOG (TEST_ONE_FAM, DEADLINE_MISSED, guid, strlen(extra_info), extra_info); + } + ACE_Allocator::instance()->free(extra_info); + DSUI_EVENT_LOG (TEST_ONE_FAM, STOP_SERVICE, guid,0,NULL); +} + +void +Simple_Server1_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "shutdown request from client\n")); + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h new file mode 100644 index 00000000000..7b016ec37ab --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h @@ -0,0 +1,58 @@ +//$Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/MT_Server +// +// = FILENAME +// test1_i.h +// +// = AUTHOR +// Carlos O'Ryan +// +// ============================================================================ + +#ifndef TAO_MT_SERVER_TEST_I_H +#define TAO_MT_SERVER_TEST_I_H + +#include "test1S.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "Task_Stats.h" + +class Simple_Server1_i : public POA_Simple_Server1 +{ + // = TITLE + // Simpler Server implementation + // + // = DESCRIPTION + // Implements the Simple_Server1 interface in test1.idl + // +public: + Simple_Server1_i (CORBA::ORB_ptr orb, + RTScheduling::Current_ptr current, + Task_Stats&, + int); + // ctor + + // = The Simple_Server1 methods. + void test_method (CORBA::Long x, CORBA::Long y ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + RTScheduling::Current_var current_; + Task_Stats& task_stats_; + int enable_yield_; + // The ORB +}; + + +#if defined(__ACE_INLINE__) +#include "test1_i.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_MT_SERVER_TEST_I_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i new file mode 100644 index 00000000000..484e00ec734 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i @@ -0,0 +1,13 @@ +//$Id$ + +ACE_INLINE +Simple_Server1_i::Simple_Server1_i (CORBA::ORB_ptr orb, + RTScheduling::Current_ptr current, + Task_Stats& task_stats, + int enable_yield) + : orb_ (CORBA::ORB::_duplicate (orb)), + current_ (RTScheduling::Current::_duplicate (current)), + task_stats_ (task_stats), + enable_yield_ (enable_yield) +{ +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.cpp new file mode 100644 index 00000000000..1cbc77bac3c --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.cpp @@ -0,0 +1,129 @@ +//$Id$ + +#include "test_i.h" +#include "ace/High_Res_Timer.h" +#include "ace/Task.h" +#include "ace/ACE.h" +#include "tao/debug.h" + +#if !defined(__ACE_INLINE__) +#include "test_i.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(MT_Server, test_i, "test_i.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp") + +CORBA::Long +Simple_Server_i::test_method (CORBA::Long exec_duration ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + int prio; + int guid; + + ACE_OS:: + memcpy (&guid, + this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->get_buffer (), + sizeof (this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->length ())); + + ACE_High_Res_Timer timer; + ACE_Time_Value elapsed_time; + + ACE_DEBUG ((LM_DEBUG, "Request in thread %t\n")); + + if (ACE_Thread::getprio (thr_handle, prio) == -1) + { + if (errno == ENOTSUP) + { + ACE_DEBUG((LM_DEBUG, + ACE_TEXT ("getprio not supported on this platform\n") + )); + return 0; + } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("getprio failed")), + -1); + } + + ACE_DEBUG ((LM_DEBUG, + "Request in thread %t, prio = %d," + "exec duration = %u\n", prio, exec_duration)); + + static CORBA::ULong prime_number = 9619899; + + ACE_Time_Value compute_count_down_time (exec_duration, 0); + ACE_Countdown_Time compute_count_down (&compute_count_down_time); + + //Applicable only for CV based implementations + //yield every 1 sec + ACE_Time_Value yield_interval (1,0); + + ACE_Time_Value yield_count_down_time (yield_interval); + ACE_Countdown_Time yield_count_down (&yield_count_down_time); + + timer.start (); + int j=0; + while (compute_count_down_time > ACE_Time_Value::zero) + { + ACE::is_prime (prime_number, + 2, + prime_number / 2); + + ++j; + +#ifdef KOKYU_DSRT_LOGGING +// if (j%1000 == 0) +// { +// ACE_DEBUG ((LM_DEBUG, +// "(%t|%T) loop # = %d, load = %usec\n", j, exec_duration)); +// } +#endif + if (j%1000 == 0) + { + ACE_Time_Value run_time = ACE_OS::gettimeofday (); + task_stats_.sample (ACE_UINT64 (run_time.msec ()), guid); + } + + compute_count_down.update (); + + if (enable_yield_) + { + yield_count_down.update (); + if (yield_count_down_time <= ACE_Time_Value::zero) + { + CORBA::Policy_var sched_param_policy = + CORBA::Policy::_duplicate (current_-> + scheduling_parameter(ACE_ENV_SINGLE_ARG_PARAMETER)); + + const char * name = 0; + + CORBA::Policy_ptr implicit_sched_param = 0; + current_->update_scheduling_segment (name, + sched_param_policy.in (), + implicit_sched_param + ACE_ENV_ARG_PARAMETER); + yield_count_down_time = yield_interval; + yield_count_down.start (); + } + } + } + + timer.stop (); + timer.elapsed_time (elapsed_time); + + ACE_DEBUG ((LM_DEBUG, + "Request processing in thread %t done, " + "prio = %d, load = %d, elapsed time = %umsec\n", + prio, exec_duration, elapsed_time.msec () )); + + return exec_duration; +} + +void +Simple_Server_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "shutdown request from client\n")); + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.h new file mode 100644 index 00000000000..b5272fe567a --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.h @@ -0,0 +1,57 @@ +//$Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/MT_Server +// +// = FILENAME +// test_i.h +// +// = AUTHOR +// Carlos O'Ryan +// +// ============================================================================ + +#ifndef TAO_MT_SERVER_TEST_I_H +#define TAO_MT_SERVER_TEST_I_H + +#include "testS.h" +#include "tao/RTScheduling/RTScheduler_Manager.h" +#include "Task_Stats.h" + +class Simple_Server_i : public POA_Simple_Server +{ + // = TITLE + // Simpler Server implementation + // + // = DESCRIPTION + // Implements the Simple_Server interface in test.idl + // +public: + Simple_Server_i (CORBA::ORB_ptr orb, + RTScheduling::Current_ptr current, + Task_Stats&, + int); + // ctor + + // = The Simple_Server methods. + CORBA::Long test_method (CORBA::Long x ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + RTScheduling::Current_var current_; + Task_Stats& task_stats_; + int enable_yield_; + // The ORB +}; + +#if defined(__ACE_INLINE__) +#include "test_i.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_MT_SERVER_TEST_I_H */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.i b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.i new file mode 100644 index 00000000000..a1fc295ff6d --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test_i.i @@ -0,0 +1,13 @@ +//$Id$ + +ACE_INLINE +Simple_Server_i::Simple_Server_i (CORBA::ORB_ptr orb, + RTScheduling::Current_ptr current, + Task_Stats& task_stats, + int enable_yield) + : orb_ (CORBA::ORB::_duplicate (orb)), + current_ (RTScheduling::Current::_duplicate (current)), + task_stats_ (task_stats), + enable_yield_ (enable_yield) +{ +} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_scheduler_config.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_scheduler_config.h new file mode 100644 index 00000000000..cccd8b004a0 --- /dev/null +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_scheduler_config.h @@ -0,0 +1,7 @@ +/* $Id$ */ +#ifndef EDF_SCHEDULER_CONFIG_H +#define EDF_SCHEDULER_CONFIG_H + +#define CONFIG_DSTREAM_EDF_SCHED + +#endif /* EDF_SCHEDULER_CONFIG_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.cpp new file mode 100644 index 00000000000..fe901fa33e4 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.cpp @@ -0,0 +1,31 @@ +// $Id$ + +#include "AddrServer.h" + +ACE_RCSID(EC_Examples, AddrServer, "$Id$") + +AddrServer::AddrServer (void) + : addr_ () +{ +} + +AddrServer::AddrServer (const RtecUDPAdmin::UDP_Addr& addr) + : addr_ (addr) +{ +} + +void +AddrServer::set_addr (const RtecUDPAdmin::UDP_Addr& addr + ACE_ENV_ARG_DECL_NOT_USED) +{ + this->addr_ = addr; +} + +void +AddrServer::get_addr (const RtecEventComm::EventHeader&, + RtecUDPAdmin::UDP_Addr_out addr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + addr = this->addr_; +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.h b/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.h new file mode 100644 index 00000000000..002ea94e57c --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/AddrServer.h @@ -0,0 +1,60 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Consumer +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// Based on previous work by Carlos O'Ryan (coryan@cs.wustl.edu) +// +// ============================================================================ + +#ifndef ADDRSERVER_H +#define ADDRSERVER_H +#include /**/ "ace/pre.h" + +#include "orbsvcs/RtecUDPAdminS.h" + +class AddrServer : public POA_RtecUDPAdmin::AddrServer +{ + // = TITLE + // A simple AddrServer + // + // = DESCRIPTION + // The EC is able to use multiple multicast groups to transmit its + // data, the is given control over the mapping between the Event + // (type,source) pair and the (ipaddr,port) pair using a + // AddrServer. + // This class implements a very simple server that simply maps the + // <type> component to the <ipaddr> and uses a fixed <port>, + // provided at initialization time. + // +public: + AddrServer (void); + // Default Constructor + AddrServer (const RtecUDPAdmin::UDP_Addr& addr); + // Constructor + + //Allows the address to be set after the object is constructed + virtual void set_addr (const RtecUDPAdmin::UDP_Addr& addr + ACE_ENV_ARG_DECL_NOT_USED); + + // = The RtecUDPAdmin::AddrServer methods + virtual void get_addr (const RtecEventComm::EventHeader& header, + RtecUDPAdmin::UDP_Addr_out addr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + RtecUDPAdmin::UDP_Addr addr_; + // The address +}; + +#include /**/ "ace/post.h" +#endif /* ADDRSERVER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.cpp new file mode 100644 index 00000000000..10aa29d2945 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.cpp @@ -0,0 +1,173 @@ +// $Id$ + +#include "Config_Factory.h" +#include "ECConfig.h" + +#include "ace/Arg_Shifter.h" +#include "ace/OS_NS_strings.h" +#include "orbsvcs/Sched/Reconfig_Scheduler.h" + +#if ! defined (__ACE_INLINE__) +#include "Config_Factory.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Configurator, Default_Config_Factory, "$Id$") + +namespace ConfigFactory { + +typedef TAO_Reconfig_Scheduler<TAO_MUF_FAIR_Reconfig_Sched_Strategy, TAO_SYNCH_MUTEX> MUF_SCHED_TYPE; +typedef TAO_Reconfig_Scheduler<TAO_RMS_FAIR_Reconfig_Sched_Strategy, TAO_SYNCH_MUTEX> RMS_SCHED_TYPE; +typedef TAO_Reconfig_Scheduler<TAO_EDF_FAIR_Reconfig_Sched_Strategy, TAO_SYNCH_MUTEX> EDF_SCHED_TYPE; + +Config_Factory::~Config_Factory (void) +{ +} + +Default_Config_Factory::~Default_Config_Factory (void) +{ +} + +int +Default_Config_Factory::init_svcs (void) +{ + return ACE_Service_Config::static_svcs ()-> + insert (&ace_svc_desc_Default_Config_Factory); +} + +int +Default_Config_Factory::init (int argc, ACE_TCHAR* argv[]) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + while (arg_shifter.is_anything_left ()) + { + const ACE_TCHAR *arg = arg_shifter.get_current (); + + if (ACE_OS::strcasecmp (arg, ACE_LIB_TEXT("-ECConfig")) == 0) + { + arg_shifter.consume_arg (); + test_config_ = 0; + + if (arg_shifter.is_parameter_next ()) + { + const ACE_TCHAR* opt = arg_shifter.get_current (); + if ((ACE_OS::strcasecmp (opt, ACE_LIB_TEXT("null")) == 0) + || (ACE_OS::strcasecmp (opt, ACE_LIB_TEXT("rms")) == 0)) + { + this->sched_type_ = RMS; //default +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Scheduling type is RMS\n")); +*/ + } + else if (ACE_OS::strcasecmp (opt, ACE_LIB_TEXT("muf")) == 0) + { + this->sched_type_ = MUF; +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Scheduling type is MUF\n")); +*/ + } + else if (ACE_OS::strcasecmp (opt, ACE_LIB_TEXT("edf")) == 0) + { + this->sched_type_ = EDF; +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Scheduling type is EDF\n")); +*/ + } + else + { + ACE_ERROR ((LM_ERROR, + "Default_Config_Factory - " + "unsupported scheduling type <%s>\n", + opt)); + } + arg_shifter.consume_arg (); + } + } + else + { + arg_shifter.consume_arg (); +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory - " + "ignoring option <%s>\n", + arg)); +*/ + } + } + return 0; +} + +int +Default_Config_Factory::fini (void) +{ + return 0; +} + +TestConfig::Test_Config* +Default_Config_Factory::create_testconfig () +{ + if (this->test_config_ == 0) + { + switch (this->sched_type_) { + case EDF: +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Returning EDF Test_Config\n")); +*/ + return new TestConfig::ECConfig<EDF_SCHED_TYPE>(); + break; + case MUF: +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Returning MUF Test_Config\n")); +*/ + return new TestConfig::ECConfig<MUF_SCHED_TYPE>(); + break; + case RMS: +/* + ACE_DEBUG ((LM_DEBUG, + "Default_Config_Factory: Returning RMS Test_Config\n")); +*/ + return new TestConfig::ECConfig<RMS_SCHED_TYPE>(); + break; + default: +/* + ACE_ERROR ((LM_ERROR, + "Default_Config_Factory - " + "unknown scheduling type <%d>\n", + this->sched_type_)); +*/ + return 0; + }; + } //else... + return 0; +} + +void +Default_Config_Factory::destroy_testconfig (TestConfig::Test_Config *x) +{ + delete x; +} + +// **************************************************************** + +ACE_STATIC_SVC_DEFINE (Default_Config_Factory, + ACE_TEXT ("Config_Factory"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (Default_Config_Factory), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) +ACE_FACTORY_DEFINE (Test_Driver, Default_Config_Factory) + +// **************************************************************** + +} //namespace ConfigFactory + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.h b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.h new file mode 100644 index 00000000000..33810ae40a8 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.h @@ -0,0 +1,110 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = FILENAME +// Config_Factory +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef CONFIGFACTORY_H +#define CONFIGFACTORY_H + +#include "test_driver_export.h" +#include "TestConfig.h" +#include "ace/Service_Config.h" +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace ConfigFactory { + +/** + * @class Config_Factory + * + * @brief Abstract base factory for Test Configurators. + * + * Defines the Config_Factory interface. + * + * <H2>Memory Management</H2> + * The objects it creates are owned by this class, the client must + * invoke the corresponding destroy() method to release them. + */ +class Test_Driver_Export Config_Factory : public ACE_Service_Object +{ +public: + ///Constructor + Config_Factory (void) {} + + ///Destructor + virtual ~Config_Factory (void); + + /// Create and destroy the TestConfig module. + virtual TestConfig::Test_Config* create_testconfig () = 0; + virtual void destroy_testconfig (TestConfig::Test_Config *) = 0; + +}; + +/** Enumerates the different scheduling strategies certain + * Test_Configs generated by Config_Factories can use. + */ +enum Sched_Type { + RMS, + MUF, + EDF, + RMSMLF, + MIF +}; + +/** + * @class Default_Config_Factory + * + * @brief A generic factory for TestConfigs. + * + * This class allows the user to experiment with different TestConfig + * implementations. Using a command-line like interface the user + * can specify which strategies will this factory generate. + * Since the class can be dynamically loaded the strategies can be + * set in the service configurator file. + */ +class Test_Driver_Export Default_Config_Factory : public Config_Factory +{ +public: + /// Constructor + Default_Config_Factory (void); + + /// Destructor... + virtual ~Default_Config_Factory (void); + + /// Helper function to register the default factory into the service + /// configurator. + static int init_svcs (void); + + // = The Service_Object entry points + virtual int init (int argc, ACE_TCHAR* argv[]); + virtual int fini (void); + + virtual TestConfig::Test_Config* create_testconfig (); + + virtual void destroy_testconfig (TestConfig::Test_Config *); +protected: + int test_config_; + Sched_Type sched_type_; +}; + +ACE_STATIC_SVC_DECLARE (Default_Config_Factory) +ACE_FACTORY_DECLARE (Test_Driver, Default_Config_Factory) + +} /* namespace ConfigFactory */ + +#if defined (__ACE_INLINE__) +#include "Config_Factory.i" +#endif /* __ACE_INLINE__ */ + +#endif /* CONFIGFACTORY_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.i b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.i new file mode 100644 index 00000000000..8f19f638f08 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Config_Factory.i @@ -0,0 +1,13 @@ +// $Id$ + +namespace ConfigFactory { + +ACE_INLINE +Default_Config_Factory::Default_Config_Factory (void) + : Config_Factory (), + test_config_(0), //default to ECConfig + sched_type_(EDF) //default to EDF dispatching +{ +} + +} //namespace ConfigFactory diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.cpp new file mode 100644 index 00000000000..e7e45f6d84b --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.cpp @@ -0,0 +1,235 @@ +// $Id$ + +#include "Consumer.h" +#include "cpuload.h" + +#include <sstream> //for ostringstream + +#include "ace/Thread.h" +#include "orbsvcs/Event_Utilities.h" //for ACE_Supplier/ConsumerQOS_Factory +#include "orbsvcs/RtecSchedulerC.h" + +ACE_RCSID(EC_Examples, Consumer, "$Id$") + +Consumer::Consumer (void) + : _consumer(this) + , _consumer_id(-1) +{ +} + +Consumer::~Consumer(void) +{ +} + +void +Consumer::connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->connect_impl(false, + scheduler, + entry_prefix, + consumer_id, + event_type, + 0, //period; ignored + RtecScheduler::VERY_LOW_IMPORTANCE, //ignored + RtecScheduler::VERY_LOW_CRITICALITY, //ignored + ec + ACE_ENV_ARG_PARAMETER); +} + +void +Consumer::connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->connect_impl(true, + scheduler, + entry_prefix, + consumer_id, + event_type, + period, + importance, + criticality, + ec + ACE_ENV_ARG_PARAMETER); +} + +void +Consumer::connect_impl (bool set_rtinfo, //true if should set RT_Info + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + ACE_UNUSED_ARG(period); + this->_consumer_id = consumer_id; + + //create consumer RT_Info + std::ostringstream cons_entry_pt; + cons_entry_pt << entry_prefix; //unique RT_Info entry point + /* + ACE_DEBUG((LM_DEBUG,"Creating %s\n",cons_entry_pt.str().c_str())); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\tcriticality: %d\n",importance,criticality)); + */ + RtecScheduler::handle_t rt_info = scheduler->create (cons_entry_pt.str().c_str() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //TODO: How get period if !set_rtinfo? + if (set_rtinfo) + { + //ORBSVCS_Time::TimeT_to_Time_Value(this->_work_time,period); + //this->_work_time *= 0.5; //only work for half the period + //TODO: How much work should we do? + this->_work_time.set(1,0); //based on DT test, work is 1 second long + + //ignore period, since it will propagate from Supplier + RtecScheduler::Period_t p = 0;//period; + + ACE_Time_Value tv (0,0); + TimeBase::TimeT tmp; + ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv); + scheduler->set (rt_info, + criticality, + tmp,tmp,tmp, + p, + importance, + tmp, + 0, + RtecScheduler::OPERATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + /* + ACE_DEBUG((LM_DEBUG,"Set Consumer %d RT_Info\n",this->_consumer_id)); + ACE_DEBUG((LM_DEBUG,"\tcriticality: %d\n",criticality)); + ACE_DEBUG((LM_DEBUG,"\tTimes (worst,typical,cached): %d, %d, %d\n",tmp,tmp,tmp)); + ACE_DEBUG((LM_DEBUG,"\tperiod: %d\n",p)); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\n",importance)); + ACE_DEBUG((LM_DEBUG,"\tquantum: %d\n",tmp)); + */ + } else + { + ACE_DEBUG((LM_DEBUG,"NOT Set Consumer %d RT_Info\n",this->_consumer_id)); + } + + // Register as consumer of appropriate event type + ACE_ConsumerQOS_Factory consQoS; + consQoS.insert_type(event_type, + rt_info); + + RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = + ec->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = + consumer_admin->obtain_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventComm::PushConsumer_var consumerv = + this->_consumer._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy->connect_push_consumer (consumerv.in (), + consQoS.get_ConsumerQOS () + ACE_ENV_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG, "Consumer (%t) ")); + printf("object pointer (%p) ---> push_supplier (%p)\n", + this, + this->_supplier_proxy.in()); + + + ACE_CHECK; + + ACE_DEBUG((LM_DEBUG,"Consumer %d connected\n",this->_consumer_id)); + ACE_DEBUG((LM_DEBUG,"\tEvent type: %d\n",event_type)); + + //calibrate + //TODO: calibrate seems to cause Consumer's connect_push_consumer() to hang! + //this->_work.calibrate(); +} + +void +Consumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + //disconnect consumer + + if (! CORBA::is_nil (this->_supplier_proxy.in())) + { + this->_supplier_proxy->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = RtecEventChannelAdmin::ProxyPushSupplier::_nil(); + + //Deactivate the servant + PortableServer::POA_var poa = + this->_consumer._default_POA(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (&this->_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object(id.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ACE_DEBUG((LM_DEBUG,"Consumer %d disconnected\n",this->_consumer_id)); + } else + { + ACE_DEBUG((LM_DEBUG,"Cannot disconnect; Consumer %d not connected!\n",this->_consumer_id)); + } +} + +void +Consumer::push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (events.length () == 0) + { + ACE_DEBUG ((LM_DEBUG, + "Consumer (%P|%t) no events\n")); + return; + } + int prio = -1; + ACE_hthread_t handle; + ACE_Thread::self(handle); + ACE_Thread::getprio(handle,prio); + //ACE_thread_t tid = ACE_Thread::self(); + ACE_DEBUG ((LM_DEBUG, "Consumer #%d @%d (%P|%t) we received event type %d\n", + this->_consumer_id,prio,events[0].header.type)); + + //@BT INSTRUMENT with event ID: EVENT_WORK_START Measure time + //when work triggered by event starts. + + //do work + //what happens when run w/o calibratin? + timeval load = (timeval) this->_work_time; + this->_work.run(load); + + //@BT INSTRUMENT with event ID: EVENT_WORK_END Measure time when + //work triggered by event finishes. +} + +void +Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.h b/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.h new file mode 100644 index 00000000000..deb8bc56133 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Consumer.h @@ -0,0 +1,117 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Consumer +// +// = AUTHOR +// Bryan A. Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef CONSUMER_H +#define CONSUMER_H + +#include "ace/Time_Value.h" + +#include "orbsvcs/RtecEventChannelAdminC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Channel_Clients_T.h" + +#include "cpuload.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Consumer +{ + // = TITLE + // Simple consumer object + // + // = DESCRIPTION + // This class is a consumer of the events pushed by a TimeoutConsumer + // every timeout. + // + // It simply registers for the event type specified in its connect() + // function. + // +public: + Consumer (void); + // Default Constructor. + + virtual ~Consumer (void); + + void connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the consumer to the EC without setting anything + // in the RT_Info (such as period, criticality, etc.). The consumer + // subscribes to events with the specified event_type. + + void connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the consumer to the EC, setting RT_Info values + // for period, criticality, and importance. The consumer subscribes + // to events with the specified event_type. + + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + // Disconnect from the EC. + + // = The RtecEventComm::PushConsumer methods + + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +protected: + void connect_impl (bool set_rtinfo, //true if should set RT_Info + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + int consumer_id, //unique identifier + long event_type, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method implements the Consumer::connect() methods; if the first + // parameter is false, then the RT_Info values are ignored. Otherwise, + // they are set. + +private: + RtecEventChannelAdmin::ProxyPushSupplier_var _supplier_proxy; + // We talk to the EC (as a consumer) using this proxy. + + ACE_PushConsumer_Adapter<Consumer> _consumer; + // We connect to the EC as a consumer so we can receive the + // timeout events. + + ACE_Time_Value _work_time; + + int _consumer_id; + + CPULoad _work; +}; + +#endif /* CONSUMER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.cpp new file mode 100644 index 00000000000..7fd83b0b175 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.cpp @@ -0,0 +1,888 @@ +// $Id$ + +#ifndef ECCONFIG_C +#define ECCONFIG_C + +#include "ECConfig.h" +#include "Consumer.h" +#include "Supplier.h" +#include "ECConfig_Gateway.h" + +#include <sstream> //for ostringstream + +#include "ace/Array.h" +#include "ace/Bound_Ptr.h" +#include "ace/Thread_Manager.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Stream.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/SOCK_Connector.h" +#include "ace/SString.h" +#include "orbsvcs/Scheduler_Factory.h" +#include "orbsvcs/Event_Utilities.h" +#include "orbsvcs/Event_Service_Constants.h" +#include "orbsvcs/Event/EC_Event_Channel.h" +#include "orbsvcs/Event/EC_Kokyu_Factory.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/Event/EC_Gateway_Sched.h" + +//REACTOR CHANGE +#include "tao/ORB_Core.h" + +namespace TestConfig { + +//data passed to spawned thread + struct spawn_data_t { + ACE_RW_Mutex *lock; + CORBA::ORB_var *orb; + int *ready; + int use_federated; + int is_server; + }; + +//TODO: Obviously, we can't just hardcode these! +//And assuming only one supplier and consumer is bad, too. +const char *supplierEC_iorfile = + "supplierEC.ior"; +const char *supplierSched_iorfile = + "supplierSched.ior"; +const char *consumerEC_iorfile = + "consumerEC.ior"; +const char *consumerSched_iorfile = + "consumerSched.ior"; +const char *supplier_schedule = + "supplier_schedule.out"; +const char *consumer_schedule = + "consumer_schedule.out"; +const char *remote_inet_addr = + "bhangra.doc.wustl.edu"; +int remote_inet_port = 42424; + +template <class SCHED_STRAT> +ECConfig<SCHED_STRAT>::ECConfig (void) + : Test_Config () + , ec_impl(0) + , sched_impl(0) + , periods(0) + , importances(0) + , crits(0) + //, udp_mcast_address(ACE_DEFAULT_MULTICAST_ADDR ":10001") + , configured (0) //false + , use_federated (1) //TODO Check whether or not FEDERATED; default to true + //, use_federated (0) //TODO Check whether or not FEDERATED; default to false + , ready (0) +{ + this->test_done = new ACE_RW_Mutex(); +} + +template <class SCHED_STRAT> +ECConfig<SCHED_STRAT>::~ECConfig (void) +{ + this->reset(ACE_ENV_SINGLE_ARG_PARAMETER); + + delete this->test_done; +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::reset (ACE_ENV_SINGLE_ARG_DECL) +{ + // We should do a lot of cleanup (disconnect from the EC, + // deactivate all the objects with the POA, etc.). + + this->disconnect_suppliers(ACE_ENV_SINGLE_ARG_PARAMETER); //should release all read locks on this->test_done + + this->disconnect_consumers(ACE_ENV_SINGLE_ARG_PARAMETER); + + { + // Deactivate the EC + PortableServer::POA_var poa = + this->ec_impl->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this->ec_impl ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG ((LM_DEBUG, "EC deactivated\n")); + } + + { + // Deactivate the Scheduler + PortableServer::POA_var poa = + this->sched_impl->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this->sched_impl ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG ((LM_DEBUG, "scheduler deactivated\n")); + } + + if (this->use_federated && !CORBA::is_nil(this->gateway_obs.in())) + { + // Deactivate the Gateway if it exists + PortableServer::POA_var poa = + this->gateway_impl->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this->gateway_impl ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG ((LM_DEBUG, "gateway deactivated\n")); + } + + delete this->ec_impl; + this->ec_impl = 0; + + delete this->sched_impl; + this->sched_impl = 0; + + delete this->gateway_impl; + this->gateway_impl = 0; + + //TODO clear config_infos? + + //TODO clear RT_Infos from scheduler? + + configured = 0; //false + this->ready = 0; +} + +template <class SCHED_STRAT> int +ECConfig<SCHED_STRAT>::configure (TCFG_SET_WPTR testconfigs) +{ + if (this->configured) { + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Resetting EC\n"))); + this->reset(); //delete memory used by previous configuration + } + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->initEC(); + + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("EC Initialized\n"))); + + ////////////////// EC ready; do config //////////////////// + size_t tsize = testconfigs->size(); + size_t supp_size = 0; //number of suppliers (sources) + size_t cons_size = 0; //number of consumers (sinks) + this->testcfgs.size(tsize); + this->periods.size(tsize); + this->importances.size(tsize); + this->crits.size(tsize); + for (size_t i=0; i<tsize; ++i) + { + //ACE_Weak_Bound_Ptr doesn't have operator*()! ?? + //test_config_t *curcfg = (*testconfigs)[i]; + test_config_t *curcfg = (*testconfigs.unsafe_get())[i]; + this->testcfgs[i] = curcfg; + + switch (curcfg->criticality) { + case VERY_LOW_CRITICALITY : + this->crits[i] = RtecScheduler::VERY_LOW_CRITICALITY; + break; + case LOW_CRITICALITY : + this->crits[i] = RtecScheduler::LOW_CRITICALITY; + break; + case MEDIUM_CRITICALITY : + this->crits[i] = RtecScheduler::MEDIUM_CRITICALITY; + break; + case HIGH_CRITICALITY : + this->crits[i] = RtecScheduler::HIGH_CRITICALITY; + break; + case VERY_HIGH_CRITICALITY : + this->crits[i] = RtecScheduler::VERY_HIGH_CRITICALITY; + break; + } + + switch (curcfg->importance) { + case VERY_LOW_IMPORTANCE : + this->importances[i] = RtecScheduler::VERY_LOW_IMPORTANCE; + break; + case LOW_IMPORTANCE : + this->importances[i] = RtecScheduler::LOW_IMPORTANCE; + break; + case MEDIUM_IMPORTANCE : + this->importances[i] = RtecScheduler::MEDIUM_IMPORTANCE; + break; + case HIGH_IMPORTANCE : + this->importances[i] = RtecScheduler::HIGH_IMPORTANCE; + break; + case VERY_HIGH_IMPORTANCE : + this->importances[i] = RtecScheduler::VERY_HIGH_IMPORTANCE; + break; + } + + ACE_Time_Value tv; + tv.msec(curcfg->period); + ORBSVCS_Time::Time_Value_to_TimeT (this->periods[i], tv); + + if (curcfg->comptype == TestConfig::SOURCE) + { + ++supp_size; + } + else if (curcfg->comptype == TestConfig::SINK) + { + ++cons_size; + } + } + + //SUPPLIER writes IORs and blocks + if (supp_size > 0 && this->use_federated) + { + //since there are suppliers, we assume we are a supplier only + //save EC and scheduler IOR for federation + CORBA::String_var ior = + orb->object_to_string (this->event_channel.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG((LM_DEBUG,"Writing supplier EC IOR\n")); + // Output the EC's ior to the supplierEC iorfile + FILE *output_file = ACE_OS::fopen (supplierEC_iorfile, "w"); + if (output_file == 0) + ACE_ERROR ((LM_ERROR, + "Cannot open output file for writing EC IOR: %s\n", + supplierEC_iorfile)); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + ior = orb->object_to_string (this->scheduler.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + //ACE_DEBUG((LM_DEBUG,"Writing supplier Sched IOR\n")); + // Output the scheduler's ior to the supplierSched iorfile + output_file = ACE_OS::fopen (supplierSched_iorfile, "w"); + if (output_file == 0) + ACE_ERROR ((LM_ERROR, + "Cannot open output file for writing scheduler IOR: %s\n", + supplierSched_iorfile)); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + //now we block until the client writes its IOR + this->barrier(true); + + //block forever so I can debug effectively! + //this->barrier(true); + } + + //CONSUMER writes IORs and blocks + if (cons_size > 0 && this->use_federated) + { + //since there are consumers, we assume we are a consumer only + //save IOR for federation + CORBA::String_var ior = + orb->object_to_string (this->event_channel.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG((LM_DEBUG,"Writing consumer EC IOR\n")); + // Output the EC's ior to the consumerEC iorfile + FILE *output_file = ACE_OS::fopen (consumerEC_iorfile, "w"); + if (output_file == 0) + ACE_ERROR ((LM_ERROR, + "Cannot open output file for writing EC IOR: %s\n", + consumerEC_iorfile)); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + //ACE_DEBUG((LM_DEBUG,"Writing consumer Sched IOR\n")); + ior = orb->object_to_string (this->scheduler.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + // Output the scheduler's ior to the consumerSched iorfile + output_file = ACE_OS::fopen (consumerSched_iorfile, "w"); + if (output_file == 0) + ACE_ERROR ((LM_ERROR, + "Cannot open output file for writing scheduler IOR: %s\n", + consumerSched_iorfile)); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + //now we block until the supplier writes its IOR + this->barrier(false); + } + + if (this->use_federated && cons_size>0) //only federate on consumer side + { + //gateway EC_Control does not appear to setup gateway on + //activation, so we need to set it up BEFORE any consumers + //or suppliers connect! + this->make_federated(ACE_ENV_SINGLE_ARG_PARAMETER); + } + + this->consumers.size(cons_size); + this->connect_consumers(ACE_ENV_SINGLE_ARG_PARAMETER); + this->suppliers.size(supp_size); + this->connect_suppliers(ACE_ENV_SINGLE_ARG_PARAMETER); + + if (this->consumers.size() > 0) + { + //this->barrier(false); //wait until both apps are ready to schedule + } + + ////////////////// Configured; compute schedule /////////// + //ACE_DEBUG ((LM_DEBUG, "Computing schedule\n")); + RtecScheduler::RT_Info_Set_var infos; + RtecScheduler::Config_Info_Set_var configs; + RtecScheduler::Scheduling_Anomaly_Set_var anomalies; + RtecScheduler::Dependency_Set_var deps; + + // Obtain the range of valid priorities in the current + // platform, the scheduler hard-code this values in the + // generated file, but in the future we may just use the + // "logical" priorities and define the mapping to OS + // priorities at run-time. + int min_os_priority = + ACE_Sched_Params::priority_min (ACE_SCHED_FIFO, + ACE_SCOPE_THREAD); + int max_os_priority = + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, + ACE_SCOPE_THREAD); + this->scheduler->compute_scheduling (min_os_priority, + max_os_priority, + infos.out (), + deps.out (), + configs.out (), + anomalies.out () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Dump the schedule to a file... (different files for supplier and consumer) + if (this->suppliers.size() > 0) + { + ACE_Scheduler_Factory::dump_schedule (infos.in (), + deps.in(), + configs.in (), + anomalies.in (), + supplier_schedule); + } + if (this->consumers.size() > 0) + { + ACE_Scheduler_Factory::dump_schedule (infos.in (), + deps.in(), + configs.in (), + anomalies.in (), + consumer_schedule); + } + + ///////////// Activate the EC ///////////////// + //ACE_DEBUG ((LM_DEBUG, "activating EC\n")); + this->ec_impl->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + //ACE_DEBUG ((LM_DEBUG, "EC activated\n")); + + if (this->suppliers.size() > 0) + { + //this->barrier(true); //wait until both apps are ready to schedule + } + + configured = 1; //true + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ECConfig"); + return 1; + } + ACE_ENDTRY; + return 0; //successful config +} + +template <class SCHED_STRAT> int +ECConfig<SCHED_STRAT>::run (void) +{ + //ACE_DEBUG ((LM_DEBUG, "Running ECConfig\n")); + if (!this->configured) { + //ACE_DEBUG ((LM_DEBUG, "Tried to run before configured\n")); + return 1; + } + + this->ready = 0; //ensure suppliers don't start when orb runs yet + + ACE_TRY + { + ACE_Thread_Manager *inst = ACE_Thread_Manager::instance(); + //ACE_Reactor *reactor = ACE_Reactor::instance(); + + // Spawn orb thread (which calls orb.run(), then terminates on return) + //ACE_DEBUG((LM_DEBUG,"SPAWNING ORB thread\n")); + //int ret = inst->spawn(ECConfig<SCHED_STRAT>::run_orb,&(this->orb)); + spawn_data_t *data = new spawn_data_t; + //printf("data points to %p\n",(void*)(data)); + //printf("setting data->lock to %p\n",(void*)(this->test_done)); + data->lock = this->test_done; + //printf("data->lock = %p\n",(void*)(data->lock)); + data->orb = &(this->orb); + //printf("data->orb = %p\n",(void*)(data->orb)); + data->ready = &(this->ready); + data->use_federated = this->use_federated; + data->is_server = this->suppliers.size()>0; //assume client if no suppliers + //int ret = inst->spawn(ECConfig<SCHED_STRAT>::run_orb,data); + //int ret = inst->spawn(ECConfig<SCHED_STRAT>::run_orb,reactor); + //no need for getting tid? + /* + if (ret == -1) + { + ACE_DEBUG ((LM_DEBUG, "ERROR: Couldn't spawn ORB->run() thread: %s\n", + ACE_OS::strerror(errno))); + return 1; + } + */ + orb->run(); + //this method returns when orb->shutdown() is called; then thread exits + + /* + //REACTOR CHANGE + //orb->orb_core()->reactor()->run_reactor_event_loop(); + ACE_DEBUG((LM_DEBUG,"Starting Reactor loop; work? %d\n", + reactor->work_pending())); + + //@BT INSTRUMENT with event ID: EVENT_TEST_BEGIN Measure time + //when test starts being able to push events. + reactor->run_reactor_event_loop(); + //this method returns when end_reactor_event_loop() is called; then thread exits + ACE_CHECK; + */ + //REACTOR CHANGE END + + //ACE_DEBUG((LM_DEBUG, "ORB thread: Shutdown\n")); + + if (inst->wait() == -1) //wait for ORB thread to terminate + { + ACE_ERROR((LM_ERROR, "ERROR: Thread_Manager wait failed: %s\n", + ACE_OS::strerror(errno))); + return 1; + } + + delete data; //don't need it anymore + data = 0; + //all Suppliers done, so stop EC and ORB + //Shutdown EC + //this->reset(); + + //ACE_DEBUG ((LM_DEBUG, "suppliers finished\n")); + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ECConfig"); + return 1; + } + ACE_ENDTRY; + + return 0; //successful run +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::initEC(ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_EC_Kokyu_Factory::init_svcs (); + + //ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Initializing event channel\n"))); + + // ORB initialization boiler plate... + int argc = 0; + char** argv = 0; + this->orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Resolving initial references\n"))); + + CORBA::Object_var object = + orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->poa = + PortableServer::POA::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->poa_manager = + poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + //TODO: do these need to remain in scope beyond this function? + + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Creating sched service\n"))); + + // Create a scheduling service + ACE_NEW (this->sched_impl,SCHED_STRAT); + + this->scheduler = sched_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Create an event channel implementation... + TAO_EC_Event_Channel_Attributes attributes (poa.in (), + poa.in ()); + attributes.scheduler = scheduler.in (); // no need to dup + + ACE_NEW (this->ec_impl,TAO_EC_Event_Channel (attributes)); + + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Created ec_impl\n"))); + + this->event_channel = + this->ec_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::make_federated (ACE_ENV_SINGLE_ARG_DECL) +{ + //TODO: IOR location is hardcoded. Obviously, this is BAD BAD BAD. + //TODO: This assumes make_federated() is only called by consumer!!! + + //get IOR of remote EC + ACE_CString remoteEC_ior("file://"); + ACE_CString remoteSched_ior("file://"); + //since we're hardcoding filenames anyway, this isn't much worse! + + remoteEC_ior += supplierEC_iorfile; + remoteSched_ior += supplierSched_iorfile; + + //ACE_DEBUG((LM_DEBUG,"Reading EC IOR: %s\n",remoteEC_ior.c_str())); + CORBA::Object_var ec_obj = + orb->string_to_object (remoteEC_ior.c_str() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::EventChannel_var remote_ec = + RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG((LM_DEBUG,"Reading Sched IOR: %s\n",remoteSched_ior.c_str())); + CORBA::Object_var sched_obj = orb->string_to_object(remoteSched_ior.c_str() ACE_ENV_ARG_PARAMETER); + RtecScheduler::Scheduler_var remote_sch = + RtecScheduler::Scheduler::_narrow (sched_obj.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //ACE_DEBUG((LM_DEBUG,"Creating gateway\n")); + //TAO_EC_Gateway_Sched *gateway = new TAO_EC_Gateway_Sched(); + ECConfig_Gateway *gateway = new ECConfig_Gateway(); + + //ACE_DEBUG((LM_DEBUG,"Gateway init\n")); + //for consumer, remote is supplier EC + gateway->init (remote_ec.in (), + this->event_channel.in (), + remote_sch.in (), + this->scheduler.in(), + supplierEC_iorfile, //use EC IOR files as names, since they should be unique + consumerEC_iorfile + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + //ACE_DEBUG((LM_DEBUG,"Gateway init returned; assigning\n")); + this->gateway_impl = gateway; + //ACE_DEBUG((LM_DEBUG,"Gateway init completed\n")); + + this->gateway_obs = this->gateway_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + //Might throw a CANT_APPEND_OBSERVER exception + //But I think we can ignore it if that happens + //ACE_DEBUG((LM_DEBUG,"Appending gateway observer\n")); + //append to consumer EC so that connecting consumers update the gateway! + RtecEventChannelAdmin::Observer_Handle h = + this->event_channel->append_observer (this->gateway_obs.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->gateway_impl->observer_handle (h); + + //ACE_DEBUG((LM_DEBUG,"Gateway observer appended\n")); + } + ACE_CATCH(RtecEventChannelAdmin::EventChannel::CANT_APPEND_OBSERVER,exc) + { + //ignore + //ACE_DEBUG((LM_DEBUG,"Caught CANT_APPEND_OBSERVER\n")); + } + ACE_ENDTRY; + + // ACE_DEBUG((LM_DEBUG,"Gateway created\n")); +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::connect_suppliers (ACE_ENV_SINGLE_ARG_DECL) +{ + RtecEventComm::EventSet event(1); + event.length(1); + + ACE_DEBUG((LM_DEBUG,"Suppliers to connect: %d\n",this->suppliers.size())); + //this->suppliers already has correct size + size_t supp_idx = 0; + for (size_t i=0; i<this->testcfgs.size(); ++i) + { + if (this->testcfgs[i]->comptype == SOURCE) + { + ACE_ASSERT(supp_idx < this->suppliers.size()); + ACE_NEW (this->suppliers[supp_idx], Supplier ()); + + event[0].header.type = ACE_ES_EVENT_UNDEFINED+this->testcfgs[i]->type; + event[0].header.source = supp_idx; //supplier_id + event[0].header.ttl = 1; + + std::ostringstream entry_prefix; + entry_prefix << "Supplier " << supp_idx; + + //ACE_DEBUG((LM_DEBUG,"Supplier.connect() for %s\n",entry_prefix.str().c_str())); + this->suppliers[supp_idx]->connect (&(this->ready), + this->test_done, + this->scheduler.in(), + entry_prefix.str().c_str(), + this->periods[i], //period + this->importances[i], //importance + this->crits[i], //criticality + supp_idx, //supplier_id + this->testcfgs[i]->num_entities, //to_send + event, //event set + this->event_channel.in() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ++supp_idx; //proceed to next supplier + } + } +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::connect_consumers (ACE_ENV_SINGLE_ARG_DECL) +{ + //ACE_DEBUG((LM_DEBUG,"Consumers to connect: %d\n",this->consumers.size())); + //this->consumers already has correct size + size_t cons_idx = 0; + for (size_t i=0; i<this->testcfgs.size(); ++i) + { + if (this->testcfgs[i]->comptype == SINK) + { + ACE_ASSERT(cons_idx < this->consumers.size()); + ACE_NEW (this->consumers[cons_idx], Consumer ()); + + std::ostringstream entry_prefix; + entry_prefix << "Consumer " << cons_idx; + + //ACE_DEBUG((LM_DEBUG,"Consumer.connect() for %s\n",entry_prefix.str().c_str())); + //don't set the RT_Info values + this->consumers[cons_idx]->connect (this->scheduler.in(), + entry_prefix.str().c_str(), + cons_idx, //consumer id + ACE_ES_EVENT_UNDEFINED+this->testcfgs[i]->type, //type + this->periods[i], + this->importances[i], + this->crits[i], + this->event_channel.in() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ++cons_idx; //proceed to next sink + } + } +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::disconnect_suppliers (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->configured) + { + for (size_t i = 0; i < this->suppliers.size(); ++i) + { + //ACE_DEBUG((LM_DEBUG,"Disconnecting supplier %d\n",i)); + this->suppliers[i]->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + delete this->suppliers[i]; + this->suppliers[i] = 0; + } + this->suppliers.size(0); + } +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::disconnect_consumers (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->configured) + { + for (size_t i = 0; i < this->consumers.size(); ++i) + { + this->consumers[i]->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + delete this->consumers[i]; + this->consumers[i] = 0; + } + this->consumers.size(0); + } +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::print_RT_Infos (ACE_Array<RtecScheduler::handle_t> cfg_set) +{ + char *rt_info_format = "{%20s, %10d, %10d, %10d, " + "%10d, %10d, " + "(RtecScheduler::Criticality_t) %d, " + "(RtecScheduler::Importance_t) %d, " + "%10d, %10d, %10d, %10d, %10d, " + "(RtecScheduler::Info_Type_t) %d }"; + ACE_TRY + { + for (size_t i=0; i<cfg_set.size(); ++i) { + RtecScheduler::handle_t hndl = cfg_set[i]; + RtecScheduler::RT_Info info = *(this->scheduler->get(hndl)); + ACE_TRY_CHECK; + + if (i!=0) + { + //finish previous line + //ACE_DEBUG ((LM_DEBUG, "\n")); + } +/* + ACE_DEBUG ((LM_DEBUG, rt_info_format, + (const char *) info.entry_point, + info.handle, + ACE_CU64_TO_CU32 (info.worst_case_execution_time), + ACE_CU64_TO_CU32 (info.typical_execution_time), + ACE_CU64_TO_CU32 (info.cached_execution_time), + info.period, + info.criticality, + info.importance, + ACE_CU64_TO_CU32 (info.quantum), + info.threads, + info.priority, + info.preemption_subpriority, + info.preemption_priority, + info.info_type)); +*/ + } + //finish last line + //ACE_DEBUG ((LM_DEBUG, "\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ECConfig"); + } + ACE_ENDTRY; + +} + +template <class SCHED_STRAT> void +ECConfig<SCHED_STRAT>::barrier(bool is_supplier) +{ + //if we are the server (we have suppliers), then we accept. + //if we are the client (we have consumers), then we connect. + + //first, create address + ACE_CString addr_str(remote_inet_addr); + char port_str[7]; + ACE_OS::sprintf(port_str,"%d",remote_inet_port); + port_str[6] = 0; + addr_str += ":"; + addr_str += port_str; + remote_inet_port++; //increment port for next barrier + + if (is_supplier) + { + //now we block on a socket connect until a consumer opens it + //this way, we don't start running until the consumer is ready + ACE_SOCK_Stream accstrm; + //ACE_DEBUG((LM_DEBUG,"Opening supplier socket %s\n",addr_str.c_str())); + ACE_INET_Addr addr(addr_str.c_str()); + ACE_SOCK_Acceptor acc(addr); + if (acc.accept(accstrm,&addr) != 0) //blocks until consumer opens + { + ACE_ERROR((LM_ERROR, + "Cannot accept socket: %s\n", + ACE_OS::strerror(errno))); + } + //ACE_DEBUG((LM_DEBUG,"Supplier: unblocked on socket\n")); + + //once opened, no need for socket any more + acc.close(); + accstrm.close(); + //ACE_DEBUG((LM_DEBUG, "Supplier: closed socket\n")); + } + else + { + //now we open a socket to start up the supplier + //ACE_DEBUG((LM_DEBUG,"Connecting consumer socket %s\n",addr_str.c_str())); + ACE_SOCK_Stream connstrm; + ACE_INET_Addr addr(addr_str.c_str()); + ACE_SOCK_Connector conn; + if (conn.connect(connstrm,addr) != 0) //blocks until supplier opens + { + ACE_ERROR((LM_ERROR, + "Consumer cannot connect socket: %s\n", + ACE_OS::strerror(errno))); + } + //ACE_DEBUG((LM_DEBUG,"Consumer: connected socket\n")); + + //once opened, no need for socket any more + connstrm.close(); + //ACE_DEBUG((LM_DEBUG, "Consumer: closed socket\n")); + } +} + +template <class SCHED_STRAT> ACE_THR_FUNC_RETURN +ECConfig<SCHED_STRAT>::run_orb(void *data) +{ + printf("data: %p\n",data); + spawn_data_t *data_ptr = ACE_reinterpret_cast(spawn_data_t*,data); + printf("data_ptr: %p\n",data_ptr); + printf("lock: %p\n",(void*)(data_ptr->lock)); + printf("orb: %p\n",(void*)(data_ptr->orb)); + //ACE_RW_Mutex *test_done = ACE_reinterpret_cast(ACE_RW_Mutex*,data); + //test_done->dump(); + //const ACE_rwlock_t& lock = test_done->lock(); + //printf("Number of: readers=%d\twriters=%d\n",lock.num_waiting_readers_,lock.num_waiting_writers_); + //printf("acquire_read(): %d\n",test_done->acquire_read()); + //printf("acquire_write(): %d\n",test_done->acquire_write()); + //std::exit(0); + + if (data_ptr->use_federated) + { + //assume if have no suppliers that we are client + ACE_DEBUG((LM_DEBUG,"Barrier to wait until both apps configured and orbs running\n")); + //not really sure orbs running, but certainly nothing else between the spawn and the run at this point! + ECConfig<SCHED_STRAT>::barrier(data_ptr->is_server); //wait until both apps are ready to run + *(data_ptr->ready) = 1; //checked by suppliers to start reacting to timeouts + } + else + { + //ACE_DEBUG((LM_DEBUG,"No barrier after configured and orb started because application is not federated\n")); + } + + // Block waiting for consumers to finish + //when can acquire write lock, all Suppliers are finished + int ret = data_ptr->lock->acquire_write(); + if (ret == -1) + { + //ACE_DEBUG((LM_DEBUG, "ERROR: could not acquire write lock for ECConfig: %s\n", + // ACE_OS::strerror(errno))); + return 0; + } + //release the lock, since it has served its purpose + data_ptr->lock->release(); + //@BT INSTRUMENT with event ID: EVENT_TEST_END Measure time when + //all events have been pushed. + + //REACTOR CHANGE + // Shutdown ORB + //TODO: Client stops immediately when it should wait for gateway to finish + if (data_ptr->is_server) + { + //HACK: client doesn't shutdown! + //ACE_DEBUG((LM_DEBUG,"Supplier shutting down ORB\n")); + (*(data_ptr->orb))->shutdown(1); //argument is TRUE so orb waits until work + //done before shutting down + } + /* + //orb->orb_core()->reactor()->end_reactor_event_loop(); + //ACE_DEBUG((LM_DEBUG,"DONE; stopping reactor event loop\n")); + ACE_Reactor::instance()->end_reactor_event_loop(); + */ + //ACE_DEBUG((LM_DEBUG,"ORB Thread exiting\n")); + return 0; +} + +} /* namespace TestConfig */ + +#endif /* ECCONFIG_C */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.h b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.h new file mode 100644 index 00000000000..2a322b81448 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig.h @@ -0,0 +1,152 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = FILENAME +// ECConfig +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef ECCONFIG_H +#define ECCONFIG_H + +#include "ace/Array.h" +#include "ace/RW_Mutex.h" +#include "orbsvcs/RtecSchedulerS.h" //for POA_RtecScheduler +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/RtecEventChannelAdminC.h" +#include "orbsvcs/Event/EC_Event_Channel.h" +#include "orbsvcs/Event/EC_Gateway.h" + +//#include "AddrServer.h" +#include "TestConfig.h" +#include "Consumer.h" +#include "Supplier.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace TestConfig { + +typedef ACE_Array<RtecEventChannelAdmin::ProxyPushConsumer_var> ProxyList; +typedef ACE_Array<RtecScheduler::handle_t> ConfigList; +typedef ACE_Array<RtecEventComm::EventSourceID> SupplierIDList; +typedef ACE_Array<TimeBase::TimeT> PeriodList; +typedef ACE_Array<RtecScheduler::Importance_t> ImportanceList; +typedef ACE_Array<RtecScheduler::Criticality_t> CritList; + +typedef ACE_Array<Consumer*> ConsumerList; +typedef ACE_Array<Supplier*> SupplierList; + +template <class SCHED_STRAT> +class ECConfig : public Test_Config { +public: + ECConfig (void); + + virtual ~ECConfig (void); + + virtual int configure (TCFG_SET_WPTR configs); + //does not take ownership of the Test_Config_Set but + //needs to use the test_config_t in that set until + //the ECConfig goes out of scope + + virtual int run (void); + //If we try to distinguish between final-push and final-receipt, + //that might be tracked in the Consumer (which would be easy as long + //as filtering and correlation isn't used -- in that case, there + //might be more than one receiver of an event, so you might get + //multiple receipt-notices). There could also be a race-condition + //problem between the various threads when reporting the receipt of + //events. + +protected: + // TODO USE DEFAULTS FOR ANY OF THESE? + + virtual void initEC (ACE_ENV_SINGLE_ARG_DECL); + + void make_federated (ACE_ENV_SINGLE_ARG_DECL); + + void connect_suppliers (ACE_ENV_SINGLE_ARG_DECL); + + void disconnect_suppliers (ACE_ENV_SINGLE_ARG_DECL); + + void connect_consumers (ACE_ENV_SINGLE_ARG_DECL); + + void disconnect_consumers (ACE_ENV_SINGLE_ARG_DECL); + + virtual void reset (ACE_ENV_SINGLE_ARG_DECL); + +private: + + void print_RT_Infos (ACE_Array<RtecScheduler::handle_t> cfg_set); + + static ACE_THR_FUNC_RETURN run_orb(void *data); //thread fcn for running ORB + + Test_Config_Set testcfgs; + //copy of the currently configured Test_Config_Set + //using the same test_config_t objects + + CORBA::ORB_var orb; + + PortableServer::POA_var poa; + + PortableServer::POAManager_var poa_manager; + + RtecEventChannelAdmin::EventChannel_var event_channel; + + RtecScheduler::Scheduler_var scheduler; + + TAO_EC_Event_Channel *ec_impl; + + SCHED_STRAT *sched_impl; + + ConsumerList consumers; + + SupplierList suppliers; + + PeriodList periods; + + ImportanceList importances; + + CritList crits; + + ACE_RW_Mutex* test_done; + //TimeoutConsumers acquire read locks; when the ECConfig can acquire + //a write lock, all TimeoutConsumers must've finished, so the test + //is finished. + + //Flag indicates whether or not the back-end has been configured + int configured; //boolean + + //These members are for Federated EC support + int use_federated; //boolean + + TAO_EC_Gateway *gateway_impl; + + RtecEventChannelAdmin::Observer_var gateway_obs; + + //Becomes true when client signals (through barrier) that it is ready to run + int ready; //boolean + + ///Blocks the application using ACE_SOCK_Connector or + ///ACE_SOCK_Acceptor. Used for barrier synchronization between the + ///application and others in the system. + static void barrier(bool is_supplier); +}; + +} /* namespace TestConfig */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ECConfig.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ECConfig.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ECCONFIG_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.cpp new file mode 100644 index 00000000000..b043a48cffa --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.cpp @@ -0,0 +1,123 @@ +/** + * @author Stephen Torri + * $Id$ + */ +#include "ECConfig_Gateway.h" +#include "ace/OS_NS_stdio.h" +#include "orbsvcs/Event_Utilities.h" + +ECConfig_Gateway::ECConfig_Gateway (void) + : TAO_EC_Gateway_Sched() +{ +} + +ECConfig_Gateway::~ECConfig_Gateway (void) +{ +} + +void ECConfig_Gateway::push (const RtecEventComm::EventSet &events ACE_ENV_ARG_DECL_WITH_DEFAULTS) +{ + ACE_OS::printf ("ECConfig_Gateway::push - %p\n", &events); + + //call super function + TAO_EC_Gateway_Sched::push(events); +} + +void ECConfig_Gateway::update_consumer (const RtecEventChannelAdmin::ConsumerQOS& sub + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + /* + ACE_OS::printf ("ECConfig_Gateway::update_consumer - %p\n", &sub); + ACE_OS::printf (" Dependencies:\n"); + for (unsigned int i = 0; i < sub.dependencies.length(); ++i) { + ACE_OS::printf(" Dep #%d\n",i); + // RtecEventComm::Event event + ACE_OS::printf(" - Event:\n"); + // RtecEventComm::EventHeader header + // RtecEventComm::EventType type; (Ulong) + // RtecEventComm::EventSourceID source; (Long) + // CORBA::Long ttl; + ACE_OS::printf(" type=%d source_id=%d ttl=%d\n", + sub.dependencies[i].event.header.type, + sub.dependencies[i].event.header.source, + sub.dependencies[i].event.header.ttl); + // RtecEventComm::Time creation_time;(Ulong) + // RtecEventComm::Time ec_recv_time; (Ulong) + // RtecEventComm::Time ec_send_time; (Ulong) + ACE_OS::printf(" creation_time=%llu\n ec_recv_time=%llu\n ec_send_time=%llu\n", + sub.dependencies[i].event.header.creation_time, + sub.dependencies[i].event.header.ec_recv_time, + sub.dependencies[i].event.header.ec_send_time); + // //RtecEventComm::EventData data + // RtecBase::handle_t rt_info + ACE_OS::printf(" - RT_Info: %d\n", sub.dependencies[i].rt_info); + } + ACE_OS::printf (" Is this a gateway:"); + if (sub.is_gateway) { + ACE_OS::printf (" true"); + } + else { + ACE_OS::printf (" false"); + } + ACE_OS::printf("\n"); + */ + + ACE_DEBUG ((LM_DEBUG, "ECConfig (%t) Gateway/Consumer ")); + ACE_ConsumerQOS_Factory::debug(sub); + + //call super function + TAO_EC_Gateway_Sched::update_consumer(sub); +} + +void ECConfig_Gateway::update_supplier (const RtecEventChannelAdmin::SupplierQOS& pub + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + /* + ACE_OS::printf ("ECConfig_Gateway::update_supplier - %p\n", &pub); + // SupplierQOS + // RtecEventChannelAdmin::PublicationSet publications; + ACE_OS::printf (" Publications:\n"); + for (unsigned int i = 0; i < pub.publications.length(); ++i) { + ACE_OS::printf(" Pub #%d\n",i); + // Publication + // RtecEventComm::Event event; + ACE_OS::printf(" - Event:\n"); + // RtecEventComm::EventHeader header + // RtecEventComm::EventType type; (Ulong) + // RtecEventComm::EventSourceID source; (Long) + // CORBA::Long ttl; + ACE_OS::printf(" type=%d source_id=%d ttl=%d\n", + pub.publications[i].event.header.type, + pub.publications[i].event.header.source, + pub.publications[i].event.header.ttl); + // RtecEventComm::Time creation_time;(Ulong) + // RtecEventComm::Time ec_recv_time; (Ulong) + // RtecEventComm::Time ec_send_time; (Ulong) + ACE_OS::printf(" creation_time=%llu\n ec_recv_time=%llu\n ec_send_time=%llu\n", + pub.publications[i].event.header.creation_time, + pub.publications[i].event.header.ec_recv_time, + pub.publications[i].event.header.ec_send_time); + + // RtecBase::Dependency_Info dependency_info; + ACE_OS::printf(" - Dependency_Info\n"); + // RtecBase::Dependency_Type_t dependency_type; + ACE_OS::printf(" type: %d\n", pub.publications[i].dependency_info.dependency_type); + // CORBA::Long number_of_calls; + ACE_OS::printf(" number of calls: %d\n", pub.publications[i].dependency_info.number_of_calls); + // RtecBase::handle_t rt_info; + ACE_OS::printf(" rt_info: %d\n", pub.publications[i].dependency_info.rt_info); + // RtecBase::handle_t rt_info_depended_on; + ACE_OS::printf(" rt_info dependend on: %d\n", pub.publications[i].dependency_info.rt_info_depended_on); + // RtecBase::Dependency_Enabled_Type_t enabled; + ACE_OS::printf(" dependency enabled type: %d\n", pub.publications[i].dependency_info.enabled); + } + */ + + ACE_DEBUG ((LM_DEBUG, "ECConfig (%t) Gateway/Supplier ")); + ACE_SupplierQOS_Factory::debug(pub); + + //call super function + TAO_EC_Gateway_Sched::update_supplier(pub); +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.h b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.h new file mode 100644 index 00000000000..560503bfa41 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ECConfig_Gateway.h @@ -0,0 +1,34 @@ +/** + * @author Stephen Torri + * $Id$ + */ +#ifndef ECCONFIG_GATEWAY_H_ +#define ECCONFIG_GATEWAY_H + +#include <orbsvcs/Event/EC_Gateway_Sched.h> +#include <orbsvcs/RtecEventChannelAdminS.h> +#include <orbsvcs/RtecEventCommS.h> + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class ECConfig_Gateway : public TAO_EC_Gateway_Sched { + public: + ECConfig_Gateway (void); + ~ECConfig_Gateway (void); + + void push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + virtual void update_consumer (const RtecEventChannelAdmin::ConsumerQOS& sub + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void update_supplier (const RtecEventChannelAdmin::SupplierQOS& pub + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +}; + +#endif // ECCONFIG_GATEWAY_H_ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Makefile b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile new file mode 100644 index 00000000000..9dcc19adbe5 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile @@ -0,0 +1,60 @@ +#---------------------------------------------------------------------------- +# GNU ACE Workspace +# +# @file Makefile +# +# $Id$ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- + + +MAKE_OPTIONS=$(shell echo $(MAKEFLAGS) | sed 's/--unix *//; s/ .*//') +ifeq ($(findstring k,$(MAKE_OPTIONS)),k) + KEEP_GOING = 1 +else + KEEP_GOING = 0 +endif + +%.tgt0: +ifeq ($(KEEP_GOING),1) + -@$(MAKE) -f Makefile.test_driver_lib -C . $(*); +else + @$(MAKE) -f Makefile.test_driver_lib -C . $(*); +endif +%.tgt1: %.tgt0 +ifeq ($(KEEP_GOING),1) + -@$(MAKE) -f Makefile.test_driver_app -C . $(*); +else + @$(MAKE) -f Makefile.test_driver_app -C . $(*); +endif + + +all: all.tgt0 all.tgt1 + +debug: debug.tgt0 debug.tgt1 + +profile: profile.tgt0 profile.tgt1 + +optimize: optimize.tgt0 optimize.tgt1 + +install: install.tgt0 install.tgt1 + +deinstall: deinstall.tgt0 deinstall.tgt1 + +clean: clean.tgt0 clean.tgt1 + +realclean: realclean.tgt0 realclean.tgt1 + +clobber: clobber.tgt0 clobber.tgt1 + +depend: depend.tgt0 depend.tgt1 + +rcs_info: rcs_info.tgt0 rcs_info.tgt1 + +idl_stubs: idl_stubs.tgt0 idl_stubs.tgt1 + +reverseclean: realclean.tgt1 realclean.tgt0 + diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_app b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_app new file mode 100644 index 00000000000..99387d4c505 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_app @@ -0,0 +1,117 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.test_driver_app +# +# $Id$ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.test_driver_app +DEPENDENCY_FILE = .depend.Makefile.test_driver_app +BIN_UNCHECKED = Test + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +FILES = \ + Test + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +LDLIBS = -lwrappers -lTest_Driver -lACEXML_Parser -lACEXML -lKokyu -ldsui -lTAO_RTSchedEvent -lTAO_RTSched -lTAO_CosNaming -lTAO_IORTable -lTAO_RTEvent -lTAO_Svc_Utils -lTAO_Messaging -lTAO_PortableServer -lTAO_IORInterceptor -lTAO_ObjRefTemplate -lTAO_Valuetype -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/test_driver_app + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif +OUTPUT_DIRECTORY = . +all: $(OUTPUT_DIRECTORY) + +$(OUTPUT_DIRECTORY): + -@mkdir -p "$(OUTPUT_DIRECTORY)" + + +CURRENT_COMPONENTS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) +ifeq (RTSchedEvent, $(findstring RTSchedEvent, $(CURRENT_COMPONENTS))) +ifeq (Sched, $(findstring Sched, $(CURRENT_COMPONENTS))) +ifeq (Naming, $(findstring Naming, $(CURRENT_COMPONENTS))) +ifeq (RTEvent, $(findstring RTEvent, $(CURRENT_COMPONENTS))) +BIN = $(BIN_UNCHECKED) +else + all: comp_warning +endif +else + all: comp_warning +endif +else + all: comp_warning +endif +else + all: comp_warning +endif + +OBJS = $(addsuffix .o, $(notdir $(FILES))) +SRC = $(addsuffix .cpp, $(FILES)) +ifneq (,$(RC)) + FILES += $(RESOURCES) +endif + + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../../../ACEXML/common -I../../../../../Kokyu -I$(DATASTREAM_ROOT)/include -I../../../../orbsvcs -I../../../.. -I../../../../tao -I../../../../.. +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + + +LDFLAGS += -L. -L$(DATASTREAM_ROOT)/lib -L../../../../../lib + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +comp_warning: + @echo This project will not be built due to one of the following missing components: + @echo RTSchedEvent Sched Naming RTEvent + + +ifndef kylix +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK) +else +$(BIN): $(addprefix $(VDIR), $(OBJS)) + $(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $(VLDLIBS) $(BORINITEXEOBJ) $(POSTLINK) $^, $@,, +endif + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_lib b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_lib new file mode 100644 index 00000000000..b101ef577b6 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Makefile.test_driver_lib @@ -0,0 +1,144 @@ +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file Makefile.test_driver_lib +# +# $Id$ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = Makefile.test_driver_lib +DEPENDENCY_FILE = .depend.Makefile.test_driver_lib +LIB = libTest_Driver.a +SHLIB = libTest_Driver.$(SOEXT) + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif +ifndef CIAO_ROOT + CIAO_ROOT = $(TAO_ROOT)/CIAO +endif + +FILES = \ + Consumer \ + Supplier \ + TimeoutConsumer \ + TestConfig \ + Test_Handler \ + Config_Factory \ + Timer_Event_Handler \ + cpuload \ + ECConfig_Gateway + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = -lACEXML_Parser -lACEXML -lTAO_RTKokyuEvent -lKokyu -ldsui -lTAO_RTSched -lTAO_CosNaming -lTAO_IORTable -lTAO_RTEvent -lTAO_Svc_Utils -lTAO_Messaging -lTAO_PortableServer -lTAO_IORInterceptor -lTAO_ObjRefTemplate -lTAO_Valuetype -lTAO -lACE +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +## We don't need the ACELIB setting from wrapper_macros.GNU +ACELIB = +include $(TAO_ROOT)/rules.tao.GNU + +# To build multiple executables in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/test_driver_lib + +all: $(TEMPINCDIR) + +$(TEMPINCDIR): + @-test -d $(TEMPINCDIR) || mkdir -p $(TEMPINCDIR) $(ACE_NUL_STDERR) + +endif +OUTPUT_DIRECTORY = ../../../../../lib +all: $(OUTPUT_DIRECTORY) + +$(OUTPUT_DIRECTORY): + -@mkdir -p "$(OUTPUT_DIRECTORY)" + +CURRENT_COMPONENTS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) +ifeq (Sched, $(findstring Sched, $(CURRENT_COMPONENTS))) +ifeq (Naming, $(findstring Naming, $(CURRENT_COMPONENTS))) +ifeq (RTEvent, $(findstring RTEvent, $(CURRENT_COMPONENTS))) +else + LIB = + SHLIB = + all: comp_warning +endif +else + LIB = + SHLIB = + all: comp_warning +endif +else + LIB = + SHLIB = + all: comp_warning +endif + +ifeq (,$(TAO_ORBSVCS)) +else + ifeq (Sched, $(findstring Sched, $(TAO_ORBSVCS))) + ifeq (Naming, $(findstring Naming, $(TAO_ORBSVCS))) + ifeq (RTEvent, $(findstring RTEvent, $(TAO_ORBSVCS))) + else + LIB = + SHLIB = + endif + else + LIB = + SHLIB = + endif + else + LIB = + SHLIB = + endif +endif + +ifneq (,$(RC)) + FILES += $(RESOURCES) +endif + +LSRC = $(addsuffix .cpp, $(FILES)) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU + +INSTALL_CHECK = ../../../../../lib +ifeq ($(INSTALL_CHECK),.) + INSLIB = $(PWD) +else + INSLIB = $(INSTALL_CHECK) +endif + +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +CPPFLAGS += -I../../../../../ACEXML/common -I../../../../../Kokyu -I$(DATASTREAM_ROOT)/include -I../../../../orbsvcs -I../../../.. -I../../../../tao -I../../../../.. +ifeq ($(static_libs),1) + ifneq ($(LIB),) + CPPFLAGS += -DTAO_AS_STATIC_LIBS -DTAO_AS_STATIC_LIBS -DACE_AS_STATIC_LIBS + endif +endif + + +LDFLAGS += -L$(DATASTREAM_ROOT)/lib -L../../../../../lib + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +comp_warning: + @echo This project will not be built due to one of the following missing components: + @echo Sched Naming RTEvent + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Schedule.h b/TAO/orbsvcs/examples/RtEC/test_driver/Schedule.h new file mode 100644 index 00000000000..0d9eb4d3804 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Schedule.h @@ -0,0 +1,42 @@ +// $Id$ + +// This file was automatically generated by the Scheduler_Factory. +// Before editing the file please consider generating it again. + +#include "orbsvcs/Scheduler_Factory.h" + + +// There were no scheduling anomalies. + + +static ACE_Scheduler_Factory::POD_RT_Info infos[] = { +{"Dispatching_Task-250000.us", 1, 0, 0, 0, 250000, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 1, 58, 4, 1, (RtecScheduler::Info_Type_t) 0 }, +{"Dispatching_Task-500000.us", 2, 0, 0, 0, 500000, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 1, 58, 5, 1, (RtecScheduler::Info_Type_t) 0 }, +{"Dispatching_Task-1000000.us", 3, 0, 0, 0, 1000000, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 1, 58, 6, 1, (RtecScheduler::Info_Type_t) 0 }, +{"Dispatching_Task-2000000.us", 4, 0, 0, 0, 2000000, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 1, 58, 7, 1, (RtecScheduler::Info_Type_t) 0 }, +{"Dispatching_Task-10000000.us", 5, 0, 0, 0, 10000000, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 1, 58, 8, 1, (RtecScheduler::Info_Type_t) 0 }, +{ "consumer_event_1", 6, 20000, 20000, 20000, 0, (RtecScheduler::Criticality_t) 4, (RtecScheduler::Importance_t) 0, 20000, 0, 59, 0, 0, (RtecScheduler::Info_Type_t) 0 }, +{ "consumer_event_2", 7, 10000, 10000, 10000, 0, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 10000, 0, 58, 1, 1, (RtecScheduler::Info_Type_t) 0 }, +{"(consumer_event_1#rep||consumer_event_2#rep)", 8, 0, 0, 0, 0, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 0, 58, 3, 1, (RtecScheduler::Info_Type_t) 2 }, +{"consumer_event_1#rep", 9, 0, 0, 0, 0, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 0, 58, 0, 1, (RtecScheduler::Info_Type_t) 0 }, +{"consumer_event_2#rep", 10, 0, 0, 0, 0, (RtecScheduler::Criticality_t) 0, (RtecScheduler::Importance_t) 0, 0, 0, 58, 2, 1, (RtecScheduler::Info_Type_t) 0 }, +{ "supplier_event_1", 11, 0, 0, 0, 100000, (RtecScheduler::Criticality_t) 4, (RtecScheduler::Importance_t) 0, 0, 1, 59, 1, 0, (RtecScheduler::Info_Type_t) 0 }, +{ "supplier_event_2", 12, 0, 0, 0, 200000, (RtecScheduler::Criticality_t) 4, (RtecScheduler::Importance_t) 0, 0, 1, 59, 2, 0, (RtecScheduler::Info_Type_t) 0 } +}; + +static int infos_size = sizeof(infos)/sizeof(infos[0]); + + +static ACE_Scheduler_Factory::POD_Config_Info configs[] = { + { 0, 59, (RtecScheduler::Dispatching_Type_t) 2 }, + { 1, 58, (RtecScheduler::Dispatching_Type_t) 2 } +}; + +static int configs_size = sizeof(configs)/sizeof(configs[0]); + + +// This sets up Scheduler_Factory to use the runtime version. +int scheduler_factory_setup = + ACE_Scheduler_Factory::use_runtime (configs_size, configs, infos_size, infos); + +// EOF diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.cpp new file mode 100644 index 00000000000..86489e2cd01 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.cpp @@ -0,0 +1,218 @@ +// $Id$ + +#include "Supplier.h" +#include "orbsvcs/Event_Utilities.h" //for ACE_Supplier/ConsumerQOS_Factory +#include "orbsvcs/Event_Service_Constants.h" + +ACE_RCSID(EC_Examples, Supplier, "$Id$") + +Supplier::Supplier (void) + : timeoutconsumer(this) + , _supplier(this) + , _ready (0) +{ +} + +Supplier::~Supplier() +{ +} + +void +Supplier::update(ACE_ENV_SINGLE_ARG_DECL) +{ + /* + ACE_DEBUG((LM_DEBUG,"Supplier %d (%P|%t) received update\n",this->_supplier_id)); + */ + + //only react to update if ready=1 + if (*this->_ready == 1 && this->_num_sent < this->_to_send) + { + //@BT INSTRUMENT with event ID: EVENT_PUSH Measure time + //when event is pushed by client. + + //send this->_events + this->_consumer_proxy->push(this->_events ACE_ENV_ARG_PARAMETER); + + ++this->_num_sent; + /* + ACE_DEBUG((LM_DEBUG,"Sent events; %d sent\t%d total\n",this->_num_sent,this->_to_send)); + */ + if (this->_num_sent >= this->_to_send) + { + //just finished; only want to do this once! + /* + ACE_DEBUG((LM_DEBUG,"RELEASE read lock from Supplier %d\n", + this->_supplier_id)); + */ + this->_done->release(); + this->_hold_mtx = 0; + } + } + else + { + //do nothing + } +} + +void +Supplier::connect (int *ready, + ACE_RW_Mutex* done, + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventComm::EventSourceID supplier_id, + size_t to_send, + const RtecEventComm::EventSet& events, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->_ready = ready; + this->_supplier_id = supplier_id; + this->_to_send = to_send; + this->_num_sent = 0; + this->_hold_mtx = 0; + this->_done = done; + if (this->_done!= 0 && this->_num_sent<this->_to_send) + { + int ret = done->acquire_read(); + if (ret == -1) + { + ACE_DEBUG((LM_DEBUG,"ERROR: Could not acquire read lock for Supplier: %s\n", + ACE_OS::strerror(errno))); + } else + { + ACE_DEBUG((LM_DEBUG,"ACQUIRED read lock for Supplier %d\n",this->_supplier_id)); + this->_hold_mtx = 1; + } + } else + { + ACE_DEBUG((LM_DEBUG,"Already done; did not grab read lock for Supplier %d\n",this->_supplier_id)); + } + + this->_events.length(events.length()); + for (size_t i=0; i<events.length(); ++i) + { + this->_events[i] = events[i]; //copy event to local set + this->_events[i].header.source = this->_supplier_id; //make sure event source is this + } + + //create supplier RT_Info + std::ostringstream supp_entry_pt; + supp_entry_pt << entry_prefix << " Supplier " << this->_supplier_id; //unique RT_Info entry point + /* + ACE_DEBUG((LM_DEBUG,"Creating %s\n",supp_entry_pt.str().c_str())); + ACE_DEBUG((LM_DEBUG,"\timportance: %d\tcriticality: %d\n",importance,criticality)); + */ + RtecScheduler::handle_t rt_info = scheduler->create (supp_entry_pt.str().c_str() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + ACE_Time_Value tv (0,0); + TimeBase::TimeT tmp; + ORBSVCS_Time::Time_Value_to_TimeT (tmp, tv); + scheduler->set (rt_info, + criticality, + tmp,tmp,tmp, + period, + importance, + tmp, + 0, + RtecScheduler::OPERATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Register as supplier of events + ACE_DEBUG((LM_DEBUG,"Supplier %d inserting %d events into SupplierQOS_Factory\n",this->_supplier_id,events.length())); + ACE_SupplierQOS_Factory supplierQOS; + for (size_t i=0; i<events.length(); ++i) + { + //insert type for each event + supplierQOS.insert (this->_supplier_id, + events[i].header.type, + rt_info, + 1); + } + + RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = + ec->for_suppliers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy = + supplier_admin->obtain_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventComm::PushSupplier_var supplierv = + this->_supplier._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy->connect_push_supplier (supplierv.in (), + supplierQOS.get_SupplierQOS () + ACE_ENV_ARG_PARAMETER); + ACE_DEBUG((LM_DEBUG, "Supplier (%t) ")); + printf("object pointer (%p) ---> push_consumer (%p)\n", + this, + this->_consumer_proxy.in()); + + ACE_CHECK; + + /* + ACE_DEBUG((LM_DEBUG,"Supplier %d connected\n",this->_supplier_id)); + for (size_t i=0; i<events.length(); ++i) + { + ACE_DEBUG((LM_DEBUG,"\tEvent Type: %d\n",events[i].header.type)); + } + */ + //connect TimeoutConsumer for timeouts. + this->timeoutconsumer.connect(scheduler,supp_entry_pt.str().c_str(),period, + importance,criticality,ec ACE_ENV_ARG_PARAMETER); + + //REACTOR CHANGE + /* + //Add Scheduler dependency between TimeoutConsumer and Supplier + scheduler->add_dependency (this->timeoutconsumer.get_RT_Info(), + rt_info, + 1, + RtecBase::TWO_WAY_CALL + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + */ + //REACTOR CHANGE END +} + +void +Supplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + if (! CORBA::is_nil (this->_consumer_proxy.in ())) + { + this->_consumer_proxy->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_consumer_proxy = + RtecEventChannelAdmin::ProxyPushConsumer::_nil (); + + // Deactivate the servant + PortableServer::POA_var poa = + this->_supplier._default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (&this->_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + this->timeoutconsumer.disconnect(ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +Supplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.h b/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.h new file mode 100644 index 00000000000..0c5887c3931 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Supplier.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// Supplier +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef SUPPLIER_H +#define SUPPLIER_H + +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Channel_Clients_T.h" +#include "ace/RW_Mutex.h" +#include "TimeoutConsumer.h" +#include <sstream> //for ostringstream + + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Supplier : Timeout_Observer +{ + // = TITLE + // Simple supplier object which responds to timeout events. + // + // = DESCRIPTION + // This class is an event supplier which responds to EC timeouts. + // For each timeout event it is notified of (via a TimeoutConsumer object), + // it pushes a specified EventSet into the EC. + // + // There are several ways to connect and disconnect this class, + // and it is up to the driver program to use the right one. + // +public: + Supplier (void); + // Default Constructor. + + virtual ~Supplier (void); + + virtual void update(ACE_ENV_SINGLE_ARG_DECL); + + void connect (int *ready, //variable to check for readiness + ACE_RW_Mutex* done, + RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventComm::EventSourceID supplier_id, + size_t to_send, + const RtecEventComm::EventSet& events, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the supplier to the EC. + + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + // Disconnect from the EC. + + // = The RtecEventComm::PushSupplier methods + + virtual void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +private: + size_t _to_send; //number of times to push on timeout + size_t _num_sent; //number of pushes so far + int _hold_mtx; //1 when hold _done mutex; 0 else + ACE_RW_Mutex* _done; //release read lock when _num_sent >= _to_send + + TimeoutConsumer timeoutconsumer; + + RtecEventComm::EventSourceID _supplier_id; + // We generate an id based on the name.... + + RtecEventChannelAdmin::ProxyPushConsumer_var _consumer_proxy; + // We talk to the EC (as a supplier) using this proxy. + + ACE_PushSupplier_Adapter<Supplier> _supplier; + // We connect to the EC as a supplier so we can push events + // every time we receive a timeout event. + + RtecEventComm::EventSet _events; + // set of events to push when a timeout event is received. + + int *_ready; //do not respond to timeouts until this variable = 1 + +}; + +#endif /* SUPPLIER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Test.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Test.cpp new file mode 100644 index 00000000000..ca561c3c32f --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Test.cpp @@ -0,0 +1,140 @@ +// $Id$ + +#include <dsui_types.h> +#include "ace/Array.h" +#include "ace/Bound_Ptr.h" +#include "ace/Synch.h" +#include "ace/Get_Opt.h" +#include "ace/String_Base.h" +#include "ACEXML/parser/parser/Parser.h" +#include "ACEXML/common/InputSource.h" +#include "ACEXML/common/FileCharStream.h" +#include "ACEXML/common/DefaultHandler.h" +#include "orbsvcs/Event/EC_Gateway_IIOP_Factory.h" + +#include "ECConfig.h" +#include "Config_Factory.h" +#include "Test_Handler.h" + +using namespace TestConfig; + +struct Arguments +{ + ACE_CString filename_; +}; + +int parse_args (int argc, char *argv[],Arguments &args); + +int +main (int argc, char *argv[]) +{ + TAO_EC_Kokyu_Factory::init_svcs(); + TAO_EC_Gateway_IIOP_Factory::init_svcs(); + ConfigFactory::Default_Config_Factory::init_svcs(); + + int retval = 0; + ds_control ctrl ("Test start","Test.dsui"); + + ACEXML_TRY_NEW_ENV + { + ACEXML_Parser parser; + Arguments args; + args.filename_.set(ACE_TEXT("test.xml")); + + // parse args for config filename + if (parse_args(argc,argv,args) == -1) + { + return 1; + } + + ACEXML_FileCharStream *fcs = new ACEXML_FileCharStream(); + if ((retval = fcs->open(args.filename_.c_str())) != 0) { + //ACE_DEBUG ((LM_DEBUG, "Could not open file %s\n",args.filename_.c_str())); + return retval; + } + + ACEXML_InputSource is (fcs); //takes responsibility of fcs + + Test_Handler handler (args.filename_.c_str()); + ACEXML_DefaultHandler dflt; + + parser.setContentHandler (&handler); + parser.setDTDHandler (&dflt); + parser.setErrorHandler (&handler); + parser.setEntityResolver (&dflt); + + parser.parse(&is); + ACEXML_TRY_CHECK; + + if ((retval = fcs->close()) != 0) { + //ACE_DEBUG ((LM_DEBUG, "Could not close file %s\n",args.filename_.c_str())); + return retval; + } + + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished parsing\n"))); + + // configure according to parsed XML + ConfigFactory::Default_Config_Factory fact; + fact.init(argc,argv); + + Test_Config *backend = fact.create_testconfig(); + if (0 == backend) { + ACE_DEBUG((LM_DEBUG, "Error: could not create back end!\n")); + return 1; + } + + // PROBLEM: occasional segfault on run and configure + TCFG_SET_WPTR cfg_ptr(handler.get_configs()); + + int retval = 0; + if ((retval = backend->configure(cfg_ptr)) != 0) { + ACE_DEBUG((LM_DEBUG, "Error configuring back end! (%d)\n",retval)); + return retval; + } + + if ((retval = backend->run()) != 0) { + ACE_DEBUG((LM_DEBUG, "Error running back end! (%d)\n",retval)); + return retval; + } + + fact.destroy_testconfig(backend); + fact.fini(); + + } + ACEXML_CATCH (ACEXML_SAXException, ex) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred: %s. Exiting...\n"), + ex.message())); + return 1; + } + ACEXML_ENDTRY; + + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Finished successfully\n"))); + + return retval; +} + +int parse_args (int argc, char *argv[], Arguments &args) +{ + ACE_Get_Opt get_opts (argc, argv, "f:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + args.filename_.set(get_opts.opt_arg()); + //ACE_DEBUG((LM_DEBUG,ACE_TEXT("Filename argument: %s\n"),args.filename_.c_str())); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-f <filename>] " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.cpp new file mode 100644 index 00000000000..37be921b867 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.cpp @@ -0,0 +1,11 @@ +// $Id$ + +#include /**/ "TestConfig.h" + +namespace TestConfig { + +Test_Config::~Test_Config (void) +{ +} + +} /* namespace TestConfig */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.h b/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.h new file mode 100644 index 00000000000..e54baeb699f --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/TestConfig.h @@ -0,0 +1,134 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = FILENAME +// TestConfig +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef TESTCONFIG_H +#define TESTCONFIG_H + +#include "ace/Array.h" +#include "ace/Bound_Ptr.h" +#include "ace/Synch.h" //for ACE_Null_Mutex + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace TestConfig { + +struct test_config_t; +typedef ACE_Array<test_config_t*> Test_Config_Set; +typedef ACE_Strong_Bound_Ptr<Test_Config_Set,ACE_Null_Mutex> TCFG_SET_SPTR; +typedef ACE_Weak_Bound_Ptr<Test_Config_Set,ACE_Null_Mutex> TCFG_SET_WPTR; + +// Entity_Type_t is used to distinguish different types of entities +// (such as Event Channel events and Distributable Threads). Not exactly +// an enumeration of those types, but it should take on reasonably +// distinct values for each. +typedef unsigned long Entity_Type_t; + +typedef long Period_t; //in milliseconds + +enum Criticality_t { +// Defines the criticality of the entity. + VERY_LOW_CRITICALITY, + LOW_CRITICALITY, + MEDIUM_CRITICALITY, + HIGH_CRITICALITY, + VERY_HIGH_CRITICALITY +}; + +enum Importance_t { +// Defines the importance of the entity, +// which can be used as a "tie-breaker" when +// other scheduling parameters are equal. + VERY_LOW_IMPORTANCE, + LOW_IMPORTANCE, + MEDIUM_IMPORTANCE, + HIGH_IMPORTANCE, + VERY_HIGH_IMPORTANCE +}; + +enum Component_Type_t { +// Defines the type of component the test_config_t represents + SOURCE, //component produces entities. + SINK, //component consumes entities. + SOURCESINK //component produces and consumes entities. NOT SUPPORTED +}; + +struct test_config_t +// = TITLE +// Test configuration information for the back-end. +// +// = DESCRIPTION +// The QoS and number of tasks for each +// test "entity" described by the following +// information. +{ + Component_Type_t comptype; + + // The entity type should uniquely identify the + // set of entities configured by this struct. + Entity_Type_t type; + + // This expresses the rate at which entities are + // pushed. + Period_t period; + + // Entity Criticality (user assigned significance). + Criticality_t criticality; + + // Entity importance, used to "break ties". + Importance_t importance; + + // Number of entities to push through the back-end. This is + // effectively a termination condition for the test, since it will + // terminate once all num_entities entities have been pushed for + // each test_config_t used to configure the back-end. + long num_entities; +}; + +class Test_Config { + // = TITLE + // Interface for configuring the test back-end. + // + // = DESCRIPTION + // This class provides an interface for configuring the back-end of the test. + // For example, the Event Channel might be the back-end, so an adapter + // implementing this interface would be used to configure the EC in that case. + // +public: + Test_Config (void) {} + + virtual ~Test_Config (void); + + virtual int configure (TCFG_SET_WPTR configs) = 0; + // Configures the back-end. Each test_config_t in the set specifies + // the configuration of a separate type of entity. Returns 0 when + // the configuration is successful, non-zero otherwise. An + // ACE_Weak_Bound_Ptr is used because the TestConfig might want to + // keep a pointer to the Test_Config_Set but should not take + // possession of the set (that is, control when the set is deleted). + + virtual int run (void) = 0; + // Runs the configured back-end. Returns 0 if the run encountered + // no errors, non-zero otherwise. Entities are pushed periodically + // according to their respective test_config_t's until num_entities + // are pushed of each test_config_t. + + //NOTE: It might be useful to distinguish between a run which + //returns after the last entity was pushed and one which returns + //after the last entity was received at its destination. +}; + +} /* namespace TestConfig */ + +#endif /* TESTCONFIG_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.cpp new file mode 100644 index 00000000000..29e7c98d071 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.cpp @@ -0,0 +1,465 @@ +// -*- C++ -*- $Id$ + +#include "Test_Handler.h" + +#include "TestConfig.h" +#include "ace/ACE.h" +#include "ace/Log_Msg.h" +#include "ace/OS_String.h" + +#include <stdlib.h> //for atol +#include <sstream> //for istringstream + +Test_Handler::Test_Handler (const char *filename) + : configs_(new TestConfig::Test_Config_Set(0)), + fileName_(filename), + didtype_(0), //false + didperiod_(0), + didcrit_(0), + didimp_(0), + didnum_(0) +{ + +} + +Test_Handler::~Test_Handler (void) +{ + const TestConfig::Test_Config_Set &cfgs = *this->configs_; + + for(size_t i=0; i<cfgs.size(); ++i) { + delete cfgs[i]; + } +} + +const TestConfig::TCFG_SET_WPTR +Test_Handler::get_configs (void) const +{ + return TestConfig::TCFG_SET_WPTR(this->configs_); +} + + +void +Test_Handler::characters (const ACEXML_Char * cdata, + int , + int + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + const TestConfig::Test_Config_Set &cfgs = *this->configs_; + TestConfig::test_config_t *curcfg = 0; //current test_config_t is last in set + std::istringstream iss(cdata); + + switch (this->scope_.top()) + { + case TYPE: + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TYPE Characters: %s\n"),cdata)); + curcfg = cfgs[cfgs.size()-1]; + if (curcfg == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("No existing test_config_t"))); + } + if ((iss >> curcfg->type) == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); + } + this->didtype_ = 1; //true + break; + case PERIOD: + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("PERIOD Characters: %s\n"),cdata)); + curcfg = cfgs[cfgs.size()-1]; + if (curcfg == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("No existing test_config_t"))); + } + if ((iss >> curcfg->period) == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); + } + this->didperiod_ = 1; //true + break; + case NUM_ENTITIES: + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("NUM_ENTITIES Characters: %s\n"),cdata)); + curcfg = cfgs[cfgs.size()-1]; + if (curcfg == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("No existing test_config_t"))); + } + if ((iss >> curcfg->num_entities) == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT ("Invalid number format"))); + } + this->didnum_ = 1; //true + break; + case CRITICALITY: + case IMPORTANCE: + case SOURCE_CONFIG_T: + case SINK_CONFIG_T: + case TESTCONFIG: + default: + //ignore characters outside leaf elements + /* + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Ignoring characters outside leaf elements: %s\n"), + cdata)); + */ + break; + } +} + +void +Test_Handler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // Print out test_config_t's: + const TestConfig::Test_Config_Set &cfgs = *this->configs_; + char *cfg_format = "{%10d, %10d, %10d, %10d, %10d }"; + + for (size_t i=0; i<cfgs.size(); ++i) { + TestConfig::test_config_t *cfg = cfgs[i]; + + if (i!=0) + { + //finish previous line + ACE_DEBUG ((LM_DEBUG, "\n")); + } + if (cfg->comptype == TestConfig::SOURCE) + { + ACE_DEBUG ((LM_DEBUG, "SOURCE : ")); + } + else if (cfg->comptype == TestConfig::SINK) + { + ACE_DEBUG ((LM_DEBUG, "SINK : ")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "UNKNOWN: ")); + } + ACE_DEBUG ((LM_DEBUG, cfg_format, + cfg->type, + cfg->period, + cfg->criticality, + cfg->importance, + cfg->num_entities)); + } + //finish last line + ACE_DEBUG ((LM_DEBUG, "\n")); +} + +void +Test_Handler::endElement (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + if (this->scope_.empty() == 1) + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Element end outside of any scope"))); + } + else + { + if (this->scope_.top() == SOURCE_CONFIG_T + || this->scope_.top() == SINK_CONFIG_T) + { + //check that all leaf elements were there + if (this->didtype_ == 0 + || this->didperiod_ == 0 + || this->didcrit_ == 0 + || this->didimp_ == 0 + || this->didnum_ == 0) + { + ACEXML_THROW(ACEXML_SAXException(ACE_TEXT("Missing leaf element " + "(TYPE, PERIOD, CRITICALITY, " + "IMPORTANCE, or NUM_ENTITIES)"))); + } + } + this->scope_.pop(); + /* + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Popped scope; new top is %d\n"), + this->scope_.empty() ? -1 : this->scope_.top())); + */ + } +} + +void +Test_Handler::endPrefixMapping (const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Test_Handler::ignorableWhitespace (const ACEXML_Char *, + int, + int + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Test_Handler::processingInstruction (const ACEXML_Char *, + const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Test_Handler::setDocumentLocator (ACEXML_Locator * locator) +{ + this->locator_ = locator; +} + +void +Test_Handler::skippedEntity (const ACEXML_Char * + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Test_Handler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +void +Test_Handler::startElement (const ACEXML_Char *uri, + const ACEXML_Char *name, + const ACEXML_Char *qName, + ACEXML_Attributes *alist + ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + /* + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"), + uri, name, qName)); + + if (alist != 0) + for (size_t i = 0; i < alist->getLength (); ++i) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT (" %s = \"%s\"\n"), + alist->getQName (i), alist->getValue (i))); + } + */ + ACE_UNUSED_ARG(uri); + ACE_UNUSED_ARG(name); + + const TestConfig::Test_Config_Set &cfgs = *this->configs_; + + element newscope; + if (ACE_OS_String::strcmp (qName, ACE_TEXT ("type")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing TYPE scope\n"))); + newscope = TYPE; + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("period")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing PERIOD scope\n"))); + newscope = PERIOD; + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("criticality")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing CRITICALITY scope\n"))); + newscope = CRITICALITY; + if (alist != 0) + { + const ACEXML_Char *val = alist->getValue(ACE_TEXT("value")); + if (val != 0) + { + TestConfig::test_config_t *curcfg = 0; //current test_config_t is last in set + curcfg = cfgs[cfgs.size()-1]; + if (curcfg == 0) + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("No existing test_config_t"))); + } + if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_LOW")) == 0) + { + curcfg->criticality = TestConfig::VERY_LOW_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("LOW")) == 0) + { + curcfg->criticality = TestConfig::LOW_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("MEDIUM")) == 0) + { + curcfg->criticality = TestConfig::MEDIUM_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("HIGH")) == 0) + { + curcfg->criticality = TestConfig::HIGH_CRITICALITY; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_HIGH")) == 0) + { + curcfg->criticality = TestConfig::VERY_HIGH_CRITICALITY; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid value for \"value\"" + " attribute for criticality"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for criticality"))); + } + this->didcrit_ = 1; //true + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("No attributes for criticality"))); + } + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("importance")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing IMPORTANCE scope\n"))); + newscope = IMPORTANCE; + if (alist != 0) + { + const ACEXML_Char *val = alist->getValue(ACE_TEXT("value")); + if (val != 0) + { + TestConfig::test_config_t *curcfg = 0; //current test_config_t is last in set + curcfg = cfgs[cfgs.size()-1]; + if (curcfg == 0) + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("No existing test_config_t"))); + } + if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_LOW")) == 0) + { + curcfg->importance = TestConfig::VERY_LOW_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("LOW")) == 0) + { + curcfg->importance = TestConfig::LOW_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("MEDIUM")) == 0) + { + curcfg->importance = TestConfig::MEDIUM_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("HIGH")) == 0) + { + curcfg->importance = TestConfig::HIGH_IMPORTANCE; + } + else if (ACE_OS_String::strcmp(val,ACE_TEXT("VERY_HIGH")) == 0) + { + curcfg->importance = TestConfig::VERY_HIGH_IMPORTANCE; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid value for \"value\"" + " attribute for importance"))); + } + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Invalid attributes for importance"))); + } + this->didimp_ = 1; //true + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("No attributes for importance"))); + } + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("num_entities")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing NUM_ENTITIES scope\n"))); + newscope = NUM_ENTITIES; + } + else if (ACE_OS_String::strcmp(qName,ACE_TEXT("source")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing SOURCE_CONFIG_T scope\n"))); + newscope = SOURCE_CONFIG_T; + //create test_config_t for filling in by the sub-elements of this element + TestConfig::test_config_t *newcfg = 0; + ACE_NEW(newcfg,TestConfig::test_config_t()); + newcfg->comptype = TestConfig::SOURCE; + TestConfig::Test_Config_Set &cfgs = *this->configs_; + size_t cfgsize = cfgs.size(); + cfgs.size(cfgsize+1); + cfgs[cfgsize] = newcfg; + this->didtype_ = 0; //false + this->didperiod_ = 0; //false + this->didcrit_ = 0; //false + this->didimp_ = 0; //false + this->didnum_ = 0; //false + } + else if (ACE_OS_String::strcmp(qName,ACE_TEXT("sink")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing SINK_CONFIG_T scope\n"))); + newscope = SINK_CONFIG_T; + //create test_config_t for filling in by the sub-elements of this element + TestConfig::test_config_t *newcfg = 0; + ACE_NEW(newcfg,TestConfig::test_config_t()); + newcfg->comptype = TestConfig::SINK; + TestConfig::Test_Config_Set &cfgs = *this->configs_; + size_t cfgsize = cfgs.size(); + cfgs.size(cfgsize+1); + cfgs[cfgsize] = newcfg; + this->didtype_ = 0; //false + this->didperiod_ = 0; //false + this->didcrit_ = 0; //false + this->didimp_ = 0; //false + this->didnum_ = 0; //false + } + else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("testconfig")) == 0) + { + //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Pushing TESTCONFIG scope\n"))); + newscope = TESTCONFIG; + } + else + { + ACEXML_THROW (ACEXML_SAXException (ACE_TEXT("Element start of unknown type"))); + } + this->scope_.push(newscope); +} + +void +Test_Handler::startPrefixMapping (const ACEXML_Char *, + const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // no-op +} + +// Methods inherited from ACEXML_ErrorHandler. + +/* + * Receive notification of a recoverable error. + */ +void +Test_Handler::error (ACEXML_SAXParseException & ex ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + + ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), + this->locator_->getLineNumber(), + this->locator_->getColumnNumber())); + ex.print(); +} + +void +Test_Handler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + + ACE_DEBUG ((LM_DEBUG, "%s:%d:%d ", this->fileName_.c_str(), + this->locator_->getLineNumber(), + this->locator_->getColumnNumber())); + ex.print(); +} + +void +Test_Handler::warning (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.h b/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.h new file mode 100644 index 00000000000..6207791d19c --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Test_Handler.h @@ -0,0 +1,191 @@ +// $Id$ + +//============================================================================= +/** + * @file Test_Handler.h + * + * $Id$ + * + * @author Bryan Thrall <thrall@cse.wustl.edu> + */ +//============================================================================= + + +#ifndef TEST_HANDLER_H +#define TEST_HANDLER_H + +#include "TestConfig.h" + +#include "ace/String_Base.h" +#include "ACEXML/common/ContentHandler.h" +#include "ACEXML/common/ErrorHandler.h" + +#include <stack> + +enum element { + TESTCONFIG, + SOURCE_CONFIG_T, + SINK_CONFIG_T, + TYPE, + PERIOD, + CRITICALITY, + IMPORTANCE, + NUM_ENTITIES +}; + +// TODO Change XML format to list supplier and client RT_Infos separate, plus dependencies + +/** + * @class Test_Handler + * + * @brief Test_Handler is a SAX event handler which parses testconfig.dtd XML + * + * This SAX event handler parses XML according to testconfig.dtd, producing a + * set of test_config_t's. + */ +class Test_Handler : public ACEXML_ContentHandler, public ACEXML_ErrorHandler +{ +public: + + typedef std::stack<element> STACK; + + /* + * Default constructor. + */ + Test_Handler (const char *filename); + + /* + * Default destructor. + */ + virtual ~Test_Handler (void); + + /** + * Returns a reference to the Handler's internal set of + * test_config_t's. The Handler retains ownership of the + * (dynamically allocated) test_config_t's in the set. + */ + const TestConfig::TCFG_SET_WPTR get_configs (void) const; + + // Methods inherited from ACEXML_ContentHandler. + + /* + * Receive notification of character data. + */ + virtual void characters (const ACEXML_Char *ch, + int start, + int length ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of a document. + */ + virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of an element. + */ + virtual void endElement (const ACEXML_Char *namespaceURI, + const ACEXML_Char *localName, + const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * End the scope of a prefix-URI mapping. + */ + virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of ignorable whitespace in element content. + */ + virtual void ignorableWhitespace (const ACEXML_Char *ch, + int start, + int length ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a processing instruction. + */ + virtual void processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive an object for locating the origin of SAX document events. + */ + virtual void setDocumentLocator (ACEXML_Locator *locator) ; + + /* + * Receive notification of a skipped entity. + */ + virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of a document. + */ + virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of an element. + */ + virtual void startElement (const ACEXML_Char *namespaceURI, + const ACEXML_Char *localName, + const ACEXML_Char *qName, + ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Begin the scope of a prefix-URI Namespace mapping. + */ + virtual void startPrefixMapping (const ACEXML_Char *prefix, + const ACEXML_Char *uri ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + // Methods inherited from ACEXML_ErrorHandler. + + /* + * Receive notification of a recoverable error. + */ + virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a non-recoverable error. + */ + virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a warning. + */ + virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL) + ACE_THROW_SPEC ((ACEXML_SAXException)) + ; +private: + TestConfig::TCFG_SET_SPTR configs_; + + ACE_CString fileName_; + ACEXML_Locator* locator_; + + STACK scope_; + + int didtype_,didperiod_,didcrit_,didimp_,didnum_; + //for each test_config_t, whether the leaf element was processed or not +}; + +#endif /* TEST_HANDLER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.cpp new file mode 100644 index 00000000000..3006bcfa971 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.cpp @@ -0,0 +1,210 @@ +// $Id$ + +#include "TimeoutConsumer.h" + +#include <sstream> //for ostringstream + +#include "orbsvcs/Event_Utilities.h" //for ACE_ConsumerQOS_Factory +//#include "orbsvcs/RtecSchedulerC.h" +//#include "orbsvcs/RtecEventCommC.h" +//REACTOR CHANGE +#include "Timer_Event_Handler.h" +#include "orbsvcs/Event_Service_Constants.h" //for ORBSVCS_Time +#include "tao/ORB_Core.h" +#include "ace/Reactor.h" + +ACE_RCSID(EC_Examples, Consumer, "$Id$") + +TimeoutConsumer::TimeoutConsumer (Timeout_Observer* obs) + : _observer(obs) + , _consumer(this) + //REACTOR CHANGE + , _handler(0) + //REACTOR CHANGE END +{ +} + +TimeoutConsumer::~TimeoutConsumer (void) +{ + this->disconnect(); +} +/* +RtecScheduler::handle_t +TimeoutConsumer::get_RT_Info(void) +{ + return this->_rt_info; +} +*/ +void +TimeoutConsumer::connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + /* + this->_scheduler = scheduler; + + //create consumer RT_Info + std::ostringstream cons_entry_pt; + cons_entry_pt << entry_prefix << " TimeoutConsumer"; //unique RT_Info entry point + ACE_DEBUG((LM_DEBUG,"Creating %s\n",cons_entry_pt.str().c_str())); + this->_rt_info = this->_scheduler->create (cons_entry_pt.str().c_str() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->_scheduler->set (this->_rt_info, + criticality, + period, period, period, + period, + importance, + period, + 0, + RtecScheduler::OPERATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Register as consumer of timeout events + ACE_ConsumerQOS_Factory timeoutQOS; + timeoutQOS.insert_time(ACE_ES_EVENT_INTERVAL_TIMEOUT, + period, //TimeBase::TimeT + this->_rt_info); + + RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = + ec->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = + consumer_admin->obtain_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventComm::PushConsumer_var consumerv = + this->_consumer._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy->connect_push_consumer (consumerv.in (), + timeoutQOS.get_ConsumerQOS () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG((LM_DEBUG,"TimeoutConsumer connected as timeout consumer\n")); + std::ostringstream prd; + prd << period; + ACE_DEBUG((LM_DEBUG,"\tTimeout period: %s\n",prd.str().c_str())); + */ + + //REACTOR CHANGE + ACE_UNUSED_ARG(entry_prefix); + ACE_UNUSED_ARG(importance); + ACE_UNUSED_ARG(criticality); + ACE_UNUSED_ARG(scheduler); + ACE_UNUSED_ARG(ec); + + this->entry_pt << entry_prefix << " TimeoutConsumer"; //unique RT_Info entry point +/* + ACE_DEBUG((LM_DEBUG,"Creating %s\n",this->entry_pt.str().c_str())); +*/ + + this->_handler = new Timer_Event_Handler(this); + ACE_Time_Value interval; + ORBSVCS_Time::TimeT_to_Time_Value(interval,period); + TAO_ORB_Core *core = ec->orb_core(); + ACE_Reactor *reactor = core->reactor(); + //ACE_Reactor *reactor = ACE_Reactor::instance(); + this->_timer_id = reactor->schedule_timer(this->_handler, + 0, + interval, + interval); + //REACTOR CHANGE END +} + +void +TimeoutConsumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + //disconnect consumer + if (! CORBA::is_nil (this->_supplier_proxy.in())) + { + //REACTOR CHANGE + /* + this->_supplier_proxy->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->_supplier_proxy = RtecEventChannelAdmin::ProxyPushSupplier::_nil(); + //Deactivate the servant + PortableServer::POA_var poa = + this->_consumer._default_POA(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (&this->_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + poa->deactivate_object(id.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + */ + //REACTOR CHANGE END + } + + //REACTOR CHANGE + //ACE_Reactor *reactor = ACE_Reactor::instance(); + ACE_Reactor *reactor = this->_supplier_proxy->orb_core()->reactor(); + reactor->cancel_timer(this->_timer_id); + delete this->_handler; + this->_handler = 0; + //REACTOR CHANGE END +} + +void +TimeoutConsumer::push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + /* + RtecScheduler::RT_Info* info = this->_scheduler->get(this->_rt_info ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + */ + + if (events.length () == 0) + { + ACE_DEBUG ((LM_DEBUG,"TimeoutConsumer %s (%P|%t) push but no events\n",this->entry_pt.str().c_str())); + return; + } + + +/* + ACE_DEBUG((LM_DEBUG,"TimeoutConsumer %s (%P|%t) received %d events:\n",this->entry_pt.str().c_str(), + events.length())); +*/ + for (size_t i=0; i<events.length(); ++i) + { + if (ACE_ES_EVENT_INTERVAL_TIMEOUT == events[i].header.type) + { + // ACE_DEBUG((LM_DEBUG,"TimeoutConsumer %s (%P|%t) received timeout event\n",this->entry_pt.str().c_str())); + if (this->_observer != 0) + { + // ACE_DEBUG((LM_DEBUG,"TimeoutConsumer %s (%P|%t) updating observer\n",this->entry_pt.str().c_str())); + this->_observer->update(); + } + } + else + { + int prio = -1; + ACE_hthread_t handle; + ACE_Thread::self(handle); + ACE_Thread::getprio(handle,prio); + //ACE_thread_t tid = ACE_Thread::self(); +// ACE_DEBUG ((LM_DEBUG, "TimeoutConsumer %s @%d (%P|%t) we received event type %d\n", +// this->entry_pt.str().c_str(),prio,events[0].header.type)); + } + } +} + +void +TimeoutConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.h b/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.h new file mode 100644 index 00000000000..954bcf764d0 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/TimeoutConsumer.h @@ -0,0 +1,124 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// ORBSVCS Real-time Event Channel examples +// +// = FILENAME +// TimeoutConsumer +// +// = AUTHOR +// Bryan Thrall (thrall@cse.wustl.edu) +// +// ============================================================================ + +#ifndef TIMEOUTCONSUMER_H +#define TIMEOUTCONSUMER_H + +#include <sstream> //for ostringstream + +#include "orbsvcs/RtecEventChannelAdminC.h" +#include "orbsvcs/RtecEventCommC.h" +#include "orbsvcs/RtecSchedulerC.h" +#include "orbsvcs/Channel_Clients_T.h" +#include "TestConfig.h" + +//REACTOR CHANGE +class Timer_Event_Handler; //forward decl +//REACTOR CHANGE END + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// TODO: Convert to Observer (or other similar) pattern. + +class Timeout_Observer { + // = TITLE + // Interface for all TimeoutConsumer observers. + // + // = DESCRIPTION + // Any class which wants to receive notifications of timeout events + // needs to be a subclass of this interface. + +public: + virtual void update(ACE_ENV_SINGLE_ARG_DECL) = 0; + // Called by the TimeoutConsumer when a timeout occurs. + // + // For now, the notification is binary ("A timeout occurred"), but + // in the future, it should be useful to pass the event type(s) or + // even the events themselves. +}; + +class TimeoutConsumer +{ + // = TITLE + // Simple consumer object of timeout events. + // + // = DESCRIPTION This class is a consumer of timeout events. For + // each timeout event it consumes, it notifies its observer + // (specified in its constructor). + // + // There are several ways to connect and disconnect this class, + // and it is up to the driver program to use the right one. + // +public: + TimeoutConsumer (Timeout_Observer* obs); + // For now, only handle a single observer. In the future, handle any number. + // Note that the TimeoutConsumer does NOT take ownership of the observer. + + virtual ~TimeoutConsumer (void); + + //RtecScheduler::handle_t get_RT_Info(void); + + void connect (RtecScheduler::Scheduler_ptr scheduler, + const char *entry_prefix, + TimeBase::TimeT period, + RtecScheduler::Importance_t importance, + RtecScheduler::Criticality_t criticality, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + // This method connects the supplier to the EC. + + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + // Disconnect from the EC. + + // = The RtecEventComm::PushConsumer methods + + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + // pushes _events as a supplier until _to_send pushes, then calls resume() on this task. + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + // The skeleton methods. + +private: + Timeout_Observer* _observer; + + //RtecScheduler::handle_t _rt_info; + std::ostringstream entry_pt; + + RtecScheduler::Scheduler_ptr _scheduler; + + RtecEventChannelAdmin::ProxyPushSupplier_var _supplier_proxy; + // We talk to the EC (as a consumer) using this proxy. + + ACE_PushConsumer_Adapter<TimeoutConsumer> _consumer; + // We connect to the EC as a consumer so we can receive the + // timeout events. + + RtecEventComm::EventSet _events; + // set of events to push when a timeout event is received. + + //REACTOR CHANGE + Timer_Event_Handler *_handler; + + long _timer_id; + //REACTOR CHANGE END +}; + +#endif /* CONSUMER_H */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.cpp new file mode 100644 index 00000000000..861fb06573f --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.cpp @@ -0,0 +1,31 @@ +// $Id$ + +#include "Timer_Event_Handler.h" +#include "TimeoutConsumer.h" +#include "orbsvcs/Event_Service_Constants.h" + +Timer_Event_Handler::Timer_Event_Handler (TimeoutConsumer* cons) + : _consumer(cons) +{ +} + +int +Timer_Event_Handler::handle_timeout (const ACE_Time_Value &tv, + const void* arg) +{ + ACE_UNUSED_ARG(tv); + ACE_UNUSED_ARG(arg); + + RtecEventComm::EventSet event(1); + event.length(1); + + event[0].header.type = ACE_ES_EVENT_INTERVAL_TIMEOUT; + event[0].header.source = ACE_ES_EVENT_UNDEFINED; //for now, fake the supplier ID + event[0].header.ttl = 1; + + //need to create ACE_ENV, since one isn't passed into this function + ACE_DECLARE_NEW_CORBA_ENV; + this->_consumer->push(event ACE_ENV_ARG_PARAMETER); + + return 0; +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.h b/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.h new file mode 100644 index 00000000000..b92da0c2727 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/Timer_Event_Handler.h @@ -0,0 +1,24 @@ +// $Id$ + +#ifndef TIMER_EVENT_HANDLER_H_ +#define TIMER_EVENT_HANDLER_H_ + +#include <ace/Event_Handler.h> +#include <ace/Time_Value.h> +#include "TimeoutConsumer.h" + +class Timer_Event_Handler : public ACE_Event_Handler { + + public: + + Timer_Event_Handler (TimeoutConsumer* cons); + + virtual int handle_timeout (const ACE_Time_Value &tv, + const void* arg); + + private: + + TimeoutConsumer *_consumer; +}; + +#endif /* TIMER_EVENT_HANDLER_H_ */ diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.cpp b/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.cpp new file mode 100644 index 00000000000..79912ef36bd --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.cpp @@ -0,0 +1,128 @@ +// $Id$ + +#include "cpuload.h" + +#include <stdio.h> +#include <sys/time.h> +#include <signal.h> + +namespace +{ + int calibration_time = 1000; //msec + unsigned long loop_count=0; + int calibration_done = 0; + volatile int done = 0; + unsigned long per_iter_loop_count; + unsigned long calibrated_loop_count; +} + +static void +handle_signal (int signum) +{ + switch (signum) + { + case SIGVTALRM: + //printf ("VTALRM recvd\n"); + per_iter_loop_count = loop_count; + done = 1; + break; + + default: + printf ("signal %d unexpected\n", signum); + } +} + +int is_prime (const unsigned long n, + const unsigned long min_factor, + const unsigned long max_factor) +{ + if (n > 3) + for (unsigned long factor = min_factor; + factor <= max_factor; + ++factor) + if (n / factor * factor == n) + return factor; + + return 0; +} + +void do_computation (unsigned long& loop_count) +{ + static unsigned long prime_number = 961989999; + ++loop_count; + + is_prime (prime_number, 2, prime_number/2); +} + +unsigned long do_calibrate () +{ + per_iter_loop_count = 0; + loop_count = 0; + + signal (SIGVTALRM, handle_signal); + itimerval timerval; + + timerval.it_value.tv_sec = 0; + timerval.it_value.tv_usec = calibration_time*1000; + + if (setitimer(ITIMER_VIRTUAL, &timerval, 0) != 0) + { + printf("setitimer failed\n"); + } + + for (;!done;) + { + do_computation (loop_count); + } + //printf("iter done\n"); + done = 0; + return per_iter_loop_count; +} + +void CPULoad::run (struct timeval& tv) +{ + unsigned long loops=0; + unsigned long iters = (unsigned long) + (((float)calibrated_loop_count/(float)(calibration_time*1000)) * + (tv.tv_usec + tv.tv_sec*1000000)); + iters = iters + 1; + + // printf("tv = %lu sec %lu usec, iters = %lu\n", + // tv.tv_sec, tv.tv_usec, iters); + + for (;iters>0;--iters) + { + //loops is really not used here. It is used only during calibration + do_computation (loops); + } +} + +void CPULoad::calibrate (int num_iters) +{ + if (calibration_done) + return; + + printf("calibrating ...\n"); + for (int i=0; i<num_iters; ++i) + { + unsigned long tmp = do_calibrate (); + //printf("calibration ended calibrated (%dmsec) loop_count = %lu\n", + // calibration_time, tmp); + + if (calibrated_loop_count == 0) + { + calibrated_loop_count = tmp; + } + else + { + //calibrated_loop_count = (calibrated_loop_count + tmp)/2; + if (calibrated_loop_count < tmp) + calibrated_loop_count = tmp; + } + loop_count = 0; + } + + calibration_done = 1; + signal (SIGVTALRM, SIG_DFL); + //printf("calibration done\n"); +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.h b/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.h new file mode 100644 index 00000000000..5fd62ebda76 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/cpuload.h @@ -0,0 +1,15 @@ +// $Id$ + +#ifndef CPULOAD_H +#define CPULOAD_H + +#include <sys/time.h> + +class CPULoad +{ + public: + static void run (timeval& tv); + static void CPULoad::calibrate (int num_iters = 10); +}; + +#endif diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ec_client.xml b/TAO/orbsvcs/examples/RtEC/test_driver/ec_client.xml new file mode 100644 index 00000000000..8c10985f066 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ec_client.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "ec_config.dtd"> +<testconfig> + <source> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW" /> + <importance value="VERY_LOW" /> + <num_entities>10</num_entities> + </source> + <source> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH"/> + <importance value="VERY_HIGH"/> + <num_entities>10</num_entities> + </source> +</testconfig> diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ec_config.dtd b/TAO/orbsvcs/examples/RtEC/test_driver/ec_config.dtd new file mode 100644 index 00000000000..31a4cdaf457 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ec_config.dtd @@ -0,0 +1,11 @@ + <!ELEMENT testconfig (test_config_t*) > + <!ELEMENT sink (type,period,criticality,importance,num_entities) > + <!ELEMENT source (type,period,criticality,importance,num_entities) > + <!ELEMENT type (#PCDATA) > +<!-- period is in milliseconds --> + <!ELEMENT period (#PCDATA) > + <!ELEMENT criticality EMPTY > + <!ELEMENT importance EMPTY > + <!ELEMENT num_entities (#PCDATA) > + <!ATTLIST criticality value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > + <!ATTLIST importance value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/ec_server.xml b/TAO/orbsvcs/examples/RtEC/test_driver/ec_server.xml new file mode 100644 index 00000000000..6cf9e4b3a3c --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/ec_server.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "ec_config.dtd"> +<testconfig> + <sink> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW"/> + <importance value="VERY_LOW"/> + <num_entities>10</num_entities> + </sink> + <sink> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH" /> + <importance value="VERY_HIGH" /> + <num_entities>10</num_entities> + </sink> +</testconfig> diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/example.xml b/TAO/orbsvcs/examples/RtEC/test_driver/example.xml new file mode 100644 index 00000000000..62ed8bad87c --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/example.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!DOCTYPE testconfig SYSTEM "testconfig.dtd"> +<testconfig> + <source> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW" /> + <importance value="VERY_LOW" /> + <num_entities>1</num_entities> + </source> + <source> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH"/> + <importance value="VERY_HIGH"/> + <num_entities>1</num_entities> + </source> + + <sink> + <type>0</type> + <period>1000</period> + <criticality value="VERY_LOW"/> + <importance value="VERY_LOW"/> + <num_entities>10</num_entities> + </sink> + <sink> + <type>1</type> + <period>3000</period> + <criticality value="VERY_HIGH" /> + <importance value="VERY_HIGH" /> + <num_entities>10</num_entities> + </sink> +</testconfig> diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf b/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf new file mode 100644 index 00000000000..ae8708fded9 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf @@ -0,0 +1,4 @@ +# $Id$ +static EC_Factory "-ECProxyPushConsumerCollection mt:immediate:list -ECProxyPushSupplierCollection mt:immediate:list -ECdispatching kokyu -ECscheduling kokyu -ECfiltering kokyu -ECproxyconsumerlock thread -ECproxysupplierlock thread -ECsupplierfiltering per-supplier -ECObserver basic" +static Config_Factory "-ECConfig edf" +static EC_Gateway_IIOP_Factory "-ECGIIOPConsumerECControl reactive -ECGIIOPUseConsumerProxyMap 0"
\ No newline at end of file diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf.xml b/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf.xml new file mode 100644 index 00000000000..00e4eb38f91 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/svc.conf.xml @@ -0,0 +1,8 @@ +<?xml version='1.0'?> +<!-- Converted from svc.conf by svcconf-convert.pl --> +<ACE_Svc_Conf> + <!-- $Id$ --> + <static id="EC_Factory" params="-ECProxyPushConsumerCollection mt:immediate:list -ECProxyPushSupplierCollection mt:immediate:list -ECdispatching kokyu -ECscheduling kokyu -ECfiltering kokyu -ECproxyconsumerlock thread -ECproxysupplierlock thread -ECsupplierfiltering per-supplier -ECObserver basic"/> + <static id="Config_Factory" params="-ECConfig edf"/> + <static id="EC_Gateway_IIOP_Factory" params="-ECGIIOPConsumerECControl reactive -ECGIIOPUseConsumerProxyMap 0"/> +</ACE_Svc_Conf> diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/test_driver.mpc b/TAO/orbsvcs/examples/RtEC/test_driver/test_driver.mpc new file mode 100644 index 00000000000..26eb427e725 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/test_driver.mpc @@ -0,0 +1,33 @@ +project(test_driver_lib): orbsvcslib, rtevent, rtsched, rtkokyuevent, kokyu, acexml { + sharedname = Test_Driver + + Source_Files { + Consumer.cpp + Supplier.cpp + TimeoutConsumer.cpp + TestConfig.cpp + Test_Handler.cpp + Config_Factory.cpp + Timer_Event_Handler.cpp + cpuload.cpp + ECConfig_Gateway.cpp + } + + Template_Files { + ECConfig.cpp + } +} + +project(test_driver_app): orbsvcsexe, rtevent, rtsched, rtschedevent, kokyu, acexml { + exename = Test + after += test_driver_lib + libs += wrappers Test_Driver + libpaths += . + + Source_Files { + Test.cpp + } + + IDL_Files { + } +} diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/test_driver_export.h b/TAO/orbsvcs/examples/RtEC/test_driver/test_driver_export.h new file mode 100644 index 00000000000..9e594b3e6a2 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/test_driver_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Test_Driver +// ------------------------------ +#ifndef TEST_DRIVER_EXPORT_H +#define TEST_DRIVER_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TEST_DRIVER_HAS_DLL) +# define TEST_DRIVER_HAS_DLL 1 +#endif /* ! TEST_DRIVER_HAS_DLL */ + +#if defined (TEST_DRIVER_HAS_DLL) && (TEST_DRIVER_HAS_DLL == 1) +# if defined (TEST_DRIVER_BUILD_DLL) +# define Test_Driver_Export ACE_Proper_Export_Flag +# define TEST_DRIVER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TEST_DRIVER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TEST_DRIVER_BUILD_DLL */ +# define Test_Driver_Export ACE_Proper_Import_Flag +# define TEST_DRIVER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TEST_DRIVER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TEST_DRIVER_BUILD_DLL */ +#else /* TEST_DRIVER_HAS_DLL == 1 */ +# define Test_Driver_Export +# define TEST_DRIVER_SINGLETON_DECLARATION(T) +# define TEST_DRIVER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TEST_DRIVER_HAS_DLL == 1 */ + +// Set TEST_DRIVER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TEST_DRIVER_NTRACE) +# if (ACE_NTRACE == 1) +# define TEST_DRIVER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TEST_DRIVER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TEST_DRIVER_NTRACE */ + +#if (TEST_DRIVER_NTRACE == 1) +# define TEST_DRIVER_TRACE(X) +#else /* (TEST_DRIVER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TEST_DRIVER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TEST_DRIVER_NTRACE == 1) */ + +#endif /* TEST_DRIVER_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/orbsvcs/examples/RtEC/test_driver/testconfig.dtd b/TAO/orbsvcs/examples/RtEC/test_driver/testconfig.dtd new file mode 100644 index 00000000000..31a4cdaf457 --- /dev/null +++ b/TAO/orbsvcs/examples/RtEC/test_driver/testconfig.dtd @@ -0,0 +1,11 @@ + <!ELEMENT testconfig (test_config_t*) > + <!ELEMENT sink (type,period,criticality,importance,num_entities) > + <!ELEMENT source (type,period,criticality,importance,num_entities) > + <!ELEMENT type (#PCDATA) > +<!-- period is in milliseconds --> + <!ELEMENT period (#PCDATA) > + <!ELEMENT criticality EMPTY > + <!ELEMENT importance EMPTY > + <!ELEMENT num_entities (#PCDATA) > + <!ATTLIST criticality value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > + <!ATTLIST importance value (VERY_LOW|LOW|MEDIUM|HIGH|VERY_HIGH) #REQUIRED > |