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 | d14d11fc00e3adcea25805921e93a32d0c8da647 (patch) | |
tree | 22269078847c444188ffea515e3f1118d523623a /TAO/examples | |
parent | f86da1d8b8bf7fd2e75d9b4c30badd3cea34ac2d (diff) | |
download | ATCD-d14d11fc00e3adcea25805921e93a32d0c8da647.tar.gz |
Tue Jan 27 16:38:00 2004 Stephen Torri <storri@cse.wustl.edu>
Diffstat (limited to 'TAO/examples')
47 files changed, 6636 insertions, 0 deletions
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 */ |