diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2010-08-04 19:24:41 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2010-08-04 19:24:41 +0000 |
commit | 15e6dc6684cea3410274153391ffcba38fd8fa3f (patch) | |
tree | 55127de5cbdadbdd7d31541819bcb22aa9365e6f | |
parent | cc0f93851ee8a491fda9c8ba68a40152ff0ac6f8 (diff) | |
download | ATCD-15e6dc6684cea3410274153391ffcba38fd8fa3f.tar.gz |
Wed Aug 4 19:24:15 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* MPC/config/rtcosscheduling.mpb:
* orbsvcs/orbsvcs/RTCosScheduling:
* orbsvcs/orbsvcs/RTCosScheduling.idl:
* orbsvcs/orbsvcs/RTCosScheduling.mpc:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.cpp:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.cpp:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.cpp:
* orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_export.h:
* orbsvcs/tests/RTCosScheduling:
* orbsvcs/tests/RTCosScheduling/Object1_i.h:
* orbsvcs/tests/RTCosScheduling/Object1_i.cpp:
* orbsvcs/tests/RTCosScheduling/README:
* orbsvcs/tests/RTCosScheduling/RTCosScheduling.mpc:
* orbsvcs/tests/RTCosScheduling/client.cpp:
* orbsvcs/tests/RTCosScheduling/run_test.pl:
* orbsvcs/tests/RTCosScheduling/schedule.cfg:
* orbsvcs/tests/RTCosScheduling/server.ior:
* orbsvcs/tests/RTCosScheduling/server.cpp:
* orbsvcs/tests/RTCosScheduling/svc.conf:
* orbsvcs/tests/RTCosScheduling/testSched.idl:
* orbsvcs/tests/RTCosScheduling/testSched_export.h:
Removed these files, RTCosScheduling got disabled with a dummy label
5 years ago because it used a non portable way to register
interceptors and in those 5 years nobody complained about this
25 files changed, 40 insertions, 4267 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 8f00587c4b8..899a7ed4e11 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,22 +1,54 @@ +Wed Aug 4 19:24:15 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl> + + * MPC/config/rtcosscheduling.mpb: + * orbsvcs/orbsvcs/RTCosScheduling: + * orbsvcs/orbsvcs/RTCosScheduling.idl: + * orbsvcs/orbsvcs/RTCosScheduling.mpc: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.cpp: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.cpp: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.cpp: + * orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_export.h: + * orbsvcs/tests/RTCosScheduling: + * orbsvcs/tests/RTCosScheduling/Object1_i.h: + * orbsvcs/tests/RTCosScheduling/Object1_i.cpp: + * orbsvcs/tests/RTCosScheduling/README: + * orbsvcs/tests/RTCosScheduling/RTCosScheduling.mpc: + * orbsvcs/tests/RTCosScheduling/client.cpp: + * orbsvcs/tests/RTCosScheduling/run_test.pl: + * orbsvcs/tests/RTCosScheduling/schedule.cfg: + * orbsvcs/tests/RTCosScheduling/server.ior: + * orbsvcs/tests/RTCosScheduling/server.cpp: + * orbsvcs/tests/RTCosScheduling/svc.conf: + * orbsvcs/tests/RTCosScheduling/testSched.idl: + * orbsvcs/tests/RTCosScheduling/testSched_export.h: + Removed these files, RTCosScheduling got disabled with a dummy label + 5 years ago because it used a non portable way to register + interceptors and in those 5 years nobody complained about this + Wed Aug 4 17:54:39 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> * test//Bug_3672_Regression/client.cpp: - + Changed call orb->_decr_refcnt() to new name _decr_refcount(). - + * TAO_IDL/be/be_visitor_argument/invoke_cs.cpp: * TAO_IDL/be/be_visitor_argument/marshal_ss.cpp: - + Removed unused local variable and commented out code. - + * TAO_IDL/be/be_visitor_interface/interface_cs.cpp: - + In the generated marshal() operation, added generation of - /*. . .*/ guards around the 'cdr' parameter if the + /*. . .*/ guards around the 'cdr' parameter if the interface is local and parameter is not used. - + * tao/Object.h: - + Removed hard-coded 'inline' from declaration of _decr_refcount(). Wed Aug 4 14:48:11 UTC 2010 Adam Mitz <mitza@ociweb.com> diff --git a/TAO/MPC/config/rtcosscheduling.mpb b/TAO/MPC/config/rtcosscheduling.mpb deleted file mode 100644 index fabb84f7dd8..00000000000 --- a/TAO/MPC/config/rtcosscheduling.mpb +++ /dev/null @@ -1,9 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : rtportableserver, interceptors, codecfactory, orbsvcslib { - after += RTCosScheduling - libs += TAO_RTCosScheduling - tagchecks += RTCosScheduling - requires += dummy_label -} diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling.idl b/TAO/orbsvcs/orbsvcs/RTCosScheduling.idl deleted file mode 100644 index 7ffd6662db1..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling.idl +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- idl -*- */ - -//============================================================================= -/** - * @file RTCosScheduling.idl - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -/** - * This directory contains the idl for the RTCORBA 1.0 Scheduling Service. - * To generate the stubs and skeletons, run - * tao_idl -I $TAO_ROOT/ RTCosScheduling.idl - * - */ - - -#ifndef _RT_COS_SCHEDULING_ -#define _RT_COS_SCHEDULING_ - -#include <orb.idl> -#include "tao/PortableServer/PortableServer_include.pidl" - -/** - * @module RTCosScheduling - * - * @brief This module contains the interfaces for the RTCORBA 1.0 - * Scheduling Service. - */ -module RTCosScheduling { - - /** - * This exception is thrown by schedule activity when an activity name - * is passed that is associated with a priority in the config file. - * It is thrown by schedule_object when an object name is passed in - * that was not assiciated with a resource priority ceiling in the - * config file. - */ - exception UnknownName {}; - - /** - * @interface ClientScheduler - * - * @brief This interface is used by clients who wish to - * schedule activities using the RT CORBA 1.0 Scheduling Service. - */ - local interface ClientScheduler { - - /** - * schedule_activity associates an activity name with a known priority - * for that activity. It then sets RT Current to that priority. - * If the name passed does not have a priority associated then - * schedule_activity throws an UnknownName exception. - * - * @param activity_name is the name of the activity that the client - * would like to run. The activity_name is associated with a - * priority by schedule_activity and RT Current is set to that - * priority. - */ - void schedule_activity(in string activity_name ) - raises (UnknownName); - }; - - /** - * @interface ServerScheduler - * - * @brief This interface is used by nodes that hold a local object - * reference. - */ - local interface ServerScheduler { - - /** - * create_POA is called by servers that would like to use the - * RT CORBA 2.0 Scheduling Service. - * - * @param parent The poa to base the RT POA upon - * @param adapter_name the adapter name for the poa - * @param a_POAManager the poa_manager - * @param policies the list of non real time policies to be set - * - */ - PortableServer::POA create_POA ( - in PortableServer::POA parent, - in string adapter_name, - in PortableServer::POAManager a_POAManager, - in CORBA::PolicyList policies) - raises (PortableServer::POA::AdapterAlreadyExists, - PortableServer::POA::InvalidPolicy); - - /** - * schedule_object is called on servers to associate a - * CORBA object reference with a name. This allows the - * scheduling service to map a server object name to a resource - * ceiling. An UnknownName exception is found if the object name - * is not found in the config file. - */ - void schedule_object(in Object obj, in string name) - raises (UnknownName); - - }; -}; - - -#endif // _RT_COS_SCHEDULING_IDL_ diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling.mpc b/TAO/orbsvcs/orbsvcs/RTCosScheduling.mpc deleted file mode 100644 index 5245a9a3c04..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling.mpc +++ /dev/null @@ -1,24 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(RTCosScheduling) : orbsvcslib, orbsvcs_output, install, rtportableserver, interceptors, codecfactory, tao_versioning_idl_defaults { - sharedname = TAO_RTCosScheduling - idlflags += -Gd -Wb,export_macro=TAO_RTCosScheduling_Export -Wb,export_include=orbsvcs/RTCosScheduling/RTCosScheduling_export.h - dynamicflags += TAO_RTCOSSCHEDULING_BUILD_DLL - tagchecks += RTCosScheduling - requires += dummy_label - - IDL_Files { - RTCosScheduling.idl - } - Source_Files(ORBSVCS_COMPONENTS) { - RTCosScheduling { - RTCosSchedulingC.cpp - RTCosSchedulingS.cpp - RTCosScheduling - } - } - Template_Files { - } -} - diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.cpp b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.cpp deleted file mode 100644 index 4dc8780b0e7..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.cpp +++ /dev/null @@ -1,466 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_ClientScheduler_i.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#include "orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h" - -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_stdio.h" - -#include "tao/ORB_Core.h" -#include "tao/LocalObject.h" -#include "tao/PortableInterceptorC.h" -#include "tao/CodecFactory/CodecFactory.h" - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - /// Constructor - RTCosScheduling_ClientScheduler_i::RTCosScheduling_ClientScheduler_i ( - CORBA::ORB_var orb, - char *node_name, - char *file) - { - try - { - /// Read the resources and ceilings from the config file - /// and put them into the activity_map_ - if ( !ACE_OS::strcmp(file,"") || file == 0) - { - ACE_DEBUG ((LM_DEBUG, - "No config supplied to the ServerScheduler, " - "Server will not scheudle object execution " - "(ServerScheduler interceptor not installed)")); - } - else if (!tasks(node_name, file, &activity_map_)) - { - ACE_DEBUG ((LM_DEBUG,"Invalid Filename given, aborting!\n")); - ACE_OS::exit (1); - } - // The tasks were successfully read in, create the client interceptor - else - { -#if (TAO_HAS_INTERCEPTORS == 1) - ACE_NEW_THROW_EX (this->client_interceptor_, - RTCosScheduling_ClientScheduler_Interceptor(orb), - CORBA::NO_MEMORY ()); - - TAO_ORB_Core *orb_core = orb->orb_core (); - - // @@ (OO) Why isn't an ORBInitializer being used to - // register the interceptor? In fact, all of the - // following code should be done in an - // ORBInitializer, except for the interceptor list - // iteration. That is already done by the ORB when - // using an ORBInitializer to register an - // interceptor. - - /// First, get a list of all interceptors currently registered - TAO::ClientRequestInterceptor_List::TYPE &interceptors = - orb_core->client_request_interceptors (); - - - /// Now check to see if the ServerScheduler Interceptor has already - /// been registered - u_int i; - u_int unregistered = 1; - for (i = 0; i < interceptors.size () && unregistered; ++i) - { - if (ACE_OS::strncmp(interceptors[i]->_interface_repository_id (), - this->client_interceptor_->_interface_repository_id (), - ACE_OS::strlen ( - this->client_interceptor_->_interface_repository_id ()-2)) - == 0) - { - /// The interceptor is already registered, - /// don't try to register it again - unregistered = 0; - } - } - - /// if the ServerScheduler Interceptor was not registered by - /// another POA then register it now - if (unregistered) - { - orb_core->add_interceptor (this->client_interceptor_); - } -#endif /* TAO_HAS_INTERCEPTORS == 1 */ - - /// Now resolve a reference to the Real Time ORB - CORBA::Object_var rt_obj = - orb->resolve_initial_references ("RTORB"); - - // Get a reference to the real time orb - RTCORBA::RTORB_var rt_orb = - RTCORBA::RTORB::_narrow (rt_obj.in ()); - - /// resolve a reference to RT Current - rt_obj = - orb->resolve_initial_references ("RTCurrent"); - - this->current_ = - RTCORBA::Current::_narrow (rt_obj.in ()); - - /// Resolve a reference to the Linear Priority Mapping Manager - rt_obj = - orb->resolve_initial_references ("PriorityMappingManager"); - RTCORBA::PriorityMappingManager_var mapping_manager = - RTCORBA::PriorityMappingManager::_narrow (rt_obj.in ()); - - /// Create the Linear Priority Mapping Manager - ACE_NEW_THROW_EX (this->pm_, - TAO_Linear_Priority_Mapping ( - ACE_SCHED_FIFO), - CORBA::NO_MEMORY ()); - // WHERE the parameter is one of SCHED_OTHER, SCHED_FIFO, or SCHED_RR - - mapping_manager->mapping (this->pm_); - } - } - catch (const CORBA::Exception& ex) - { - ACE_ERROR ((LM_ERROR, "Could not configure the orb")); - ACE_OS::exit (1); - } -} - - -/// Implementation skeleton destructor -RTCosScheduling_ClientScheduler_i::~RTCosScheduling_ClientScheduler_i (void) -{ - delete this->pm_; -#if (TAO_HAS_INTERCEPTORS == 1) - delete this->client_interceptor_; -#endif /* TAO_HAS_INTERCEPTORS == 1 */ -} - - -void RTCosScheduling_ClientScheduler_i::schedule_activity ( - const char * activity_name) -{ - /// Look up the priority using the activity name in the activity map - COS_SCHEDULER_ACTIVITY_VALUE priority = 0; - CORBA::Short result = - this->activity_map_.find (activity_name, priority); - - /// If the activity/priority was found, set the current to the - /// appropriate priority. - if (result != -1) - { - this->current_->the_priority (priority); - } - /// If the activity was not found, throw an UnknownName exception. - else - { - throw RTCosScheduling::UnknownName (); - } -} - - -int -RTCosScheduling_ClientScheduler_i::tasks ( - const char *node_name, - const char *file_name, - CosSchedulerActivityMap *activity_map) -{ - /// get the activity list just for the particular node - const unsigned int BUF_MAX = 256; - - FILE *fp = ACE_OS::fopen (file_name, "r"); - /// Make sure we can open the file - if (fp == 0) - { - /// Error return of we cannot open the file. - ACE_ERROR_RETURN ((LM_ERROR, - "Could not find the config file %C, aborting\n", - file_name), - 0); - } - - - char line[BUF_MAX], key[64]; - ACE_OS::strsncpy (key, "Node ", sizeof (key)); - ACE_OS::strcat (key, node_name); - - /// Skip to the appropriate node -#ifndef ACE_LACKS_CLEARERR - ACE_OS::clearerr (fp); -#else -# warning ACE_OS::clearerr() is unimplemented on this platform. -# warning This code may not function properly. -#endif /* !ACE_LACKS_CLEARERR */ - do - { - ACE_OS::fgets (line, BUF_MAX, fp); - /// Make sure we did not hit the end of file - if (ACE_OS::last_error () == EOF) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Node %C not found in config file\n", - node_name), - 0); - break; - } - } - while (ACE_OS::strncmp (line, key, ACE_OS::strlen (key)) != 0); - - /// Skip to the appropriate task section of the node -#ifndef ACE_LACKS_CLEARERR - ACE_OS::clearerr (fp); -#else -# warning ACE_OS::clearerr() is unimplemented on this platform. -# warning This code may not function properly. -#endif /* !ACE_LACKS_CLEARERR */ - do - { - ACE_OS::fgets (line, BUF_MAX, fp); - /// Make sure we did not hit the end of file - if (ACE_OS::last_error () == EOF) - { - ACE_ERROR_RETURN((LM_ERROR, - "Task list not found for node %C\n", - node_name), - 0); - break; - } - } - while (ACE_OS::strncmp (line, "Tasks:", ACE_OS::strlen ("Tasks:")) != 0); - - CORBA::Short done = 0; - COS_SCHEDULER_ACTIVITY_KEY name; - COS_SCHEDULER_ACTIVITY_VALUE priority = 0; - u_int delimiter; - - /// read each activity/priority pair from the config file - while (!done) - { - /// get the activity name - ACE_OS::fgets (line, BUF_MAX, fp); - - /// Make sure we did not hit the end of file - if (ACE_OS::last_error () == EOF) - { - ACE_ERROR_RETURN((LM_ERROR, - "Task list not found for node %C\n", - node_name), - 0); - break; - } - - /// check to make sure we have not reached the end of the list. - if (ACE_OS::strncmp (line, "END", ACE_OS::strlen ("END")) != 0) - { - name = ACE_CString (line); - delimiter = name.find ('\t'); - char *p = ACE_OS::strchr (line, '\t'); - if (p) - priority = ACE_OS::atoi (p); - if (priority == 0) - priority = RTCORBA::minPriority; - if (delimiter < name.length () && delimiter > 0) - { - activity_map->bind (name.substr (0, delimiter), priority); - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "Error in reading activities from %C", - file_name), - 0); - } - } - else - { - done = 1; - } - } - - return 1; -} - - -#if (TAO_HAS_INTERCEPTORS == 1) - -RTCosScheduling_ClientScheduler_Interceptor::RTCosScheduling_ClientScheduler_Interceptor () : name_ ("RTCosScheduling_Client_Interceptor") -{ - try - { - /// resolve a reference to RT Current - int argc = 0; - ACE_TCHAR **argv= 0; - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - CORBA::Object_var obj = - orb->resolve_initial_references ("RTCurrent"); - if (CORBA::is_nil (obj.in ())) - { - ACE_OS::exit (1); - } - else - { - this->current_ = - RTCORBA::Current::_narrow (obj.in ()); - } - - obj = - orb->resolve_initial_references ("CodecFactory"); - - IOP::CodecFactory_var codec_factory; - if (CORBA::is_nil (obj.in ())) - { - ACE_DEBUG ((LM_DEBUG, - "Could not initialize client interceptor, aborting!\n")); - ACE_OS::exit (1); - } - 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; - - this->codec_ = codec_factory->create_codec (encoding); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ( - "There was an error constructing the " - "ClientScheduler Interceptor\n"); - } -} - - -RTCosScheduling_ClientScheduler_Interceptor::RTCosScheduling_ClientScheduler_Interceptor ( - const CORBA::ORB_var orb) : name_ ("RTCosScheduling_Client_Interceptor") -{ - try - { - /// resolve a reference to RT Current - CORBA::Object_var obj = - orb->resolve_initial_references ("RTCurrent"); - if (CORBA::is_nil (obj.in ())) - { - ACE_OS::exit (1); - } - else - { - this->current_ = - RTCORBA::Current::_narrow (obj.in ()); - } - - obj = - orb->resolve_initial_references ("CodecFactory"); - - // set up the codec factory to create the codec necessary to - // encode the octet stream for the service context - IOP::CodecFactory_var codec_factory; - if (CORBA::is_nil (obj.in ())) - { - ACE_DEBUG ((LM_DEBUG, - "Could not initialize client interceptor, aborting!\n")); - ACE_OS::exit (1); - } - 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; - - // Create the codec - this->codec_ = codec_factory->create_codec (encoding); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Error in creating Client Interceptor\n"); - } -} - -char * -RTCosScheduling_ClientScheduler_Interceptor::name () -{ -return CORBA::string_dup (this->name_); -} - -void -RTCosScheduling_ClientScheduler_Interceptor::destroy () -{ -} - -void -RTCosScheduling_ClientScheduler_Interceptor::send_request ( - PortableInterceptor::ClientRequestInfo_ptr ri) -{ - try - { - - // Get the Corba priority that the activity is currently running at - CORBA::Any the_priority_as_any; - the_priority_as_any <<= - this->current_->the_priority (); - - // Set up a service context to hold the priority - IOP::ServiceContext sc; - sc.context_id = IOP::RTCorbaPriority; - - // Convert the priority to an octet stream - // (that is how service contexts send data) - sc.context_data = - reinterpret_cast<CORBA::OctetSeq &> (*this->codec_->encode (the_priority_as_any)); - - // add the service context - ri->add_request_service_context (sc, 0); - - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("ERROR - in Client interceptor\n"); - throw CORBA::INTERNAL (); - } -} - -void -RTCosScheduling_ClientScheduler_Interceptor::send_poll ( - PortableInterceptor::ClientRequestInfo_ptr) -{ -} - -void -RTCosScheduling_ClientScheduler_Interceptor::receive_reply ( - PortableInterceptor::ClientRequestInfo_ptr) -{ -} - -void -RTCosScheduling_ClientScheduler_Interceptor::receive_exception ( - PortableInterceptor::ClientRequestInfo_ptr) -{ -} - -void -RTCosScheduling_ClientScheduler_Interceptor::receive_other ( - PortableInterceptor::ClientRequestInfo_ptr) -{ -} - -#endif /* TAO_HAS_INTERCEPTORS == 1 */ - -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h deleted file mode 100644 index 11821b2053b..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h +++ /dev/null @@ -1,190 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_ClientScheduler_i.h - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#ifndef CLIENT_SCHEDULER_I_H -#define CLIENT_SCHEDULER_I_H - -#include /**/ "ace/pre.h" - -#include "ace/Map_T.h" -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -#include "ace/SString.h" -#include <orbsvcs/RTCosSchedulingC.h> -#include <orbsvcs/RTCosScheduling/RTCosScheduling_export.h> -#include "tao/RTCORBA/Priority_Mapping_Manager.h" -#include "tao/PortableInterceptorC.h" -#include "tao/CodecFactory/CodecFactory.h" -#include "tao/RTCORBA/Linear_Priority_Mapping.h" - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO { - -#ifndef COS_SCHEDULER_ACTIVITY_MAP -#define COS_SCHEDULER_ACTIVITY_MAP - /** - * This typedef is used in RTCosScheduling_ClientScheduler - * to map activity names,stored as an ACE_CString, - * to CORBA priorities - */ - typedef ACE_CString COS_SCHEDULER_ACTIVITY_KEY; - typedef CORBA::Long COS_SCHEDULER_ACTIVITY_VALUE; - - typedef ACE_Map_Manager_Adapter< - COS_SCHEDULER_ACTIVITY_KEY, - COS_SCHEDULER_ACTIVITY_VALUE, - ACE_Noop_Key_Generator<COS_SCHEDULER_ACTIVITY_KEY> > - CosSchedulerActivityMap; -#endif /* ACTIVITY_MAP */ - -#if TAO_HAS_INTERCEPTORS -/** - * @class ClientRequestInterceptor - * - * @brief Simple concrete client request interceptor. - */ -class RTCosScheduling_ClientScheduler_Interceptor - : public PortableInterceptor::ClientRequestInterceptor -{ -public: - - RTCosScheduling_ClientScheduler_Interceptor(); - RTCosScheduling_ClientScheduler_Interceptor(const CORBA::ORB_var orb); - - virtual ~RTCosScheduling_ClientScheduler_Interceptor() { } - /** - * @name Methods Required by the Client Request Interceptor - * Interface - * - * These are methods that must be implemented since they are pure - * virtual in the abstract base class. They are the canonical - * methods required for all client request interceptors. - */ - //@{ - /// Return the name of this ClientRequestInterceptor. - // - virtual char * name (void); - - virtual void destroy (void); - - virtual void send_request ( - PortableInterceptor::ClientRequestInfo_ptr ri); - - virtual void send_poll ( - PortableInterceptor::ClientRequestInfo_ptr ri); - - virtual void receive_reply ( - PortableInterceptor::ClientRequestInfo_ptr ri); - - virtual void receive_exception ( - PortableInterceptor::ClientRequestInfo_ptr ri); - - virtual void receive_other ( - PortableInterceptor::ClientRequestInfo_ptr ri); - //@} - -private: - - /// The name of the interceptor - const char* name_; - - /// reference to set local priority - RTCORBA::Current_var current_; - - IOP::Codec_var codec_; - -}; -#endif /* TAO_HAS_INTERCEPTORS */ - -/** - * @class RTCosScheduling_ClientScheduler - * - * @brief Used in conjunction with the class ServerScheduler to - * provide RTCORBA 1.0 compliant scheduling - * - * This class provides the framework necessary for a client node - * to retrieve scheduling information from a config file and set - * the local OS priority. - * - */ -class TAO_RTCosScheduling_Export RTCosScheduling_ClientScheduler_i : - public virtual RTCosScheduling::ClientScheduler, - public virtual CORBA::LocalObject -{ - - public: -//@{ - /* - * Constructs a new ClientScheduler object for use on a client - * that wishes to use the RTCORBA 1.0 Scheduling Service. - * - * @param orb The orb - * @param node The name of the node the client resides on - */ - RTCosScheduling_ClientScheduler_i (CORBA::ORB_var orb, - char* node, - char* file); - - ///Destructor - virtual ~RTCosScheduling_ClientScheduler_i (void); - - - /** - * Called by clients to set the local thread priority to - * that specified in the scheduling config file - * - * @param activity_name the name of the activity that signifies - * the desired priority - */ - virtual void schedule_activity ( - const char *activity_name); -//@} - - private: - /// The map to match activity names with corba priorities - CosSchedulerActivityMap activity_map_; - - /// RT Current, to change the priority of the thread - RTCORBA::Current_var current_; - - /// RT Corba Priority Mapping - RTCORBA::PriorityMapping *pm_; - -#if TAO_HAS_INTERCEPTORS - /// The Server Interceptor that handles the PCP control - RTCosScheduling_ClientScheduler_Interceptor *client_interceptor_; -#endif /* TAO_HAS_INTERCEPTORS */ - - int tasks(const char *node_name, - const char *file_name, - CosSchedulerActivityMap *activity_map); - -}; - -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#include /**/ "ace/post.h" -#endif /* CLIENT_SCHEDULER_I */ diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.cpp b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.cpp deleted file mode 100644 index be16d03fb37..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file RTCosScheduling_PCP_Manager.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#include "orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h" -#include "ace/Condition_Thread_Mutex.h" -#include "ace/Thread.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_unistd.h" - -#if !defined (__ACE_INLINE__) -#include "orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl" -#endif /* __ACE_INLINE__ */ - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO { - -CosSchedulingLockList::CosSchedulingLockList(CosSchedulingLockNode *lock_array, - const int size, - TAO_SYNCH_MUTEX *mutex) -{ - try - { - /* - * The pointers to the beginnings of the lists must be globally visible, - * so I have chosen to use the first three locks in the array. - * lock_array[0].next() (== free_->next() ) -> start of free list - * lock_array[1].next() (== granted_->next()) -> start of granted list - * lock_array[2].next() (== pending_->next()) -> start of pending list - */ - - /// start of the free list - lock_array[0].next(&lock_array[3]); - - /// start with an empty granted list - lock_array[1].next(0); - - /// start with an empty pending list - lock_array[2].next(0); - - /// initialize the free list (link together the elements in the array) - for (int i = 3; i < (size - 1); ++i) - { - lock_array[i].next(&lock_array[i + 1]); - ACE_NEW_THROW_EX(lock_array[i].condition_, - ACE_SYNCH_CONDITION(*mutex), - CORBA::NO_MEMORY()); - } - lock_array[size - 1].next(0); /// terminate the free list - - - /// Update the positions - this->free_ = &lock_array[0]; - this->granted_ = &lock_array[1]; - this->pending_ = &lock_array[2]; - } - catch (const CORBA::Exception& ex) - { - ACE_DEBUG((LM_ERROR, - "Error in %s: Line %d - Could not generate a Locklist in shared memory\n", - __FILE__, - __LINE__)); - ex._tao_print_exception ("Exception: CosSchedulingLockList()"); - } -} - -void -CosSchedulingLockList::destroy(const int size) -{ - for (int i = 3; i < size; ++i) - { - this->free_[i].condition_->remove(); - delete &free_[i].condition_; - } -} - -int -CosSchedulingLockList::grant_lock(const CosSchedulingLockNode& L) -{ - if (this->free_->next() == 0) - { - return 0; /// no free nodes left - } - /// take a node from the free list - CosSchedulingLockNode *new_lock = this->free_->next(); - this->free_->next(this->free_->next()->next()); - *new_lock = L; - - if ((this->granted_->next() == 0) - || (this->granted_->next()->priority_ceiling_ <= L.priority_ceiling_)) - { - /// insert at the head of the list - new_lock->next(this->granted_->next()); - this->granted_->next(new_lock); - } - else - { - /// find the proper location to insert - /// the new lock (ordered by priority ceiling) - CosSchedulingLockNode *current_lock = granted_->next(); - while ((current_lock->next() != 0) - && (current_lock->next()->priority_ceiling_ > L.priority_ceiling_)) - { - current_lock = current_lock->next(); - } - new_lock->next(current_lock->next()); - current_lock->next(new_lock); - } - - return 1; -} - -int -CosSchedulingLockList::defer_lock(const CosSchedulingLockNode& L, - TAO_SYNCH_MUTEX & mutex) -{ - if (this->free_->next() == 0) - { - return 0; /// no free nodes left - } - CosSchedulingLockNode *new_lock = free_->next(); - this->free_->next(free_->next()->next()); - *new_lock = L; - - if ((this->pending_->next() == 0) - ||(this->pending_->next()->priority_ <= L.priority_)) - { - /// insert at the head of the list - new_lock->next(this->pending_->next()); - this->pending_->next(new_lock); - } - else - { - /// find the proper location to insert the new lock - CosSchedulingLockNode *current_lock = pending_->next(); - while ((current_lock->next() != 0) - && (current_lock->next()->priority_ceiling_ > L.priority_ceiling_)) - { - current_lock = current_lock->next(); - } - new_lock->next(current_lock->next()); - current_lock->next(new_lock); - } - - - if (new_lock->condition_) - { - new_lock->condition_->wait(mutex); - return 1; - } - else - { - return 0; - } -} - - -int -CosSchedulingLockList::release_lock(CosSchedulingLockNode& L) -{ - if (this->granted_->next() == 0) - { - return 0; /// empty list of granted locks - } - - if (this->granted_->next()->threadID_ == L.threadID_) - { - /// remove the lock at the head of the list and put it on the free list - - /// Set the Lock to the next one in the granted list - L = *(this->granted_->next()); - - /// (sets next offset from previous statement) - L.next(this->granted_->next()->next()); - - /// set the next granted's next one to be the next free one - this->granted_->next()->next(this->free_->next()); - - /// Set the next free one to be the next granted one - this->free_->next(this->granted_->next()); - - /// Set the next granted on to be the Lock's next one - this->granted_->next(L.next()); - - /// Set the Locks next on to NULL - L.next(0); - - return 1; - } - - /// find the lock to remove - CosSchedulingLockNode *current_lock = granted_->next(); - while ((current_lock->next() != 0) - && (current_lock->next()->threadID_ != L.threadID_)) - { - current_lock = current_lock->next(); - } - if (current_lock->next() != 0) - { - /// removes lock and prepends to the free list, as above - L = *(current_lock->next()); - L.next(current_lock->next()->next()); - current_lock->next()->next(this->free_->next()); - this->free_->next(current_lock->next()); - current_lock->next(L.next()); - L.next(0); - return 1; - } - - return 0; -} - -int -CosSchedulingLockList::remove_deferred_lock(CosSchedulingLockNode& L) -{ - if (this->pending_->next() == 0) - { - return 0; /// empty list of pending locks - } - - /// take pending lock off the head of the list - /// (highest priority request) and add to the free list - L = *(this->pending_->next()); - CosSchedulingLockNode * fn = this->pending_->next(); - this->pending_->next(this->pending_->next()->next()); - fn->next(this->free_->next()); - this->free_->next(fn); - - return 1; -} - -PCP_Manager::PCP_Manager(CosSchedulingLockList *locks, - TAO_SYNCH_MUTEX *mutex, - const RTCORBA::Current_var current) -: locks_(locks), - mutex_(mutex), - current_(current) -{ - /// Get the thread ID - this->threadID_ = (ACE_OS::getpid() << 16) + int(ACE_Thread::self()); -} - -void -PCP_Manager::lock(const int priority_ceiling, const int priority) -{ - try - { - - /// we do not want the thread to be pre-empted inside - /// this critical section, so we - /// will set its priority to the highest possible - // This is not completely necessary since the server should be running - // at RTCORBA::maxPriority - this->current_->the_priority(RTCORBA::maxPriority); - this->mutex_->acquire(); - - /// create a structure to store my own lock request - CosSchedulingLockNode MyLock; - MyLock.threadID_ = this->threadID_; - MyLock.priority_ceiling_ = MyLock.elevated_priority_ = priority_ceiling; - MyLock.priority_ = priority; - /// Start by assuming we don't have the lock then go look for it - int HaveLock = 0; - while (!HaveLock) - { - /// retrieve the highest priority ceiling from the list - CosSchedulingLockNode *highest_lock = this->locks_->highest_ceiling(); - int prio_ceiling; - /// check to see if are at the highest priority, - /// if so set the priority ceiling - if (highest_lock) - { - prio_ceiling = highest_lock->priority_ceiling_; - } - else - { - prio_ceiling = -1; - } - - /// if I hold the highest ceiling or my priority is higher than the - /// highest ceiling, just get the lock - if ((highest_lock == 0) || - (highest_lock->threadID_ == this->threadID_) || - (highest_lock->priority_ceiling_ < priority)) - { - /// Try and grant the lock, if it is not granted, - /// then there are unfortunately no more lock nodes - if (!this->locks_->grant_lock (MyLock)) - { - ACE_ERROR ((LM_ERROR, - "Fatal error--out of lock nodes!!!")); - } - /// Lock obtained from grant_lock, don't loop again - HaveLock = 1; - } - else - { - /// There is another lock out there active, put this one - /// in the list of pending locks - if (this->locks_->defer_lock(MyLock, *this->mutex_)) - { - /// done waiting for it, remove it from the pending - /// lock list, will try again to grant on next loop - /// iteration - this->locks_->remove_deferred_lock (MyLock); - } - else - { - ACE_ERROR((LM_ERROR, - "Error in deferring lock\n")); - } - } - } - - /// remove mutex on the lock list - this->mutex_->release(); - - /// at this point we have the right to set the OS priority - /// Do so at the priority ceiline. - this->current_->the_priority(priority_ceiling); - - } - catch (const CORBA::Exception& ex) - { - ACE_DEBUG((LM_ERROR, - "Error in %s: Line %d - Could lock resource\n" - __FILE__, - __LINE__)); - ex._tao_print_exception ("Exception: PCP_Manager::lock"); - } -} - -void PCP_Manager::release_lock() -{ - try - { - /// To prevent pre-emption in the critical section, - /// which could lead to unbounded blocking - this->current_->the_priority(RTCORBA::maxPriority); - - /// set up the mutex - this->mutex_->acquire(); - - /// remove the lock node from the list of locks - CosSchedulingLockNode L; - L.threadID_ = this->threadID_; - this->locks_->release_lock(L); - - /// Done with the list, release the mutex - this->mutex_->release(); - - /// Let the highest priority lock signal the condition variable - CosSchedulingLockNode *waiter = this->locks_->highest_priority(); - if (waiter) - { - waiter->condition_->signal(); - } - - /// We do not need to restore priority because we have already set this - // thread to wait at RTCORBA::maxPriority at the start of this method - } - catch (const CORBA::Exception& ex) - { - ACE_DEBUG((LM_ERROR, - "Error in %s: Line %d - Could not release lock\n" - __FILE__, - __LINE__)); - ex._tao_print_exception ("Exception: PCP_Manager::release_lock"); - } -} - - -PCP_Manager_Factory::PCP_Manager_Factory(const char *shared_file) -{ - try - { -#if !defined (ACE_LACKS_MMAP) - char temp_file[MAXPATHLEN + 1]; - - /// Get the temporary directory - if (ACE::get_temp_dir (temp_file, - MAXPATHLEN - ACE_OS_String::strlen(shared_file)) - == -1) - { - ACE_DEBUG((LM_ERROR, - "Error in %s: Line %d - Shared File Name too long\n" - __FILE__, - __LINE__)); - ACE_OS::exit(1); - } - - /// Add the filename to the end - ACE_OS_String::strcat (temp_file, shared_file); - - /// Store in the global variable. - this->shm_key_ = temp_file; - - if (ACE_OS::mkxxstemp (this->shm_key_) == 0 - || (ACE_OS::unlink (this->shm_key_) == -1 -#ifndef ACE_HAS_WINCE - && errno == EPERM -#endif /* ACE_HAS_WINCE */ - )) - ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n", - this->shm_key_)); - -#else /* !ACE_LACKS_MMAP */ - ACE_DEBUG((LM_ERROR, - "Error in %s: Line %d - ACE_LACKS_MMAP - cannot create shared memory\n" - __FILE__, - __LINE__)); - ACE_OS::exit(); -#endif /* !ACE_LACKS_MMAP */ - - /// determine space requirements for the lock list - u_int CosSchedulingLockList_space = - LOCK_ARRAY_SIZE * sizeof (CosSchedulingLockNode); - - /// allocate space in shared memory for size of the lock list - int result = - this->mem_.open(this->shm_key_, CosSchedulingLockList_space); - - /// Make sure shared memory CosSchedulingLockList is ok, scheduling - /// service cannot run without it. - if (result == -1) - { - ACE_ERROR((LM_ERROR, - "Error in %s: Line %d - Error in creating the shared " - " memory segment to hold Lock information, " - "aborting ServerScheduler.\n" - __FILE__, - __LINE__)); - ACE_OS::exit(1); - } - - - /// Make the shared memory a place for a lock list - this->lock_array_ = static_cast<CosSchedulingLockNode *> (this->mem_.malloc(CosSchedulingLockList_space)); - /// get the pointer to the list of locks and - /// construct a lock list manager object - if (this->lock_array_ == 0) - { - ACE_ERROR((LM_ERROR, - "Error in %s: Line %d - Error in creating " - "array to hold lock information " - "ServerScheduler not created\n" - __FILE__, - __LINE__)); - ACE_OS::exit(1); - } - else - { - /// construct the new lock list in shared memory - ACE_NEW_THROW_EX(this->locks_, - CosSchedulingLockList(this->lock_array_, - LOCK_ARRAY_SIZE, - &this->mutex_), - CORBA::NO_MEMORY() - ); - } - } - catch (const CORBA::Exception& ex) - { - ACE_ERROR((LM_ERROR, - "Error in %s: Line %d - Error in creating " - "PCP_Manager_Factory to create new PCP_Managers\n" - __FILE__, - __LINE__)); - ex._tao_print_exception ("PCP_Manager_Factory::PCP_Manager_Factory\n"); - } -} - -PCP_Manager_Factory::~PCP_Manager_Factory() -{ - /// throw out all the old Locks - this->locks_->destroy(LOCK_ARRAY_SIZE); - /// and delete the shared memory - this->mem_.remove(); - delete this->locks_; -} - -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h deleted file mode 100644 index 1c5f492c237..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h +++ /dev/null @@ -1,307 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_PCP_Manager.h - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - * @author based upon work by Greg Cooper - * @author University of Rhode Island - */ -//============================================================================= - -#ifndef PCP_MANAGER_H -#define PCP_MANAGER_H -#include /**/ "ace/pre.h" - -#include "ace/config-all.h" -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Shared_Memory_MM.h" -#include "ace/Map_T.h" -#include "ace/SString.h" -#include "tao/RTCORBA/RTCORBA.h" - - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO { - - -#if !defined (LOCK_ARRAY_SIZE) - #define LOCK_ARRAY_SIZE 1024 -#endif /* LOCK_ARRAY_SIZE */ - -#ifndef COS_SCHEDULING_CONTAINERS -#define COS_SCHEDULING_CONTAINERS - /* - * ResourceCeilingMap - * - * This typedef is used in the RTCORBA 1.0 Scheduling Service to - * map names of resources on a server with priority ceilings. - */ - typedef ACE_CString COS_SCHEDULING_RESOURCE_KEY; - typedef int COS_SCHEDULING_RESOURCE_VALUE; - - typedef ACE_Map_Manager_Adapter< - COS_SCHEDULING_RESOURCE_KEY, - COS_SCHEDULING_RESOURCE_VALUE, - ACE_Noop_Key_Generator<COS_SCHEDULING_RESOURCE_KEY> > CosSchedulingResourceMap; -#endif /* COS_SCHEDULING_CONTAINERS */ - - -/** -* @class CosSchedulingLockList -* -* @brief This program provides an abstract mechanism -* for the PCP_Manager class to store its lists of locks in -* shared memory. It provides an efficient allocation and -* retrieval system and uses a pseudo-linked-list based on -* offsets (rather than absolute pointers) which allows it -* to work regardless of where it is mapped in a process's -* address space. This means it can be used in a shared -* memory segment. -* -*/ -struct CosSchedulingLockNode -{ - /// unique ID of the thread owning the lock - int threadID_; - - /// the lock's priority ceiling - int priority_ceiling_; - - /// the thread's original global priority - int priority_; - - /// the thread's elevated priority - int elevated_priority_; - - /// offset to the next lock in the list - int next_offset_; - - /// Condition Variable to wait on Mutex - ACE_SYNCH_CONDITION *condition_; - - /** - * Translates the offset to the next lock - * to a pointer and returns it - */ - struct CosSchedulingLockNode *next(); - - /** - * Translates the pointer into an offset and - * stores it in the structure - */ - void next(const struct CosSchedulingLockNode *Next); - - /** - * Copies the relevant fields while preserving those which should not be - *modified - */ - const CosSchedulingLockNode& operator=(const CosSchedulingLockNode& L); - -}; - -class CosSchedulingLockList -{ - public: - /** - * Creates a CosSchedulingLockList structure using the storage in lock_array: - * if Init is 1, the array is initialized to indicate that - * none of the nodes are in use - * - * @param lock_array The shared memory space for the CosSchedulingLockList - * @param size The size of the lock list - * @param mutex the mutex that guards the CosSchedulingLockList - */ - CosSchedulingLockList(CosSchedulingLockNode *lock_array, - const int size, - TAO_SYNCH_MUTEX *mutex); - - /** - * Calls ACE_Thread::remove() on all conditions in the list; - * should only be called when SchedInit terminates - * (may not be necessary then) - * - * @param size the number of locks to destroy, starting at head - */ - void destroy(const int size); - - /** - * Adds L to the granted list, if space is available - * (returns success); the list of granted locks is kept sorted - * by priority-ceiling so that the highest ceiling can - * be found quickly at the head - * - * @param L the CosSchedulingLockNode to add to the granted list. - */ - int grant_lock(const CosSchedulingLockNode& L); - - /** - * Adds L to the pending list, if space is available - * (returns success); the list of pending locks is kept - * sorted by priority so that the highest priority thread - * awaiting a lock will be at the head; returns pointer to - * condition variable upon success, NULL otherwise - * - * @param L The lock to add to the pending list. - * @param mutex The mutex that guards the locks. - */ - int defer_lock(const CosSchedulingLockNode& L, - TAO_SYNCH_MUTEX &mutex); - - /** - * Removes a node from the granted lock list whose threadID_ - * matches that of L, replacing L with the removed lock - * - * @param L released lock - */ - int release_lock(CosSchedulingLockNode& L); - - /** - * Removes the first node from the pending lock list, - * replacing L with the removed lock - * - * @param L Reference to the lock that is removed from pending - */ - int remove_deferred_lock(CosSchedulingLockNode& L); - - /** - * Returns a pointer to the node containing the highest ceiling (the - * first node in the list of held locks) - */ - CosSchedulingLockNode *highest_ceiling(); - - - /** - * Returns a pointer to the node with the highest priority - * (from the first node in the list of pending locks - */ - CosSchedulingLockNode *highest_priority(); - - private: - - /// A list of free locks - CosSchedulingLockNode *free_; - - /// A list of Free locks - CosSchedulingLockNode *granted_; - - /// A list of pending locks awaiting to be locked - CosSchedulingLockNode *pending_; - -}; - - -/** -* @class PCP_Manager -* -* @brief PCP_Manager handles Priority Ceiling Control Protocol for the -* RTCORBA 1.0 ServerScheduler -* Each thread needs a PCP_Manager object: these are created by the -* PCP_Manager_Factory object, of which only one is needed per process -* -*/ -class PCP_Manager -{ -public: - - /** - * Initializes a PCP_Manager object with the given lists, mutex, - * condition variable, and priority mapper. - * - * @param locks A list of the locks to use in the PCP_Manager. - * @param mutex The mutex to guard the locks. - */ - PCP_Manager(CosSchedulingLockList *locks, - TAO_SYNCH_MUTEX *mutex, - const RTCORBA::Current_var current); - - /** - * Acquires a lock on a shared resource using the - * priority ceiling protocol - * - * @param PriorityCeiling The priority ceiling of the lock - * @param priority The priority to lock at. - */ - void lock(const int PriorityCeiling, const int Priority); - - /** - * Releases a lock previously granted with lock() - */ - void release_lock(); - - /** - * Returns the mThreadID data member - */ - int threadID(); - - private: - int threadID_; /// ID of thread owning this object - CosSchedulingLockList *locks_; /// combined list of locks - TAO_SYNCH_MUTEX *mutex_; /// Mutex to guard lock list - RTCORBA::Current_var current_; /// reference to set local priority - -}; - -/** -* @class PCP_Manager_Factory -* -* @brief Creates PCP_Managers. Each process needs only one of -* these objects: it can create a PCP_Manager object for each -* thread as need arises. -*/ -class PCP_Manager_Factory -{ -public: - - /** - * Initializes a PCP_Manager_Factory: each process should only - * do this once. It attaches a shared memory segment and retrieves - * pointers to the granted and pending lock lists as well as - * the mutex and condition variable. - */ - PCP_Manager_Factory(const char *shared_file); - - ~PCP_Manager_Factory(); - - /** - * Creates a new PCP manager object using the lists and - * synchronization objects found in shared memory. - */ - PCP_Manager New_PCP_Manager(RTCORBA::Current_var current); - - private: - CosSchedulingLockList *locks_; /// lists of granted and pending locks - TAO_SYNCH_MUTEX mutex_; /// The mutex for locking the lock list - ACE_Shared_Memory_MM mem_; /// shared memory space - char *shm_key_; /// Key for shared memory - CosSchedulingLockNode *lock_array_; /// The lock list - -}; - -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl" -#endif /* __ACE_INLINE__ */ - - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#include /**/ "ace/post.h" -#endif /* PCP_MANAGER_H */ diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl deleted file mode 100644 index 597b48ea4e2..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.inl +++ /dev/null @@ -1,98 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_PCP_Manager.inl - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - * @author based upon work by Greg Cooper - * @author University of Rhode Island - */ -//============================================================================= - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -/** - * Returns a pointer to the node containing the highest ceiling (the - * first node in the list of held locks) - */ -ACE_INLINE TAO::CosSchedulingLockNode * -TAO::CosSchedulingLockList::highest_ceiling() -{ - return this->granted_->next(); -} - - -/** - * Returns a pointer to the node with the highest priority - * (from the first node in the list of pending locks - */ -ACE_INLINE TAO::CosSchedulingLockNode * -TAO::CosSchedulingLockList::highest_priority() -{ - return this->pending_->next(); -} - - -/** - * Returns the mThreadID data member - */ -ACE_INLINE int -TAO::PCP_Manager::threadID() -{ - return this->threadID_; -} - - -/** - * Creates a new PCP manager object using the lists and - * synchronization objects found in shared memory. - */ -ACE_INLINE TAO::PCP_Manager -TAO::PCP_Manager_Factory::New_PCP_Manager(RTCORBA::Current_var current) -{ - return TAO::PCP_Manager(this->locks_, &this->mutex_, current); -} - -ACE_INLINE struct TAO::CosSchedulingLockNode * -TAO::CosSchedulingLockNode::next() -{ - /// INT_MAX is a special value indicating the end of a list - if (this->next_offset_ == INT_MAX) - { - return 0; - } - else - { - return this + this->next_offset_; - } -} - -ACE_INLINE void -TAO::CosSchedulingLockNode::next(const struct CosSchedulingLockNode *next_lock) -{ - /// INT_MAX is a special value indicating the end of a list - if (next_lock == 0) - { - this->next_offset_ = INT_MAX; - } - else - { - this->next_offset_ = next_lock - this; - } -} - -ACE_INLINE const TAO::CosSchedulingLockNode& -TAO::CosSchedulingLockNode::operator=(const CosSchedulingLockNode& L) -{ - this->threadID_ = L.threadID_; - this->priority_ceiling_ = L.priority_ceiling_; - this->priority_ = L.priority_; - this->elevated_priority_ = L.elevated_priority_; - - return *this; -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.cpp b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.cpp deleted file mode 100644 index 7bda2f81867..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.cpp +++ /dev/null @@ -1,690 +0,0 @@ -//============================================================================= -/** - * @file RTCosScheduling_ServerScheduler_i.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#include "orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h" -#include "ace/OS_NS_errno.h" -#include "ace/OS_NS_unistd.h" - -#if !defined (__ACE_INLINE__) -#include "orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl" -#endif /* __ACE_INLINE__ */ - -#include "tao/ORB_Core.h" -#include "tao/PortableServer/Root_POA.h" -#include "tao/RTCORBA/Linear_Priority_Mapping.h" -#include "tao/RTCORBA/Priority_Mapping_Manager.h" -#include "tao/RTPortableServer/RTPortableServer.h" -#include "tao/CodecFactory/CodecFactory.h" - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO { - -RTCosScheduling_ServerScheduler_i:: - RTCosScheduling_ServerScheduler_i (char *node, - char *file, - char *shared_file, - int numthreads - ) -: num_threads_(numthreads), - shared_file_(shared_file) -{ - /// Read the Resources and ceilings from the config file - /// and put them into the resource_map_ - if ( !ACE_OS::strcmp(file,"") || file == 0 || !TAO_HAS_INTERCEPTORS) - { - ACE_DEBUG((LM_DEBUG, - "Server will not schedule object execution " - "(ServerScheduler interceptor not installed)")); - } - else if (!resources(node, file, &this->resource_map_)) - { - ACE_OS::exit(1); - } -} - - -// Implementation skeleton destructor -RTCosScheduling_ServerScheduler_i::~RTCosScheduling_ServerScheduler_i (void) -{ - delete this->pm_; -} - - -int -RTCosScheduling_ServerScheduler_i::configure_ORB(TAO_ORB_Core *orb_core) -{ - try - { - - // Get an object reference to orb from the orb core - CORBA::ORB_ptr orb = orb_core->orb(); - -#if TAO_HAS_INTERCEPTORS - /// Construct the interceptor that the Scheduling service uses - RTCosScheduling_ServerScheduler_Interceptor *server_interceptor = 0;; - ACE_NEW_THROW_EX(server_interceptor, - RTCosScheduling_ServerScheduler_Interceptor(orb, - this->shared_file_, - &this->object_name_map_, - &this->resource_map_), - CORBA::NO_MEMORY()); - - /// First, get a list of all interceptors currently registered - TAO::ServerRequestInterceptor_List::TYPE &interceptors = - orb_core->server_request_interceptors(); - - - /// Now check to see if the ServerScheduler Interceptor has already - /// been registered - u_int i; - u_int unregistered = 1; - for (i = 0; i < interceptors.size() && unregistered; ++i) - { - if (ACE_OS::strncmp( - interceptors[i]->_interface_repository_id (), - server_interceptor->_interface_repository_id(), - ACE_OS::strlen( - server_interceptor->_interface_repository_id())-2) - == 0) - { - /// The interceptor is already registered, - /// don't try to register it again - unregistered = 0; - } - } - - if (unregistered) - { - orb_core->add_interceptor(server_interceptor); - } -#endif /* TAO_HAS_INTERCEPTORS */ - - /// Resolve a reference to the Linear Priority Mapping Manager - CORBA::Object_var rt_obj = - orb->resolve_initial_references("PriorityMappingManager"); - if (CORBA::is_nil(rt_obj.in())) - { - ACE_DEBUG((LM_DEBUG, - "Priority Mapping Manager not available, " - "RT not used on server!\n")); - return 0; - } - RTCORBA::PriorityMappingManager_var mapping_manager = - RTCORBA::PriorityMappingManager::_narrow(rt_obj.in()); - - /// Create the Linear Priority Mapping Manager - ACE_NEW_THROW_EX(this->pm_, - TAO_Linear_Priority_Mapping( - ACE_SCHED_FIFO), - CORBA::NO_MEMORY()); - - mapping_manager->mapping(this->pm_); - - } - catch (const CORBA::Exception& ex) - { - ACE_ERROR((LM_ERROR, "Could not configure the orb")); - ACE_OS::exit(1); - } - return 1; -} - - -::PortableServer::POA_ptr RTCosScheduling_ServerScheduler_i::create_POA ( - PortableServer::POA_ptr parent, - const char * adapter_name, - PortableServer::POAManager_ptr a_POAManager, - const CORBA::PolicyList & policies) -{ - try - { - // We should hopefully be using more than one thread -#if defined (ACE_HAS_THREADS) - u_int has_threads = 2; -#else - u_int has_threads = 1; -#endif /* ACE_HAS_THREADS */ - - /// Get the ORB core from the POA Manager - TAO_Root_POA *tao_poa = dynamic_cast<TAO_Root_POA*>(parent); - - TAO_ORB_Core &orb_core = tao_poa->orb_core(); - - /// configure the orb (linear mapping, register interceptor, etc.) - configure_ORB(&orb_core); - - /// Get an object reference to orb from the orb core - CORBA::ORB_ptr orb = orb_core.orb(); - - /// Now resolve a reference to the Real Time ORB - CORBA::Object_var rt_obj = - orb->resolve_initial_references("RTORB"); - if (CORBA::is_nil(rt_obj.in())) - { - ACE_DEBUG((LM_DEBUG, - "RTORB not available, " - "not using RT on the server!\n")); - return 0; - } - - /// Get the reference to the RT ORB - RTCORBA::RTORB_var rt_orb = - RTCORBA::RTORB::_narrow (rt_obj.in ()); - - if (CORBA::is_nil(rt_orb.in ())) - { - ACE_DEBUG((LM_DEBUG, - "Could not initialize orb for the server interceptor, " - "RT will not be used!\n")); - return 0; - } - - - // Copy the non realtime policy list - CORBA::PolicyList poa_policy_list = policies; - poa_policy_list.length (policies.length()+has_threads); - - /// Set the server to run at max priority so it will immediately - /// process intercepts and place new requests into the approprate queue - poa_policy_list[policies.length()] = - rt_orb->create_priority_model_policy ( - RTCORBA::SERVER_DECLARED, - RTCORBA::maxPriority); - - // Set up the threadpool -#if defined (ACE_HAS_THREADS) - CORBA::ULong stacksize = 0; - - /// ideally 1, but not implemented in TAO. This is fine as long - /// the system is not overloaded and can accept all requests - CORBA::Boolean allow_request_buffering = 0; - - // ideally max_concurrent - num_threads_, but no request buffer in TAO - CORBA::ULong max_buffered_requests = 0; - - /// TAO does not have, nor plan to implement, request buffering - CORBA::ULong max_request_buffer_size = 0; - - /// This comes from the model of the system - CORBA::ULong static_threads = this->num_threads_; - - CORBA::ULong dynamic_threads = 0; - - /// Set it to max so there will be no priority inversions - /// while the request is accepted - CORBA::ULong default_thread_priority = RTCORBA::maxPriority; - - /// Create the threadpool the server uses to execute requests - RTCORBA::ThreadpoolId threadpool = - rt_orb->create_threadpool (stacksize, - static_threads, - dynamic_threads, - default_thread_priority, - allow_request_buffering, - max_buffered_requests, - max_request_buffer_size); - - poa_policy_list[policies.length()+1] = - rt_orb->create_threadpool_policy (threadpool); -#endif /* ACE_HAS_THREADS */ - - - /// Create the RT POA - PortableServer::POA_var poa = - parent->create_POA (adapter_name, - a_POAManager, - poa_policy_list); - - RTPortableServer::POA_var rt_poa = - RTPortableServer::POA::_narrow(poa.in()); - - /// return the reference to the RT POA - return rt_poa.in(); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ( - "ERROR: Could not create a Scheduling Service POA\n"); - return parent; - } - return parent; -} - -void -RTCosScheduling_ServerScheduler_i::schedule_object ( - CORBA::Object_ptr obj, - const char * name) -{ - /// Check and see if the object name is in the resource map, - /// if it is, then there is a ceiling for it and we can add it to the - /// object name map. If there is no name in the resource map, then there - /// is no valid ceiling for it, throw an UnknownName exception - if (this->resource_map_.find(name) == -1) - { - throw RTCosScheduling::UnknownName(); - } - else - { - this->object_name_map_.rebind(obj, name); - } -} - - - -#if TAO_HAS_INTERCEPTORS -RTCosScheduling_ServerScheduler_Interceptor::RTCosScheduling_ServerScheduler_Interceptor( - CORBA::ORB_ptr orb, - char *shared_file, - CosSchedulingObjectMap *ObjectMap, - CosSchedulingResourceMap *resourceMap) -: name_("RTCosScheduling_ServerScheduler_Interceptor"), - orb_(orb), - object_name_map_(ObjectMap), - resource_map_(resourceMap) -{ - try - { - // Create a new Priority Ceiling protocol manager factory - ACE_NEW_THROW_EX(this->PCP_factory_, - PCP_Manager_Factory(shared_file), - CORBA::NO_MEMORY()); - - - /// Now resolve a reference to the Real Time ORB - CORBA::Object_var obj = - this->orb_->resolve_initial_references("RTORB"); - RTCORBA::RTORB_var rt_orb; - if (CORBA::is_nil(obj.in ())) - { - ACE_DEBUG((LM_DEBUG, - "RTORB not available, " - "RT ServerScheduler not used!\n")); - return; - } - else - { - rt_orb =RTCORBA::RTORB::_narrow (obj.in ()); - } - - // Now get a reference to the RTCurrent - // for the PCP manager to control - obj = this->orb_->resolve_initial_references ("RTCurrent"); - if (CORBA::is_nil(obj.in())) - { - ACE_DEBUG((LM_DEBUG, - "RTCurrent not available, " - "RT ServerScheduler not used!\n")); - return; - } - else - { - this->current_ = - RTCORBA::Current::_narrow (obj.in ()); - } - - // Now get a reference to the codec factory to create a codec that will - // decode the client priority sent in the service context - obj = - this->orb_->resolve_initial_references ("CodecFactory"); - - if (CORBA::is_nil(obj.in())) - { - ACE_DEBUG((LM_DEBUG, - "Could not initalize the server interceptor Codec, " - "RT ServerScheduler not used!\n")); - return; - } - else - { - this->codec_factory_ = IOP::CodecFactory::_narrow(obj.in()); - } - - - // Set up the codec - IOP::Encoding encoding; - encoding.format = IOP::ENCODING_CDR_ENCAPS; - encoding.major_version = 1; - encoding.minor_version = 2; - - this->codec_ = this->codec_factory_->create_codec(encoding); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ( - "Error in installing the interceptor for the ServerScheduler\n"); - } -} - - -// Delete the objects we have made in the interceptor -RTCosScheduling_ServerScheduler_Interceptor::~RTCosScheduling_ServerScheduler_Interceptor() -{ - this->object_name_map_ = 0; - this->resource_map_ = 0; - delete this->PCP_factory_; -} - -void -RTCosScheduling_ServerScheduler_Interceptor::receive_request( - PortableInterceptor::ServerRequestInfo_ptr ri) -{ - try - { - - ACE_CString name = ""; - COS_SCHEDULING_RESOURCE_VALUE ceiling, base_priority = 0; - - // Now get a reference to the POA, this is used to get a reference - // to the target object - PortableInterceptor::AdapterName *adapter_seq = ri->adapter_name(); - PortableServer::POA_var poa; - const char *adapter_name = - (*adapter_seq)[adapter_seq->length() - 1]; - - CORBA::Object_var obj = - this->orb_->resolve_initial_references("RootPOA"); - if (CORBA::is_nil(obj.in())) - { - ACE_DEBUG((LM_DEBUG, - "Could not get root POA, " - "RT scheduling not used on server!\n")); - return; - } - else - { - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow(obj.in()); - if (CORBA::is_nil(root_poa.in())) - { - ACE_ERROR((LM_ERROR, - "No POA found in Interceptor prio not set\n")); - return; - } - poa = root_poa->find_POA(adapter_name, 0); - } - - // decode the Client priority sent in the service context - IOP::ServiceId id = IOP::RTCorbaPriority; - IOP::ServiceContext_var sc; - try - { - sc = ri->get_request_service_context(id); - } - catch (const CORBA::Exception& ex) - { - // The RTCorbaPriority was not sent, do not use real time - // Here we cannot let the server continue to run at - // RTCORBA::maxPriority, so change to RTCORBA::minPriority - // and things will run best effort - this->current_->the_priority(RTCORBA::minPriority); - return; - } - - CORBA::OctetSeq ocSeq = CORBA::OctetSeq( - sc->context_data.length(), - sc->context_data.length(), - sc->context_data.get_buffer(), - 0); - - CORBA::Any the_priority_as_any; - the_priority_as_any = *this->codec_->decode(ocSeq); - - RTCORBA::Priority the_client_priority; - the_priority_as_any >>= the_client_priority; - - // get the object from the object ID that is passed - CORBA::OctetSeq_var oseq = ri->object_id(); - PortableServer::ObjectId oid(oseq -> length(), - oseq -> length(), - oseq -> get_buffer(), - 0); - - CORBA::Object_var target_object = poa->id_to_reference(oid); - - // Check to make sure we have the object as scheduled by the - // ServerScheduler - if (this->object_name_map_->find(target_object, name) == -1 ) - { - ACE_DEBUG((LM_DEBUG, - "Object not found in config file, " - "RT ServerScheduler not used!\n")); - // Here we cannot let the server continue to run at - // RTCORBA:: maxPriority, so it will run at minPriority - // and things will run best effort - this->current_->the_priority(RTCORBA::minPriority); - return; - } - - /// If the object name if found, get its priority ceiling - if (this->resource_map_->find(name, ceiling) == -1 ) - { - /// We could not find the Object's priority ceiling - /// given its name - ACE_DEBUG((LM_DEBUG, - "Object Resource Ceiling not found in config file, " - "RT ServerScheduler not used!\n")); - // Here we cannot let the server continue to run at - // RTCORBA:: maxPriority, so it will run at minPriority - // and things will run best effort - this->current_->the_priority(RTCORBA::minPriority); - return; - } - - /// Get the base priority of the server - if (this->resource_map_->find("BP", base_priority) == -1 ) - { - ACE_DEBUG((LM_DEBUG, - "Server Base Priority not found in config file, " - "RTServerScheduler not used!\n")); - // Here we cannot let the server continue to run at - // RTCORBA:: maxPriority, so it will run at minPriority - // and things will run best effort - this->current_->the_priority(RTCORBA::minPriority); - return; - } - - /// Create a new PCP Manager to manage the priority control - COS_SCHEDULING_INVOCATION_VALUE p = 0; - ACE_NEW_THROW_EX(p, - PCP_Manager( - PCP_factory_->New_PCP_Manager(this->current_)), - CORBA::NO_MEMORY()); - - // Get the lock on the resource, using MPCP - - p->lock(ceiling + base_priority, - the_client_priority + base_priority); - - /// store the thread in the invocation list - this->invocation_map_.bind( - p->threadID(), - p); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Unknown exception in the receive request\n"); - ACE_OS::exit(1); - } -} - -void -RTCosScheduling_ServerScheduler_Interceptor::send_reply( - PortableInterceptor::ServerRequestInfo_ptr ri) -{ - ACE_UNUSED_ARG(ri); - finish_execution(); -} - -void -RTCosScheduling_ServerScheduler_Interceptor::finish_execution() -{ - PCP_Manager *p = 0; - this->invocation_map_.unbind((ACE_OS::getpid() << 16) + int(ACE_Thread::self()),p); - if (p) - { - /// Release the Lock on the Thread - p->release_lock(); - /// Delete the PCP Manager - delete p; - } -} - -char* -RTCosScheduling_ServerScheduler_Interceptor::name(void) -{ - return CORBA::string_dup(this->name_); -} - -void -RTCosScheduling_ServerScheduler_Interceptor::destroy(void) -{ -} - -void -RTCosScheduling_ServerScheduler_Interceptor::receive_request_service_contexts( - PortableInterceptor::ServerRequestInfo_ptr ri) -{ - ACE_UNUSED_ARG(ri); -} - -void -RTCosScheduling_ServerScheduler_Interceptor::send_exception( - PortableInterceptor::ServerRequestInfo_ptr ri) -{ - ACE_UNUSED_ARG(ri); - finish_execution(); -} - -void -RTCosScheduling_ServerScheduler_Interceptor::send_other( - PortableInterceptor::ServerRequestInfo_ptr ri) - { - ACE_UNUSED_ARG(ri); - finish_execution(); - } - -#endif /* TAO_HAS_INTERCEPTORS */ - -int -RTCosScheduling_ServerScheduler_i::resources( - const char *node_name, - const char *file_name, - CosSchedulingResourceMap *resource_map) -{ - /// get the resource list list just for the particular node - const unsigned int BUF_MAX = 256; - FILE *fp = ACE_OS::fopen(file_name, "r"); - if (fp == 0) - { - /// Error return of we cannot open the file. - ACE_ERROR_RETURN((LM_ERROR, - "Could not find the config file %s, aborting\n", - file_name), - 0); - } - - - char line[BUF_MAX], key[64]; - ACE_OS::strncpy(key, "Node ", sizeof("Node ")); - ACE_OS::strcat(key, node_name); - -#ifndef ACE_LACKS_CLEARERR - ACE_OS::clearerr(fp); -#else -# warning ACE_OS::clearerr() is unimplemented on this platform. -# warning This code may not function properly. -#endif /* !ACE_LACKS_CLEARERR */ - do - { - ACE_OS::fgets(line, BUF_MAX, fp); - if (ACE_OS::last_error() == EOF) - { - ACE_ERROR_RETURN((LM_ERROR, - "Node %s not found in config file\n", - node_name), - 0); - break; - } - - } - while (ACE_OS::strncmp(line,key,ACE_OS::strlen(key)) != 0); - - /// Skip to the appropriate Task section of the node -#ifndef ACE_LACKS_CLEARERR - ACE_OS::clearerr(fp); -#else -# warning ACE_OS::clearerr() is unimplemented on this platform. -# warning This code may not function properly. -#endif /* !ACE_LACKS_CLEARERR */ - do - { - ACE_OS::fgets(line, BUF_MAX, fp); - /// Make sure we did not hit the end of file - if (ACE_OS::last_error() == EOF) - { - ACE_ERROR_RETURN((LM_ERROR, - "Task list not found for node %s\n", - node_name), - 0); - break; - } - - } - while (ACE_OS::strncmp(line, - "Resources:", - ACE_OS::strlen("Resources:") - ) != 0); - - CORBA::Short done = 0; - COS_SCHEDULING_RESOURCE_KEY name; - COS_SCHEDULING_RESOURCE_VALUE priority = 0; - u_int delimiter; - - /// read each activity/priority pair from the config file - while (!done) - { - /// get the activity name - ACE_OS::fgets(line, BUF_MAX, fp); - - /// check to make sure we have not reached the end of the list. - if (ACE_OS::strncmp(line, "END", ACE_OS::strlen(line)-1) != 0) - { - name = ACE_CString(line); - delimiter = name.find('\t'); - char *p = ACE_OS::strchr(line, '\t'); - if (p) - priority = ACE_OS::atoi(p); - if (priority == 0) - priority = RTCORBA::minPriority; - if (delimiter < name.length() && delimiter > 0) - { - resource_map->bind(name.substr(0, delimiter), priority); - } - else - { - ACE_ERROR_RETURN((LM_ERROR, - "Error in reading resources from %s, aborting", - file_name), - 0); - } - } - else - { - done = 1; - } - } - - return 1; -} - -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h deleted file mode 100644 index 1e06790ae1e..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h +++ /dev/null @@ -1,278 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_ServerScheduler_i.h - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#ifndef SERVER_SCHEDULERI_H -#define SERVER_SCHEDULERI_H - -#include /**/ "ace/pre.h" - -#include "ace/Map_T.h" -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/SString.h" -#include <orbsvcs/RTCosSchedulingS.h> -#include <orbsvcs/RTCosScheduling/RTCosScheduling_export.h> -#include "orbsvcs/RTCosScheduling/RTCosScheduling_PCP_Manager.h" -#include "tao/PortableInterceptorC.h" -#include "tao/CodecFactory/CodecFactory.h" -#include "tao/LocalObject.h" - - - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -#ifndef RTCOSSCHEDULING_SERVER_CONTAINERS -#define RTCOSSCHEDULING_SERVER_CONTAINERS - -/** - * CosSchedulingObjectNameMap - * - * This typedef is used by the RTCORBA 1.0 ServerScheduler to map - * CORBA object references to names - */ - -typedef CORBA::Object_var COS_SCHEDULING_OBJECT_NAME_KEY; -typedef ACE_CString COS_SCHEDULING_OBJECT_NAME_VALUE; - -template<> -class TAO_RTCosScheduling_Export ACE_Equal_To< COS_SCHEDULING_OBJECT_NAME_KEY > -{ - public: - int operator () (const COS_SCHEDULING_OBJECT_NAME_KEY lhs, - const COS_SCHEDULING_OBJECT_NAME_KEY rhs) const; -}; - - -namespace TAO { - -class TAO_RTCosScheduling_Export CosSchedulingObjectMap_Hash_Key -{ -public: - u_long operator () (const COS_SCHEDULING_OBJECT_NAME_KEY &key) const; -}; - -typedef ACE_Hash_Map_Manager_Ex_Adapter< - COS_SCHEDULING_OBJECT_NAME_KEY, - COS_SCHEDULING_OBJECT_NAME_VALUE, - CosSchedulingObjectMap_Hash_Key, - ACE_Equal_To<COS_SCHEDULING_OBJECT_NAME_KEY>, - ACE_Noop_Key_Generator<COS_SCHEDULING_OBJECT_NAME_KEY> > CosSchedulingObjectMap; - -/** - * This typedef is used in the ServerScheduler to hold a list of - * priority ceiling protocol managers for each active method call - * from a client. - */ -typedef int COS_SCHEDULING_INVOCATION_KEY; -typedef PCP_Manager * COS_SCHEDULING_INVOCATION_VALUE; - -class CosSchedulingInvocation_Hash_key -{ -public: - u_long operator () (const COS_SCHEDULING_INVOCATION_KEY &key) const; -}; - -typedef ACE_Hash_Map_Manager_Ex_Adapter< - COS_SCHEDULING_INVOCATION_KEY, - COS_SCHEDULING_INVOCATION_VALUE, - CosSchedulingInvocation_Hash_key, - ACE_Equal_To<COS_SCHEDULING_INVOCATION_KEY>, - ACE_Noop_Key_Generator<COS_SCHEDULING_INVOCATION_KEY> > CosSchedulingInvocationMap; - - -#endif /* RTCOSSCHEDULING_SERVER_CONTAINERS */ - -#if TAO_HAS_INTERCEPTORS - /** - * @class RTCosScheduling_ServerScheduler_Interceptor - * - * @brief The RTCosScheduling_ServerScheduler_Interceptor intercepts CORBA - * requests on behalf of the RTCORBA 1.0 scheduling service and - * schedules the requests. - */ - class RTCosScheduling_ServerScheduler_Interceptor - : public PortableInterceptor::ServerRequestInterceptor - { - public : - RTCosScheduling_ServerScheduler_Interceptor(CORBA::ORB_ptr orb, - char *shared_file, - CosSchedulingObjectMap *CosSchedulingObjectMap, - CosSchedulingResourceMap *resourceMap); - - - virtual ~RTCosScheduling_ServerScheduler_Interceptor(); - - virtual char* name(void); - - virtual void destroy(); - - virtual void receive_request( - PortableInterceptor::ServerRequestInfo_ptr ri); - - virtual void receive_request_service_contexts( - PortableInterceptor::ServerRequestInfo_ptr ri); - - virtual void send_reply( - PortableInterceptor::ServerRequestInfo_ptr ri); - - virtual void send_exception( - PortableInterceptor::ServerRequestInfo_ptr ri); - - virtual void send_other( - PortableInterceptor::ServerRequestInfo_ptr ri); - - void finish_execution(); - - - private: - - /// The name of the interceptor - const char* name_; - - /// reference to set local priority - RTCORBA::Current_var current_; - - /// Factory reference to receive PCP_managers - PCP_Manager_Factory * PCP_factory_; - - /// Map to match threadIDs with PCP_Managers - CosSchedulingInvocationMap invocation_map_; - - //The orb - CORBA::ORB_ptr orb_; - - /// Map to match CORBA::Object_vars to names - CosSchedulingObjectMap *object_name_map_; - - /// Map to match Resource names to Ceilings - CosSchedulingResourceMap *resource_map_; - - // The codec to decode incoming CORBA Priorities - IOP::Codec_var codec_; - - - // The factory to create the codec - IOP::CodecFactory_var codec_factory_; - }; - -#endif /* TAO_HAS_INTERCEPTORS */ - - /** - * @class RTCosScheduling_ServerScheduler_i - * - * @brief The ServerScheduler class handles server side - * scheduling for the RTCORBA 1.0 Scheduling Service. - */ - class TAO_RTCosScheduling_Export RTCosScheduling_ServerScheduler_i - : public virtual RTCosScheduling::ServerScheduler, - public virtual CORBA::LocalObject - { - public: - // Constructor - RTCosScheduling_ServerScheduler_i (char *node, - char *file, - char *shared_file, - int numthreads); - - //Destructor - virtual ~RTCosScheduling_ServerScheduler_i (void); - - /** - * This creates and returns a RT POA for use on the server. - * It accepts a set of non-RT policies and sets these as - * well as RT policies (threadpooling and Server Declared). - * - * @param parent The poa to base the RT POA upon - * @param adapter_name the adapter name for the poa - * @param a_POAManager the poa_manager - * @param policies the list of non real time policies to be set - */ - virtual ::PortableServer::POA_ptr create_POA ( - PortableServer::POA_ptr parent, - const char * adapter_name, - PortableServer::POAManager_ptr a_POAManager, - const CORBA::PolicyList & policies); - - /** - * This maps a CORBA::Object_var with a name. The names are - * later associated with priority ceiling stored in the - * scheduling config file. - * - * @param obj the CORBA object reference to associate with a name - * @param name name to associate with the CORBA object reference - */ - virtual void schedule_object (CORBA::Object_ptr obj, - const char * name); - - private: - - /** - * This sets the orb for the ServerScheduler, - * it also resolves references to RT current and sets - * priority mapping - */ - int configure_ORB(TAO_ORB_Core *orb_core); - - /// RT Current, to change the priority of the thread - - /// RT Corba Priority Mapping , uses - /// Linear Priority Mapping - RTCORBA::PriorityMapping *pm_; - - /// The number of threads in the server threadpool - int num_threads_; - - char *shared_file_; - - /// The map to match CORBA::Object_vars - /// to names - CosSchedulingObjectMap object_name_map_; - - /// The map to match resource names to corba priorities - CosSchedulingResourceMap resource_map_; - - /* - * resources populates a string/int map with a list of resources (keys) - * and associated priority ceilings(values) - * - * @param node_name the name of the node the client resides on, - * resources() only retrieves ceilings for the local node - * - * @param map resource_map a reference to the resource map to populate - * - */ - int resources(const char* node_name, - const char* file_name, - CosSchedulingResourceMap * resource_map); - }; -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#if defined (__ACE_INLINE__) -#include "orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl" -#endif /* __ACE_INLINE__ */ - - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#include /**/ "ace/post.h" -#endif /* SERVER_SCHEDULERI_H */ diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl deleted file mode 100644 index 3098246643a..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.inl +++ /dev/null @@ -1,39 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file RTCosScheduling_ServerScheduler_i.inl - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_INLINE int -ACE_Equal_To< COS_SCHEDULING_OBJECT_NAME_KEY >::operator () ( - COS_SCHEDULING_OBJECT_NAME_KEY lhs, - COS_SCHEDULING_OBJECT_NAME_KEY rhs) const -{ - return lhs->_is_equivalent(rhs.in()); -} - -ACE_INLINE u_long -TAO::CosSchedulingObjectMap_Hash_Key::operator () ( - const COS_SCHEDULING_OBJECT_NAME_KEY &key) const -{ - u_long value = key->_hash(ACE_UINT32_MAX); - return value; -} - -ACE_INLINE u_long -TAO::CosSchedulingInvocation_Hash_key::operator () ( - const COS_SCHEDULING_INVOCATION_KEY &key) const -{ - return static_cast<u_long> (key); -} - -TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_export.h b/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_export.h deleted file mode 100644 index 413a49c7658..00000000000 --- a/TAO/orbsvcs/orbsvcs/RTCosScheduling/RTCosScheduling_export.h +++ /dev/null @@ -1,60 +0,0 @@ - -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl TAO_RTCosScheduling -// ------------------------------ -#ifndef TAO_RTCOSSCHEDULING_EXPORT_H -#define TAO_RTCOSSCHEDULING_EXPORT_H - -#include "ace/config-all.h" - -#if defined (TAO_AS_STATIC_LIBS) -# if !defined (TAO_RTCOSSCHEDULING_HAS_DLL) -# define TAO_RTCOSSCHEDULING_HAS_DLL 0 -# endif /* ! TAO_RTCOSSCHEDULING_HAS_DLL */ -#else -# if !defined (TAO_RTCOSSCHEDULING_HAS_DLL) -# define TAO_RTCOSSCHEDULING_HAS_DLL 1 -# endif /* ! TAO_RTCOSSCHEDULING_HAS_DLL */ -#endif - -#if defined (TAO_RTCOSSCHEDULING_HAS_DLL) && (TAO_RTCOSSCHEDULING_HAS_DLL == 1) -# if defined (TAO_RTCOSSCHEDULING_BUILD_DLL) -# define TAO_RTCosScheduling_Export ACE_Proper_Export_Flag -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* TAO_RTCOSSCHEDULING_BUILD_DLL */ -# define TAO_RTCosScheduling_Export ACE_Proper_Import_Flag -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* TAO_RTCOSSCHEDULING_BUILD_DLL */ -#else /* TAO_RTCOSSCHEDULING_HAS_DLL == 1 */ -# define TAO_RTCosScheduling_Export -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARATION(T) -# define TAO_RTCOSSCHEDULING_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* TAO_RTCOSSCHEDULING_HAS_DLL == 1 */ - -// Set TAO_RTCOSSCHEDULING_NTRACE = 0 to turn on library specific tracing even if -// tracing is turned off for ACE. -#if !defined (TAO_RTCOSSCHEDULING_NTRACE) -# if (ACE_NTRACE == 1) -# define TAO_RTCOSSCHEDULING_NTRACE 1 -# else /* (ACE_NTRACE == 1) */ -# define TAO_RTCOSSCHEDULING_NTRACE 0 -# endif /* (ACE_NTRACE == 1) */ -#endif /* !TAO_RTCOSSCHEDULING_NTRACE */ - -#if (TAO_RTCOSSCHEDULING_NTRACE == 1) -# define TAO_RTCOSSCHEDULING_TRACE(X) -#else /* (TAO_RTCOSSCHEDULING_NTRACE == 1) */ -# if !defined (ACE_HAS_TRACE) -# define ACE_HAS_TRACE -# endif /* ACE_HAS_TRACE */ -# define TAO_RTCOSSCHEDULING_TRACE(X) ACE_TRACE_IMPL(X) -# include "ace/Trace.h" -#endif /* (TAO_RTCOSSCHEDULING_NTRACE == 1) */ - -#endif /* TAO_RTCOSSCHEDULING_EXPORT_H */ - -// End of auto generated file. diff --git a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp b/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp deleted file mode 100644 index 0f139779223..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Object1_i.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#include "Object1_i.h" -#include "ace/ACE.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" -//#include "tao/RTCORBA/RTCORBA.h" -////##include "ace/Task.h" -// -//#if !defined (ACE_LACKS_PRAGMA_ONCE) -//# pragma once -//#endif /* ACE_LACKS_PRAGMA_ONCE */ -// -////#include "ace/CORBA_macros.h" -////#include "tao/RTCORBA/Priority_Mapping_Manager.h" -////#include "tao/corba.h" -////#include "tao/ORB_Core.h" -// - -Object1_impl::Object1_impl() -{ -} - - -Object1_impl::~Object1_impl() -{ -} - - -void Object1_impl::method1(const char* activity, - CORBA::Long seconds, - char* &output) -{ - const int scale_factor = 2000; - int work; - const int time_size = 35; - ACE_TCHAR date_and_time[time_size]; - char buf[128]; - char buf2[128]; - - ACE_OS::sprintf(buf, - "%s\t%s\tBeginning work on the server\n", - ACE::timestamp(date_and_time, time_size), - activity); - ACE_DEBUG((LM_DEBUG,"%s",buf)); - - if (ACE_OS::strcmp(activity,"Client1") == 0) - { - ACE_OS::sleep(5); - } - - /// Simulate some work - static CORBA::ULong prime_number = 9619; - work = scale_factor * seconds; - for (; work != 0; work--) - { - ACE::is_prime (prime_number, 2, prime_number / 2); - } - - ACE_OS::sprintf(buf2, - "%s\t%s\tFinished work on the server\n", - ACE::timestamp(date_and_time, time_size), - activity); - ACE_DEBUG((LM_DEBUG,"%s",buf2)); - ACE_OS::strcat(buf,buf2); - output = ACE_OS::strdup(buf); - -} diff --git a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.h b/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.h deleted file mode 100644 index 80e16f06dbe..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file Object1_i.h - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#ifndef Object1_I_H -#define Object1_I_H - -#include "testSchedS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -/** - * @class Object1_i - * - * @brief This class is used to test the RTCORBA 1.0 Scheduling Service - * - */ -class Object1_impl : public POA_testSched::Object1 -{ - public: - Object1_impl(); - - virtual ~Object1_impl(); - - virtual void method1(const char *activity, - CORBA::Long seconds, - char *&output - ); -}; - -#endif /* Object1_I_H */ diff --git a/TAO/orbsvcs/tests/RTCosScheduling/README b/TAO/orbsvcs/tests/RTCosScheduling/README deleted file mode 100644 index a400d10dc03..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/README +++ /dev/null @@ -1,270 +0,0 @@ -README,v 1.0 2003/07/09 - -This is a test for RTCORBA 1.0 scheduling Service. - -Matt Murphy <murphym@cs.uri.edu> -University of Rhode Island - -Scenario: --------- -Client nodes connect to a server to make object calls to execute -on the server. An offline analysis tool has determined appropriate -priorities for each task on the system. These priorities are stored -in a configuration file. - -The server is started with the appropriate object instantiated that -will be used by the clients, and the server has created a local -ServerScheduler object, which sets the RT policies necessary for -the scheduling service to execute (set through the -ServerScheduler->create_POA(...) method.). Threads on the server run at -RTCORBA::maxPriority so the server can immediately intercept incoming requests -for proper scheduling. The Client creates a local -ClientScheduler object, which read the configuration file and stores -the activity/priority relationships for the given node. Clients make -a schedule_activity("activity_name") call to the ClientScheduler -object to set the local system priority as specified by the activity name. - -When a client makes a CORBA call on an object residing on the server, -the Client Propagated Priority policy (set in ServerScheduler) -ensures that the server receives the priority the client runs at. A -ServerScheduler receive_request() interceptor intercepts the method -call and locks the thread while there are higher priority tasks executing -on the server. The ServerScheduler then sets the server thread to -run using MPCP while the task executes. A ServerScheduler send_reply -interceptor raises the thread priority back to RTCORBA::maxPriority so it can -intercept the next incoming request. - - -To compile (on Unix): ----------- -Ensure that RTCosScheduling is compiled. There should be a -libTAO_RTCosScheduling.so file in $ACE_ROOT/TAO/orbsvcs/orbsvcs. - -If it is not there, from the $ACE_ROOT/TAO/orbsvcs/orbsvcs/ directory, run -make -f Makefile.RTCosScheduling - -To compile the test, just run make in the test directory - - -To run (on Unix): -------- -Run the test as root since this test sets the priorities on -both the client and server. -Make sure that your LD_LIBRARY_PATH and TAO_ROOT are set appropriately: - -# ./run_test.pl - - -Options: --------- -Client: --B int # amount of work performed before the CORBA call is made --R int # amount of work performed on server during the CORBA call --A int # amount of work performed after the CORBA call --N char* # name of the node --X 0|1 # Flag to use realtime (Y=1) --C char* # intermediate client output file - # (used by the run_test validator) --S char* # intermediate server output file - # (used by the run_test validator) --F char* # name of the configuration file that their - # activities/priorities/resources are stored in --T char* # name of the activity that the client will run - -Server: --N char* # The name of the node --F char* # The name of the configuration file --A char* # the name of the server resource --X 1|0 # Flag to use realtime (Y=1) - -Tests ---------- - -Functionality Tests -------------------- -Test1 ensures that the scheduling service works as expected. -Three clients are started with the following parameters: - -Client priority release time remote execution time -Client1 Low 0 10 -Client2 Medium 0 3 -Client3 High 2 3 - -Where release time is the amount of work done on the local client before -the remote method call is made. Each remote method call is made on the -same server object, so the ServerScheduler must schedule execution of -each of these three clients so that they use the remote object in the -appropriate order. - -Note that the scheduling service is only tested when both the client and -the server are using the 1.0 scheduler. (Test1) -In the functionality tests the clients start up at the same time. Client1 -immediately makes a remote method call to the server. Clients 2 and 3 -make method calls to the server object that arrive while the client 1 -method call is still executing on the server. MPCP guarantees that -client1's priority is elevated so that it is allowed to finish, so clients -2 and 3 are placed in a pending queue to await execution. Once client -1 finishes, the activity in queue with the highest client propagated -priority (client3) runs. When it is finished, client 2 runs. - -When Client1 execution returns from the method call it is blocked in this -test because it runs at a lower priority than the server execution of -clients 2 and 3 (this is because this test is designed to run on a single -node!). - -When clients 2 and 3 return from the method call, client 3 finishes execution -because it has the highest priority, then client2 finishes, finally client 1. - -If the scheduling service test failed an error message will appear describing -the point of failure. Please note that some artificial changes to the client -and server object code since this test is designed to run on one node. -Specifically, there is an ACE_OS::sleep(2) in object1_i::method1() that -executes only when client1 makes the method call. This is because the client1 -method call is running at an elevated MPCP priority, and needs to sleep long -enough for clients 2 and 3 to execute on the client and make method calls on -object1. If it did not sleep, the method1() method call would execute to -completion due the singe node nature of this test. (It is running at an -elevated priority on the same processor as the clients 2 and 3). - -There is also a sleep method in the client code that sleeps for 1 as soon as -each client starts up. This occurs before schedule activity is called, and is -in place to allow each client to start up in the event that the default -priority for new processes is higher than the the priorities set in the config -file. If the default priority was higher and the clients did not sleep, each -would not let the successive one start at the appropriate time. - -Please note that in designing a test that since this runs on a single node, there -is no noticeable network delay. There will be a greater network delay on a truly -distributed system. If the test does not run correctly on you machine, try -changing the sleep delays to allow all processes to start. If they all start, -the test should work. - - -Tests 2,3,4 do not execute with both ClientScheduler and a ServerScheduler -so there is no way to validate that execution is appropriate. In test 2, -visual inspection of the output shows that tasks are not scheduled on the client -appropriately. Test 3 does not use server side scheduling, so server execution -runs at RTCORBA::minPriority. Note that the server prints a debug message to inform -the user that it did not use RT MPCP scheduling. - - -Exception Tests ---------------- -Tests 5,6,7,8 ensure that the 1.0 scheduling service handles exceptions -and other errors. -These test determine that the proper exceptions are thrown when the -scheduling service receives improper parameters from either the Client -or the server. - - - -Expected Output ---------------- - -==== Running RTCORBA 1.0 Scheduling Service test -==== Note that the first column is the time, it will be different for you - -TIME OBJECT LOCATION ACTIVITY - -==== Test1 - YES client side scheduling, YES server side scheduling - 13:32:35.775474 Client1 Beginning activity at priority 334 - 13:32:35.775767 Client1 Calling method1 at priority 334 - 13:32:35.785983 Client1 Beginning work on the server - 13:32:36.781443 Client2 Beginning activity at priority 5349 - 13:32:36.781736 Client2 Calling method1 at priority 5349 - 13:32:37.052432 Client3 Beginning activity at priority 10699 - 13:32:37.319242 Client3 Calling method1 at priority 10699 - 13:32:42.120180 Client1 Finished work on the server - 13:32:42.120688 Client3 Beginning work on the server - 13:32:42.520590 Client3 Finished work on the server - 13:32:42.520708 Client2 Beginning work on the server - 13:32:42.920614 Client2 Finished work on the server - 13:32:42.921104 Client3 Done with method1 at priority 10699 - 13:32:43.321033 Client3 Done with test at priority 10699 - 13:32:43.323357 Client2 Done with method1 at priority 5349 - 13:32:43.723272 Client2 Done with test at priority 5349 - 13:32:43.725464 Client1 Done with method1 at priority 334 - 13:32:44.125410 Client1 Done with test at priority 334 -The scheduling service worked as expected - -==== Test2 - NO client side scheduling, YES server side scheduling - 13:32:47.306196 Client1 Client Beginning Activity - 13:32:47.306383 Client1 Client Calling method1 - 13:32:47.313107 Client1 Beginning work on the server - 13:32:48.306283 Client2 Client Beginning Activity - 13:32:48.306468 Client2 Client Calling method1 - 13:32:48.313031 Client3 Client Beginning Activity - 13:32:48.314012 Client2 Beginning work on the server - 13:32:48.951789 Client3 Client Calling method1 - 13:32:48.958000 Client3 Beginning work on the server - 13:32:49.331351 Client2 Finished work on the server - 13:32:49.331830 Client2 Client Done with method1 - 13:32:49.786784 Client3 Finished work on the server - 13:32:49.787294 Client3 Client Done with method1 - 13:32:53.647493 Client1 Finished work on the server - 13:32:53.648023 Client1 Client Done with method1 - -==== Test3 - YES client side scheduling, NO server side scheduling - 13:32:59.233825 Client1 Beginning activity at priority 334 - 13:32:59.234116 Client1 Calling method1 at priority 334 -Object not found in config file, RT ServerScheduler not used! - 13:32:59.271519 Client1 Beginning work on the server - 13:33:00.240454 Client2 Beginning activity at priority 5349 - 13:33:00.240748 Client2 Calling method1 at priority 5349 - 13:33:00.511453 Client3 Beginning activity at priority 10699 - 13:33:00.778302 Client3 Calling method1 at priority 10699 -Object not found in config file, RT ServerScheduler not used! - 13:33:00.785727 Client2 Beginning work on the server -Object not found in config file, RT ServerScheduler not used! - 13:33:00.788335 Client3 Beginning work on the server - 13:33:01.188213 Client3 Finished work on the server - 13:33:01.188896 Client3 Done with method1 at priority 10699 - 13:33:01.588847 Client3 Done with test at priority 10699 - 13:33:01.988080 Client2 Finished work on the server - 13:33:01.988614 Client2 Done with method1 at priority 5349 - 13:33:02.388587 Client2 Done with test at priority 5349 - 13:33:05.606466 Client1 Finished work on the server - 13:33:05.606997 Client1 Done with method1 at priority 334 - 13:33:06.006881 Client1 Done with test at priority 334 - -==== Test4 - NO client side scheduling, NO server side scheduling - 13:33:09.188034 Client1 Client Beginning Activity - 13:33:09.188223 Client1 Client Calling method1 - 13:33:09.195621 Client1 Beginning work on the server - 13:33:10.189090 Client2 Client Beginning Activity - 13:33:10.189276 Client2 Client Calling method1 - 13:33:10.192857 Client3 Client Beginning Activity - 13:33:10.459655 Client3 Client Calling method1 - 13:33:10.465746 Client2 Beginning work on the server - 13:33:10.865946 Client2 Finished work on the server - 13:33:10.866442 Client2 Client Done with method1 - 13:33:11.268218 Client3 Beginning work on the server - 13:33:11.668138 Client3 Finished work on the server - 13:33:11.668611 Client3 Client Done with method1 - 13:33:15.530260 Client1 Finished work on the server - 13:33:15.530785 Client1 Client Done with method1 - -==== Testing exceptions - -==== Test5 - Testing ClientScheduler exception for invalid activity name -Should receive an RTCosScheduling::UnknownName exception -(13374|16386) EXCEPTION, Invalid activity name - -user exception, ID 'IDL:RTCosScheduling/UnknownName:1.0' - -==== Test6 - Testing client exception when invalid config file specified -Program should abort because no valid file was given -Could not find the config file INVALID_FILE.cfg, aborting -Invalid Filename given, aborting! - -==== Test7 - Testing server exception when invalid Object Name specified -==== (Object name not in config file) -Should receive an RTCosScheduling::UnknownName exception -(13378|16384) EXCEPTION, Unknown object passed to schedule_object - -user exception, ID 'IDL:RTCosScheduling/UnknownName:1.0' - -==== Test8 - Testing server exception when invalid config file specified -Server Should abort because an invalid config filename was given -Could not find the config file INVALID_FILE.cfg, aborting -ERROR: server returned 1 diff --git a/TAO/orbsvcs/tests/RTCosScheduling/RTCosScheduling.mpc b/TAO/orbsvcs/tests/RTCosScheduling/RTCosScheduling.mpc deleted file mode 100644 index 08b932cb774..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/RTCosScheduling.mpc +++ /dev/null @@ -1,48 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(RTCosScheduling_Server): rtcosscheduling, rt_server, orbsvcsexe, interceptors { - after += commonlib - libs += testSched_Common - libpaths += . - exename = server - - Source_Files { - Object1_i.cpp - server.cpp - } - IDL_Files { - } -} - -project(RTCosScheduling_Client): rtcosscheduling, rt_client, orbsvcsexe { - after += commonlib - after += RTCosScheduling_Server - libs += testSched_Common - libpaths += . - exename = client - - Source_Files { - client.cpp - } - IDL_Files { - } -} - -project(commonlib): rtcosscheduling, orbsvcslib { - requires += interceptors - sharedname = testSched_Common - idlflags += -Wb,export_macro=testSched_Export \ - -Wb,export_include=testSched_export.h - - dynamicflags += TESTSCHED_BUILD_DLL - tagchecks += testSched_Common - - IDL_Files { - testSched.idl - } - Source_Files { - testSchedC.cpp - testSchedS.cpp - } -} diff --git a/TAO/orbsvcs/tests/RTCosScheduling/client.cpp b/TAO/orbsvcs/tests/RTCosScheduling/client.cpp deleted file mode 100644 index 009a575307e..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/client.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file client.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - - -#include "testSchedC.h" -#include <orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h> -#include "ace/Get_Opt.h" -#include "tao/debug.h" -#include "tao/Version.h" -#include "ace/OS_main.h" -#include "ace/OS_NS_unistd.h" -#include "ace/Task.h" -#include "tao/ORB_Core.h" - - -/// In the test, these are the default values that specify -/// how long (in seconds) the test methods should run before going -/// to the server, while on the server, and after returning from -/// the server -CORBA::Long before_ = 1; -CORBA::Long remote_ = 1; -CORBA::Long after_ = 1; -u_int use_realtime_ = 1; - -/// This is the name of the node that the client executes on. -char *node_ = 0; - -/// the name of the config file holding the scheduling information -char *file_ = 0; - -/// the name of the activity to run (the name of the string passed in -/// schedule_activity(activity_) -char * activity_ = 0; - -/// The name of the output file -char *client_output_file_ = 0; - -CORBA::String_var serv_output_; - -char date_and_time[35]; -char client_output_[2048]; -char buf[100]; - - -/// For the timestampe -const int time_size = 35; -ACE_TCHAR day_and_time[time_size]; - -void do_work(const CORBA::Long value); - -ACE_RCSID( - tests, - client, - "client.cpp,v 1.0 2003/08/07 15:59:21 murphy_m Exp") - -/// Standard parse args method -/* - * parse_args allows the user to configure the test to use values other - * than those specified above. - */ -int -parse_args (int argc, ACE_TCHAR *argv[]) -{ - /// We set the '-' flag for getopts because we have to do this - /// parsing before the ORB does it's parsing, and we'd confuse it to reorder - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("-B:R:A:X:N:C:F:T:?:")); - int c; - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'B': - before_ =ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'R': - remote_ =ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'A': - after_ =ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'X': - use_realtime_ =ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'N': - node_ = ACE_OS::strdup(get_opts.opt_arg ()); - break; - case 'C': - client_output_file_ = ACE_OS::strdup(get_opts.opt_arg ()); - break; - case 'F': - file_ = ACE_OS::strdup(get_opts.opt_arg ()); - break; - case 'T': - activity_ = ACE_OS::strdup(get_opts.opt_arg ()); - break; - case '?': - ACE_DEBUG ((LM_DEBUG, - "usage: %n [-b precall_execution] " - "[-r remote_execution] " - "[-a postcall_workload] " - "[-N node] " - "[-F config_file] " - "[-c activity_name]\n")); - ACE_OS::exit (1); - } - } - if (node_ == 0) - node_ = ACE_OS::strdup("1"); - if (file_ == 0) - file_ = ACE_OS::strdup("schedule.cfg"); - if (activity_ == 0) - activity_ = ACE_OS::strdup(""); - if (client_output_file_ == 0) - client_output_file_ = ACE_OS::strdup(""); - - return 0; -} - -/** - * This class runs the test as a new thread since the main thread - * cannot set RT priorities as of TAO 1.3.3 - * - */ -class ORB_Thread : public ACE_Task<ACE_SYNCH> -{ - -public: -ORB_Thread(CORBA::ORB_var orb, - int argc, - ACE_TCHAR **argv) -: orb_(orb), - argc_(argc), - argv_(argv) -{ -} - -int svc(void) { - try - { - if (parse_args (argc_, argv_) != 0) - { - return 1; - } - - if (ACE_OS::strcmp(activity_,"Client2") == 0 || - ACE_OS::strcmp(activity_,"Client3") == 0) - { - ACE_OS::sleep(1); - } - - CORBA::Object_var obj = - orb_->string_to_object ("file://server.ior" - ); - - - if (CORBA::is_nil (obj.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P) orb_->string_to_object ") - ACE_TEXT ("(\"file://server.ior\") failed.\n")), - -1); - } - - testSched::Object1_var object1 = - testSched::Object1::_narrow (obj.in ()); - - - if (CORBA::is_nil (object1.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - "ERROR: Object reference is nil, Aborting\n"), 1); - } - - - if (use_realtime_) - { - /// Create the ClientScheduler, note that you must pass in the - /// orb and the node name. The node name is required so that the - /// appropriate information can be read from the config file - TAO::RTCosScheduling_ClientScheduler_i *client_sched = 0; - ACE_NEW_THROW_EX(client_sched, - TAO::RTCosScheduling_ClientScheduler_i ( - orb_, - node_, - file_), - CORBA::NO_MEMORY()); - - - // Check to see that the ClientScheduler started correctly - if (CORBA::is_nil (client_sched)) - { - /// There was an error in setting up the RTORB, - /// RT Policies were not set, throw an exception - ACE_OS::exit(1); - } - - - - /// Create a Current object so we can check on the priority locally - obj = orb_->resolve_initial_references ("RTCurrent"); - RTCORBA::Current_var current = - RTCORBA::Current::_narrow (obj.in ()); - - - /// Test to make sure the priority model is exposed - CORBA::Policy_var policy = - object1->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); - - RTCORBA::PriorityModelPolicy_var priority_policy = - RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); - - if (CORBA::is_nil (priority_policy.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - "ERROR: Priority Model not exposed!\n"), - 1); - } - - /// Test to make sure we are using Server Declared Priority model - RTCORBA::PriorityModel priority_model = - priority_policy->priority_model (); - - if (priority_model != RTCORBA::SERVER_DECLARED) - { - ACE_ERROR_RETURN ((LM_ERROR, - "ERROR: priority_model != " - "RTCORBA::SERVER_DECLARED!\n"), - 1); - } - - do_work(before_); - - try - { - client_sched->schedule_activity (::activity_); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Invalid activity name\n"); - return -1; - } - - ACE_OS::sprintf(buf, - "%s\t%s\tBeginning activity at priority %d\n", - ACE::timestamp(date_and_time, time_size), - activity_, - current->the_priority()); - ACE_DEBUG ((LM_DEBUG, - "%s", - buf)); - ACE_OS::strcat(client_output_, buf); - - do_work(before_); - - - ACE_OS::sprintf(buf, - "%s\t%s\tCalling method1 at priority %d\n", - ACE::timestamp(date_and_time, time_size), - activity_, - current->the_priority()); - ACE_DEBUG ((LM_DEBUG, - "%s", - buf)); - ACE_OS::strcat(client_output_, buf); - serv_output_ = ACE_OS::strdup(""); - object1->method1 (activity_, remote_, serv_output_.inout()); - - ACE_OS::strcat(client_output_, serv_output_.in()); - - - ACE_OS::sprintf(buf, - "%s\t%s\tDone with method1 at priority %d\n", - ACE::timestamp(date_and_time, time_size), - activity_, - current->the_priority()); - ACE_DEBUG ((LM_DEBUG, - "%s", - buf)); - ACE_OS::strcat(client_output_, buf); - - - do_work(after_); - - ACE_OS::sprintf(buf, - "%s\t%s\tDone with test at priority %d\n", - ACE::timestamp(date_and_time, time_size), - activity_, - current->the_priority()); - ACE_DEBUG ((LM_DEBUG, - "%s", - buf)); - ACE_OS::strcat(client_output_, buf); - - - } - else - { - ACE_DEBUG ((LM_DEBUG, - "%T\t%s\tClient\tBeginning Activity\n", - activity_)); - do_work(before_); - ACE_DEBUG ((LM_DEBUG, - "%T\t%s\tClient\tCalling method1\n", - activity_)); - - object1->method1 (activity_, remote_, serv_output_.inout()); - ACE_OS::strcat(client_output_,serv_output_.in()); - /// Finished with remote call - ACE_DEBUG ((LM_DEBUG, - "%T\t%s\tClient\tDone with method1\n", - activity_)); - do_work(after_); - } - - FILE *fp = ACE_OS::fopen(client_output_file_, "w"); - if (fp) - { - ACE_OS::fprintf(fp, - "%s", - client_output_); - } - else - { - ACE_DEBUG((LM_DEBUG,"No file to write to\n")); - } - ACE_OS::fclose(fp); - - - // Finally destroy the ORB - orb_->destroy (); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Exception in running the client\n"); - return -1; - } - return 0; - } - - -private: - CORBA::ORB_var orb_; - CORBA::ORB_var orb2_; - int argc_; char ** argv_; -}; - - - -int -ACE_TMAIN(int argc, ACE_TCHAR *argv[]) -{ - try - { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, "client_orb"); - - ORB_Thread ot(orb, argc, argv); - - // Need to set the main thread pthread scope and pthread policy to - // the values that are specified in svc.conf. This change was - // recommended by irfan@oomworks.com - long flags = THR_NEW_LWP | THR_JOINABLE | - - orb->orb_core ()->orb_params ()->thread_creation_flags (); - - ot.activate(flags); - return ot.wait(); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("ERROR in running the client\n"); - } - return 0; -} - -void -do_work(const CORBA::Long value) -{ - const int scale_factor = 2000; - int work; - - /// Simulate some work - static CORBA::ULong prime_number = 9619; - - work = scale_factor * value; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "test_i::method: %hd units of work\n", work)); - for (; work != 0; work--) - ACE::is_prime (prime_number, 2, prime_number / 2); - -} diff --git a/TAO/orbsvcs/tests/RTCosScheduling/run_test.pl b/TAO/orbsvcs/tests/RTCosScheduling/run_test.pl deleted file mode 100755 index 7e0de229071..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/run_test.pl +++ /dev/null @@ -1,301 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# -*- perl -*- -# $Id$ - -use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::TestTarget; - -$status = 0; -$debug_level = '0'; - -foreach $i (@ARGV) { - if ($i eq '-debug') { - $debug_level = '10'; - } -} - -my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; -my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; -my $client1 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n"; -my $client2 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n"; -my $client3 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n"; - -my $srv_ior = "server.ior"; -my $schedule_cfg = "schedule.cfg"; -my $invalid_cfg = "INVALID_FILE.cfg"; - -my $server_schedule_cfg = $server->LocalFile ($schedule_cfg); -my $server_invalid_cfg = $server->LocalFile ($invalid_cfg); -my $server_srv_ior = $server->LocalFile ($srv_ior); -$server->DeleteFile ($srv_ior); - -my $client_schedule_cfg = $client->LocalFile ($schedule_cfg); -my $client_invalid_cfg = $client->LocalFile ($invalid_cfg); - -my $client1_schedule_cfg = $client1->LocalFile ($schedule_cfg); -my $client2_schedule_cfg = $client2->LocalFile ($schedule_cfg); -my $client3_schedule_cfg = $client3->LocalFile ($schedule_cfg); - -my $client1_output = $client1->LocalFile ("client1_output"); -my $client2_output = $client2->LocalFile ("client2_output"); -my $client3_output = $client3->LocalFile ("client3_output"); -$client1->DeleteFile ($client1_output); -$client2->DeleteFile ($client2_output); -$client3->DeleteFile ($client3_output); - -#S11 uses schedule object, S10 does not -$S11 = $server->CreateProcess ("server", "-N 2 -F $server_schedule_cfg -A Server2 -X 1"); -$S10 = $server->CreateProcess ("server", "-N 2 -F $server_schedule_cfg -A Server2 -X 0"); -#S2 uses and invalid config file -$S2 = $server->CreateProcess ("server", "-N 2 -F $server_invalid_cfg -A Server2 -X 1"); -#s3 tries to schedule an invalid object -$S3 = $server->CreateProcess ("server", "-N 2 -F $server_schedule_cfg -A Server5 -X 1"); - -# C11 C21 C31 use RTCosScheduler 1.0 on the client -$C11 = $client1->CreateProcess ("client", "-B 0 -R 10 -A 3 -N 1 -C $client1_output ". - "-F $client1_schedule_cfg -T Client1 -X 1"); -$C21 = $client2->CreateProcess ("client", "-B 0 -R 3 -A 3 -N 1 -C $client2_output ". - "-F $client2_schedule_cfg -T Client2 -X 1"); -$C31 = $client3->CreateProcess ("client", "-B 2 -R 3 -A 3 -N 1 -C $client3_output ". - "-F $client3_schedule_cfg -T Client3 -X 1"); - -#C10 C20 C30 Do not use RTCosScheduler 1.0 on the client -$C10 = $client1->CreateProcess ("client", "-B 0 -R 10 -A 3 -N 1 -C $client1_output ". - "-F $client1_schedule_cfg -T Client1 -X 0"); -$C20 = $client2->CreateProcess ("client", "-B 0 -R 3 -A 3 -N 1 -C $client2_output ". - "-F $client2_schedule_cfg -T Client2 -X 0"); -$C30 = $client3->CreateProcess ("client", "-B 2 -R 3 -A 3 -N 1 -C $client3_output ". - "-F $client3_schedule_cfg -T Client3 -X 0"); - -#C4 is an invalid activity name -$C4 = $client->CreateProcess ("client","-B 1 -R 3 -A 0 -N 1 -F $client_schedule_cfg -T Client4 -X 1"); -#C5 is an invalid config file -$C5 = $client->CreateProcess ("client", "-B 1 -R 3 -A 0 -N 1 -F $client_invalid_cfg -T Client2 -X 1"); - -sub spawn_server { - local ( $param_1 ) = @_; - $result = $param_1->Spawn (); - if ($result != 0) { - print STDERR "ERROR: server Spawn retured $result\n"; - exit 1; - } - - if ($server->WaitForFileTimed ($srv_ior, $server->ProcesStartWaitInterval() ) == -1) { - print STDERR "ERROR: cannot find file <$server_srv_ior>\n"; - $param_1->Kill (); - exit 1; - } -} - -sub kill_server { - local ( $param_1 ) = @_; - $result = $param_1->TerminateWaitKill ($server->ProcessStopWaitInterval()); - if ($result != 0) { - print STDERR "ERROR: server returned $result\n"; - $status = 1; - } - $server->DeleteFile ($srv_ior); -} - -sub run_client { - local ( $param_1 ) = @_; - $result = $param_1->Spawn(); - if ($result != 0) { - print STDERR "ERROR: client returned $result\n"; - $status = 1; - } -} - -sub test { - local($param_0, $param_1, $param_2, $param_3) = @_; - print STDERR $param_0; - - $result = $param_1->Spawn(); - - if ($result != 0) { - print STDERR "ERROR: client returned $result\n"; - $status = 1; - } - - $result = $param_1->Spawn(); - - if ($result != 0) { - print STDERR "ERROR: client returned $result\n"; - $status = 1; - } - - $result = $param_1->Spawn(); - - if ($result != 0) { - print STDERR "ERROR: client returned $result\n"; - $status = 1; - } - - $param_1->WaitKill ($client1->ProcessStopWaitInterval() + 20); - $param_2->WaitKill ($client2->ProcessStopWaitInterval() + 15); - $param_3->WaitKill ($client3->ProcessStopWaitInterval() + 15); - sleep 2; - - if ($param_0 =~ /Test1/) { - evaluate_output(); - } - $client1->DeleteFile ($client1_output); - $client2->DeleteFile ($client2_output); - $client3->DeleteFile ($client3_output); -} - -sub test5 { - print STDERR "\n==== Testing exceptions\n"; - print STDERR "\n==== Test5 - Testing ClientScheduler ". - "exception for invalid activity name\n". - "Should recieve an RTCosScheduling::UnknownName exeption\n"; - run_client($C4); - $C4->WaitKill($client->ProcessStopWaitInterval()); -} - -sub test6 { - print STDERR "\n==== Test6 - Testing client exception ". - "when invalid config file specified\n". - "Program should abort because no valid file was given\n"; - run_client($C5); - $C5->WaitKill ($client->ProcessStopWaitInterval()); -} - -sub test7 { - print STDERR "\n==== Test7 - Testing server exception ". - "when invalid Object Name specified\n"; - print STDERR "==== (Object name not in config file)\n". - "Should receive an RTCosScheduling::UnknownName exception\n"; - $S3->Spawn(); - sleep 1; - kill_server($S3); -} - -sub test8 { - print STDERR "\n==== Test8 - Testing server exception ". - "when invalid config file specified\n". - "Server Should abort because an invalid config ". - "filename was given\n"; - $S2->Spawn(); - sleep 1; - kill_server($S2); -} - -sub evaluate_output { - # this looks at the three output files to see if the - # clients ran in the correct order - open(INFOC1, $client1_output); - open(INFOC2, $client2_output); - open(INFOC3, $client3_output); - - @arrayC1=<INFOC1>; - close (INFOC1); - @arrayC2=<INFOC2>; - close (INFOC2); - @arrayC3=<INFOC3>; - close (INFOC3); - - $is_valid = 1; - - # check the client execution to make sure - #it runs in the correct order - ($BAtimeC1,$client,$activity)=split(/\t/,$arrayC1[0]); - ($BAtimeC2,$client,$activity)=split(/\t/,$arrayC2[0]); - ($BAtimeC3,$client,$activity)=split(/\t/,$arrayC3[0]); - - ($CMtimeC1,$client,$activity)=split(/\t/,$arrayC1[1]); - ($CMtimeC2,$client,$activity)=split(/\t/,$arrayC2[1]); - ($CMtimeC3,$client,$activity)=split(/\t/,$arrayC3[1]); - - ($BRtimeC1,$client,$activity)=split(/\t/,$arrayC1[2]); - ($BRtimeC2,$client,$activity)=split(/\t/,$arrayC2[2]); - ($BRtimeC3,$client,$activity)=split(/\t/,$arrayC3[2]); - - ($FRtimeC1,$client,$activity)=split(/\t/,$arrayC1[3]); - ($FRtimeC2,$client,$activity)=split(/\t/,$arrayC2[3]); - ($FRtimeC3,$client,$activity)=split(/\t/,$arrayC3[3]); - - ($DMtimeC1,$client,$activity)=split(/\t/,$arrayC1[4]); - ($DMtimeC2,$client,$activity)=split(/\t/,$arrayC2[4]); - ($DMtimeC3,$client,$activity)=split(/\t/,$arrayC3[4]); - - ($DTtimeC1,$client,$activity)=split(/\t/,$arrayC1[5]); - ($DTtimeC2,$client,$activity)=split(/\t/,$arrayC2[5]); - ($DTtimeC3,$client,$activity)=split(/\t/,$arrayC3[5]); - - if ($BAtimeC1 gt $BAtimeC2 || $BAtimeC1 gt $BAtimeC3) { - print STDERR "Scheduler Test Failed - activities did not begin in correct order\n"; - $is_valid = 0; - } - if ($CMtimeC1 gt $CMtimeC2 || $CMtimeC1 gt $CMtimeC3) { - print STDERR "Scheduler Test Failed - remote method calls not ". - "made in correct order\n"; - $is_valid = 0; - } - if ($FRtimeC1 gt $FRtimeC3 || $FRtimeC3 gt $FRtimeC2) { - print STDERR "Scheduler Test Failed - Remote Method calls did ". - "not finish in correct order\n"; - $is_valid = 0; - } - if ($DTtimeC3 gt $DTtimeC2 || $DTtimeC2 gt $DTtimeC1) { - print STDERR "Scheduler Test Failed - Tests did not finish in ". - "correct order\n"; - $is_valid = 0; - } - if ($BRtimeC1 gt $BAtimeC2) { - print STDERR "Scheduler Test Failed - Client1 remote method call ". - "finished before Client2 began local activity\n"; - $is_valid = 0; - } - if ($FRtimeC1 gt $BRtimeC3 || $FRtimeC1 gt $BRtimeC2) { - print STDERR "Scheduler Test Failed - Client1 finished before ". - "Clients2 or 3 made method calls\n"; - $is_valid = 0; - } - if ($BRtimeC3 gt $BRtimeC2 || $FRtimeC3 gt $FRtimeC2) { - print STDERR "Scheduler Test Failed - Client 3 remote method call ". - "did not begin before Client2\n"; - $is_valid = 0; - } - - #next one condition disables WARNING only. No functionality, no logic. - if ($DMtimeC1 || $DMtimeC2 || $DMtimeC3) { - } - - if ($is_valid == 1) { - print STDERR "The scheduling service worked as expected\n"; - } - else { - print STDERR "The scheduling service did not work as expected\n"; - } - -} - -print STDERR "\n==== Running RTCORBA 1.0 Scheduling Service test\n"; -print STDERR "==== Note that the first column is the time, it will be different for you\n\n"; -print STDERR "TIME\t\t\tOBJECT\tLOCATION\tACTIVITY\n"; - -spawn_server($S11); -test("\n==== Test1 - YES client side scheduling, YES server side scheduling\n", $C11, $C21, $C31); -test("\n==== Test2 - NO client side scheduling, YES server side scheduling\n", $C10, $C20, $C30); -kill_server($S11); - -spawn_server($S10); -test("\n==== Test3 - YES client side scheduling, NO server side scheduling\n", $C11, $C21, $C31); -test("\n==== Test4 - NO client side scheduling, NO server side scheduling\n", $C10, $C20, $C30); -kill_server ($S10); - -spawn_server ($S11); - -test5 (); -test6 (); - -kill_server ($S11); - -test7 (); -test8 (); - -exit $status; diff --git a/TAO/orbsvcs/tests/RTCosScheduling/schedule.cfg b/TAO/orbsvcs/tests/RTCosScheduling/schedule.cfg deleted file mode 100644 index 0f74742bcc0..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/schedule.cfg +++ /dev/null @@ -1,24 +0,0 @@ -Node 1 - -Resources: -BP 11000 -Server2 6000 -END - -Tasks: -Client1 500 -Client2 5500 -Client3 11000 -END - -Node 2 - -Resources: -BP 17000 -Server2 11000 -Server3 500 -END - -Tasks: -Client4 500 -Client5 10000 diff --git a/TAO/orbsvcs/tests/RTCosScheduling/server.cpp b/TAO/orbsvcs/tests/RTCosScheduling/server.cpp deleted file mode 100644 index b69c973ccd1..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/server.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file server.cpp - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -#include "Object1_i.h" -#include <orbsvcs/RTCosScheduling/RTCosScheduling_ServerScheduler_i.h> - -#include "tao/Version.h" - -// FUZZ: disable check_for_streams_include -#include "ace/streams.h" -#include "ace/Task.h" -#include "ace/Get_Opt.h" -#include "tao/ORB_Core.h" -#include "ace/OS_main.h" -#include "ace/OS_NS_stdio.h" - -const ACE_TCHAR *ior_output_file = ACE_TEXT("server.ior"); -char *node_ = 0; -char *file_ = 0; -char *shared_file_ = 0; -char *object_ = 0; -int num_threads_ = 5; -int use_realtime_ = 1; - -// ORB Thread - -class ORB_Thread : public ACE_Task<ACE_SYNCH> -{ -public: - -ORB_Thread(CORBA::ORB_var orb) : orb_(orb) -{ -} - -int -svc(void) -{ - - try - { - orb_->run(); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("svc"); - return 1; - } - - ACE_OS::exit(0); - return 0; -} - - -private: - CORBA::ORB_var orb_; -}; - - -int -parse_args (int argc, ACE_TCHAR *argv[]) -{ - // We set the '-' flag for getopts because we have to do - // this parsing before the ORB does it's - //parsing, and we'd confuse it to reorder - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("-:N:F:S:T:A:X:")); - int c; - - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'N': - node_ = get_opts.opt_arg (); - break; - case 'F': - file_ = get_opts.opt_arg (); - break; - case 'S': - shared_file_ = get_opts.opt_arg (); - break; - case 'T': - num_threads_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'A': - object_ = ACE_OS::strdup(get_opts.opt_arg ()); - break; - case 'X': - use_realtime_ = ACE_OS::atoi(get_opts.opt_arg ()); - break; - - } - } - if (node_ == 0) - node_ = ACE_OS::strdup("1"); - if (file_ == 0) - file_ = ACE_OS::strdup("schedule.cfg"); - if (shared_file_ == 0) - shared_file_ = ACE_OS::strdup("Scheduling_Service_Shared_Memory"); - if (object_ == 0) - object_ = ACE_OS::strdup("Server2"); - - return 0; -} - - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { - try - { - if (parse_args (argc, argv) != 0) - { - return 1; - } - - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "testORB"); - - /// get the root poa - CORBA::Object_var object= orb->resolve_initial_references ("RootPOA"); - - PortableServer::POA_var rootPOA = - PortableServer::POA::_narrow (object.in ()); - - /// Create a manager for the POA - PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager (); - - CORBA::PolicyList poa_policy_list; - poa_policy_list.length (1); - - poa_policy_list[0] = - rootPOA->create_lifespan_policy(PortableServer::TRANSIENT); - - // Create the RT Scheduling service - TAO::RTCosScheduling_ServerScheduler_i *server_sched = 0; - ACE_NEW_THROW_EX(server_sched, - TAO::RTCosScheduling_ServerScheduler_i( - node_, - file_, - shared_file_, - num_threads_ ), - CORBA::NO_MEMORY()); - - /// Create the POA so RT Policies are set - PortableServer::POA_var RTPOA = - server_sched->create_POA(rootPOA.in(), - "my_RT_POA", - poa_manager.in(), - poa_policy_list); - - - Object1_impl * servant = 0; - ACE_NEW_THROW_EX(servant, - Object1_impl(), - CORBA::NO_MEMORY()); - - PortableServer::ObjectId_var id = - RTPOA->activate_object(servant); - - CORBA::Object_var testObject = - RTPOA->id_to_reference(id.in()); - - CORBA::String_var testObject_IORString = - orb->object_to_string (testObject.in ()); - - // If the ior_output_file exists, output the ior to it - 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", testObject_IORString.in ()); - ACE_OS::fclose (output_file); - - if (use_realtime_) - { - /// Schedule the object - try - { - server_sched->schedule_object(testObject.inout(), - object_); - } - catch (const RTCosScheduling::UnknownName& ex) - { - ex._tao_print_exception ( - "Unknown object passed to schedule_object\n"); - } - } - - // Activate the manager and run the event loop - poa_manager->activate (); - - // Need to set the main thread pthread scope and pthread policy to - // the values that are specified in svc.conf. This change was - // recommended by irfan@oomworks.com - long flags = THR_NEW_LWP | THR_JOINABLE | - - orb->orb_core ()->orb_params ()->thread_creation_flags (); - - ORB_Thread ot(orb); - ot.activate(flags); - ot.wait(); - - ACE_DEBUG((LM_DEBUG, - "Server is shutting down\n\n")); - - delete server_sched; - - /// clean up - rootPOA->destroy (1, 1); - orb->destroy (); - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("Exception caught:"); - return -1; - } - - return 0; -} diff --git a/TAO/orbsvcs/tests/RTCosScheduling/server.ior b/TAO/orbsvcs/tests/RTCosScheduling/server.ior deleted file mode 100644 index 3a8697919ef..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/server.ior +++ /dev/null @@ -1 +0,0 @@ -IOR:010000001a00000049444c3a7465737453636865642f4f626a656374313a312e300000000300000000000000d600000001010200110000007274646f632e63732e7572692e656475000039912300000014010f004e5354ff2b873ff9e6060001000000010000000000000001000000010000000004000000000000000800000001000000004f415401000000140000000100000001000100000000000901010000000000024f4154220000000100000001000000110000007274646f632e63732e7572692e65647500003991ffff0000020000002e000000018c134202000000280000000a000000018e134201000000ff7fffff280000000a000000018e134201000000ff7f000000000000ce000000010102000d0000003137322e31362e3134392e31006539912300000014010f004e5354ff2b873ff9e6060001000000010000000000000001000000010000000104000000000000000800000001000000004f415401000000140000000100000001000100000000000901010000000000024f41541e000000018c1342010000000d0000003137322e31362e3134392e3100653991ffff6475020000002e000000018e134202000000280000000a000000018e134201000000ff7f0000280000000a000000018e134201000000ff7f000000000000ca000000010102000c0000003139322e3136382e302e3100399139912300000014010f004e5354ff2b873ff9e6060001000000010000000000000001000000010000000104000000000000000800000001000000004f415401000000140000000100000001000100000000000901010000000000024f41541c000000018e1342010000000c0000003139322e3136382e302e31003991ffff020000002e000000018c134202000000280000000a000000018c134201000000ff7f0000280000000a000000018c134201000000ff7f diff --git a/TAO/orbsvcs/tests/RTCosScheduling/svc.conf b/TAO/orbsvcs/tests/RTCosScheduling/svc.conf deleted file mode 100644 index 84f0293b2b9..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/svc.conf +++ /dev/null @@ -1,2 +0,0 @@ -#static RT_ORB_Loader "-ORBSchedPolicy SCHED_RR -ORBPriorityMapping linear -ORBScopePolicy SYSTEM" -static RT_ORB_Loader "-ORBSchedPolicy SCHED_FIFO -ORBPriorityMapping linear -ORBScopePolicy SYSTEM" diff --git a/TAO/orbsvcs/tests/RTCosScheduling/testSched.idl b/TAO/orbsvcs/tests/RTCosScheduling/testSched.idl deleted file mode 100644 index c2d98c7cf88..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/testSched.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- C++ -*- */ - -//============================================================================= -/** - * @file testSched.idl - * - * $Id$ - * - * @author Matt Murphy <murphym@cs.uri.edu> - */ -//============================================================================= - -/** - * @class Object1 - * - * @brief Used by the RTCORBA 1.0 scheduling service. - */ - -#ifndef TEST_SCHED -#define TEST_SCHED - -/** - * Object1 class is used in the RTCORBA 1.0 Scheduling - * Service test. - */ -module testSched { - - exception testSchedException {}; - - interface Object1 { - /** - * method1 executes work at the location specified by the object reference. - * It sleeps for the number of seconds specified. - * - * @param seconds The number of seconds to sleep for. - */ - void method1(in string activity, in long second, inout string output_file) - raises (testSchedException); - }; - -}; - -#endif /* TEST_SCHED */ diff --git a/TAO/orbsvcs/tests/RTCosScheduling/testSched_export.h b/TAO/orbsvcs/tests/RTCosScheduling/testSched_export.h deleted file mode 100644 index d931b25070d..00000000000 --- a/TAO/orbsvcs/tests/RTCosScheduling/testSched_export.h +++ /dev/null @@ -1,60 +0,0 @@ - -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl testSched -// ------------------------------ -#ifndef TESTSCHED_EXPORT_H -#define TESTSCHED_EXPORT_H - -#include "ace/config-all.h" - -#if defined (TAO_AS_STATIC_LIBS) -# if !defined (TESTSCHED_HAS_DLL) -# define TESTSCHED_HAS_DLL 0 -# endif /* ! TESTSCHED_HAS_DLL */ -#else -# if !defined (TESTSCHED_HAS_DLL) -# define TESTSCHED_HAS_DLL 1 -# endif /* ! TESTSCHED_HAS_DLL */ -#endif - -#if defined (TESTSCHED_HAS_DLL) && (TESTSCHED_HAS_DLL == 1) -# if defined (TESTSCHED_BUILD_DLL) -# define testSched_Export ACE_Proper_Export_Flag -# define TESTSCHED_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define TESTSCHED_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* TESTSCHED_BUILD_DLL */ -# define testSched_Export ACE_Proper_Import_Flag -# define TESTSCHED_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define TESTSCHED_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* TESTSCHED_BUILD_DLL */ -#else /* TESTSCHED_HAS_DLL == 1 */ -# define testSched_Export -# define TESTSCHED_SINGLETON_DECLARATION(T) -# define TESTSCHED_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* TESTSCHED_HAS_DLL == 1 */ - -// Set TESTSCHED_NTRACE = 0 to turn on library specific tracing even if -// tracing is turned off for ACE. -#if !defined (TESTSCHED_NTRACE) -# if (ACE_NTRACE == 1) -# define TESTSCHED_NTRACE 1 -# else /* (ACE_NTRACE == 1) */ -# define TESTSCHED_NTRACE 0 -# endif /* (ACE_NTRACE == 1) */ -#endif /* !TESTSCHED_NTRACE */ - -#if (TESTSCHED_NTRACE == 1) -# define TESTSCHED_TRACE(X) -#else /* (TESTSCHED_NTRACE == 1) */ -# if !defined (ACE_HAS_TRACE) -# define ACE_HAS_TRACE -# endif /* ACE_HAS_TRACE */ -# define TESTSCHED_TRACE(X) ACE_TRACE_IMPL(X) -# include "ace/Trace.h" -#endif /* (TESTSCHED_NTRACE == 1) */ - -#endif /* TESTSCHED_EXPORT_H */ - -// End of auto generated file. |