diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-08 02:32:17 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-08 02:32:17 +0000 |
commit | 960f7a384b01ad9029483986d2bc1992e9a419b8 (patch) | |
tree | 48a2cea18d8c060dc924c8b8da22a75954e7b478 | |
parent | 2e4fc85e9c9912c20e43c4f1fb6229dd6ed28500 (diff) | |
download | ATCD-960f7a384b01ad9029483986d2bc1992e9a419b8.tar.gz |
bug fixes from testing the reconfig scheduler alongside the config scheduler.
-rw-r--r-- | TAO/ChangeLog-99c | 14 | ||||
-rw-r--r-- | TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/DynSched.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp | 6 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.cpp | 141 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.h | 16 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.cpp | 155 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.h | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Sched_Conf/Sched_Conf.cpp | 33 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp | 82 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp | 12 |
11 files changed, 322 insertions, 152 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index aff2fcc86f1..306f4e69012 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,17 @@ +Wed Jul 07 21:28:00 1999 Chris Gill <cdgill@cs.wustl.edu> + + * orbsvcs/Scheduling_Service/Scheduling_Service.cpp + orbsvcs/orbsvcs/Sched/DynSched.cpp + orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp + orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.{cpp, h} + orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.{cpp, h} + orbsvcs/tests/Sched_Conf/Sched_Conf.cpp + orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp + orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp: bug fixes from + testing the reconfig scheduler alongside the config scheduler. + Reconfig scheduler now executes with no exceptions and generates + a schedule in the Sched_Conf test. + Wed Jul 7 21:16:24 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * tao/ORB.cpp (multicast_to_service): Revised the code to use diff --git a/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp b/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp index 8d90d8796a8..4d45539f9a7 100644 --- a/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp +++ b/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp @@ -98,7 +98,7 @@ TAO_Scheduling_Service::init (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, - "TAO_Naming_Service::init: " + "TAO_Scheduling_Service::init: " "unrecognized Scheduler_Type"), -1); } @@ -157,7 +157,7 @@ TAO_Scheduling_Service::init (int argc, char *argv[]) } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_Naming_Service::init"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_Scheduling_Service::init"); return -1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/orbsvcs/Sched/DynSched.cpp b/TAO/orbsvcs/orbsvcs/Sched/DynSched.cpp index 09f187cf7dc..fd4b3f584a8 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/DynSched.cpp +++ b/TAO/orbsvcs/orbsvcs/Sched/DynSched.cpp @@ -329,7 +329,7 @@ ACE_DynScheduler::get_rt_info (Object_Name name, { rtinfo = new RT_Info; rtinfo->info_type = RtecScheduler::OPERATION; - rtinfo->entry_point = name; + rtinfo->entry_point = CORBA::string_dup(name); // Bind the rtinfo to the name. if (info_collection_.bind (lookup, rtinfo) != 0) { diff --git a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp index b8c78b8890d..9d37c52e122 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp +++ b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils.cpp @@ -79,8 +79,7 @@ TAO_Reconfig_Scheduler_Entry::orig_rt_info_data () void TAO_Reconfig_Scheduler_Entry::orig_rt_info_data (RtecScheduler::RT_Info &data) { - this->orig_rt_info_data_.entry_point = data.entry_point; - this->orig_rt_info_data_.handle = data.handle; + // Only store the information that can be updated by the public interface at run-time. this->orig_rt_info_data_.worst_case_execution_time = data.worst_case_execution_time; this->orig_rt_info_data_.typical_execution_time = data.typical_execution_time; this->orig_rt_info_data_.cached_execution_time = data.cached_execution_time; @@ -89,9 +88,6 @@ TAO_Reconfig_Scheduler_Entry::orig_rt_info_data (RtecScheduler::RT_Info &data) this->orig_rt_info_data_.importance = data.importance; this->orig_rt_info_data_.quantum = data.quantum; this->orig_rt_info_data_.threads = data.threads; - this->orig_rt_info_data_.priority = data.priority; - this->orig_rt_info_data_.preemption_subpriority = data.preemption_subpriority; - this->orig_rt_info_data_.preemption_priority = data.preemption_priority; this->orig_rt_info_data_.info_type = data.info_type; } diff --git a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.cpp b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.cpp index 901dff6304f..7f6932fe82e 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.cpp @@ -97,61 +97,65 @@ visit (TAO_Reconfig_Scheduler_Entry &rse) // Get the dependency set for the current entry. RtecScheduler::Dependency_Set *dependency_set = 0; if (dependency_map_.find (rse.actual_rt_info ()->handle, - dependency_set) != 0) + dependency_set) == 0) { - ACE_ERROR_RETURN ((LM_ERROR, "Dependency set not found"), -1); - } - - // Iterate over the set of dependencies for the current entry. - TAO_Reconfig_Scheduler_Entry * next_rse = 0; - RtecScheduler::RT_Info *next_rt_info; - for (u_int i = 0; i < dependency_set->length (); ++i) - { - // Take the handle from the dependency and use it - // to obtain an RT_Info pointer from the map. - if (rt_info_map_.find ((*dependency_set) [i].rt_info, - next_rt_info) != 0) - { - ACE_ERROR_RETURN ((LM_ERROR, "RT_Info not found"), -1); - } - - // Extract a pointer to the scheduling entry from the RT_Info. - - if (next_rt_info == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, "RT_Info in map was null"), -1); - } - - // Reference the associated scheduling entry: the double cast is - // needed to ensure that the size of the pointer and the size of the - // stored magic cookie are the same (see the definition of - // ptr_arith_t in ACE to grok how this works portably). - next_rse = ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry *, - ACE_static_cast (ptr_arith_t, - next_rt_info-> - volatile_token)); - if (next_rse == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, "entry pointer in RT_Info was null"), -1); - } - - // Call pre-recursion action method, which performs any necessary - // modifications to a successor (or the entry) prior to recursing - // on the successor. - result = this->pre_recurse_action (rse, *next_rse, - (*dependency_set) [i]); - if (result < 0) + // Iterate over the set of dependencies for the current entry. + TAO_Reconfig_Scheduler_Entry * next_rse = 0; + RtecScheduler::RT_Info *next_rt_info; + for (u_int i = 0; i < dependency_set->length (); ++i) { - ACE_ERROR_RETURN ((LM_ERROR, "TAO_RSE_Dependency_Visitor::" - "visit: error from pre-recursion action.\n"), -1); + // Take the handle from the dependency and use it + // to obtain an RT_Info pointer from the map. + if (rt_info_map_.find ((*dependency_set) [i].rt_info, + next_rt_info) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, "RT_Info not found.\n"), -1); + } + + // Extract a pointer to the scheduling entry from the RT_Info. + + if (next_rt_info == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, "RT_Info in map was null.\n"), + -1); + } + + // Reference the associated scheduling entry: the double cast is + // needed to ensure that the size of the pointer and the size of the + // stored magic cookie are the same (see the definition of + // ptr_arith_t in ACE to grok how this works portably). + next_rse = ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry *, + ACE_static_cast (ptr_arith_t, + next_rt_info-> + volatile_token)); + if (next_rse == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Entry pointer in RT_Info was null.\n"), + -1); + } + + // Call pre-recursion action method, which performs any necessary + // modifications to a successor (or the entry) prior to recursing + // on the successor. + result = this->pre_recurse_action (rse, *next_rse, + (*dependency_set) [i]); + if (result < 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "TAO_RSE_Dependency_Visitor::visit: " + "error from pre-recursion action.\n"), + -1); + } + + // If the pre-recursion action returned 0, visit the successor. + if (result == 0) + { + this->visit (*next_rse); + } } - // If the pre-recursion action returned 0, visit the successor. - if (result == 0) - { - this->visit (*next_rse); - } - } + } // Call postfix action method, which performs any necessary // modifications on the node after visiting all its successors. @@ -710,13 +714,17 @@ pre_recurse_action (TAO_Reconfig_Scheduler_Entry &entry, // Constructor. template <class RECONFIG_SCHED_STRATEGY> -TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::TAO_RSE_Priority_Visitor () +TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>:: +TAO_RSE_Priority_Visitor (RtecScheduler::handle_t handles, + TAO_Reconfig_Scheduler_Entry ** entry_ptr_array) : previous_entry_ (0), first_subpriority_entry_ (0), priority_ (0), subpriority_ (0), os_priority_ (ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, - ACE_SCOPE_PROCESS)) + ACE_SCOPE_PROCESS)), + handles_ (handles), + entry_ptr_array_ (entry_ptr_array) { } @@ -737,9 +745,9 @@ TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::visit (TAO_Reconfig_Scheduler // Indicate a new priority level was assigned. result = 1; - // If we're on the first node, store it as the start of - // the priority level. - first_subpriority_entry_ = &rse; + // If we're on the first node, store the start of the array + // as the start of the priority level. + first_subpriority_entry_ = this->entry_ptr_array_; rse.actual_rt_info ()->preemption_subpriority = subpriority_; } else @@ -763,7 +771,7 @@ TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::visit (TAO_Reconfig_Scheduler // Iterate back through and adjust the subpriority levels. for (int i = 0; i <= subpriority_; ++i, ++first_subpriority_entry_) { - first_subpriority_entry_-> + (*first_subpriority_entry_)-> actual_rt_info ()-> preemption_subpriority += subpriority_; } @@ -771,7 +779,6 @@ TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::visit (TAO_Reconfig_Scheduler subpriority_ = 0; rse.actual_rt_info ()->preemption_subpriority = subpriority_; - first_subpriority_entry_ = &rse; ++priority_; os_priority_ = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, os_priority_, @@ -790,6 +797,24 @@ TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::visit (TAO_Reconfig_Scheduler } +// Finishes scheduler entry priority assignment by iterating over the +// remaining entries in the last subpriority level, and adjusting +// their subpriorities. +template <class RECONFIG_SCHED_STRATEGY> int +TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY>::finish () +{ + // Iterate back through and adjust the subpriority levels. + for (int i = 0; i <= subpriority_; ++i, ++first_subpriority_entry_) + { + (*first_subpriority_entry_)-> + actual_rt_info ()-> + preemption_subpriority += subpriority_; + } + + // Indicate no new proirity level was identified. + return 0; +} + /////////////////////////////////////// // class TAO_RSE_Utilization_Visitor // /////////////////////////////////////// diff --git a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.h b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.h index 892eb8b51b7..3a9120922fb 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.h +++ b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Sched_Utils_T.h @@ -309,7 +309,8 @@ class TAO_RSE_Priority_Visitor : { public: - TAO_RSE_Priority_Visitor (); + TAO_RSE_Priority_Visitor (RtecScheduler::handle_t handles, + TAO_Reconfig_Scheduler_Entry ** entry_ptr_array); // Constructor. virtual int visit (TAO_Reconfig_Scheduler_Entry &); @@ -320,12 +321,17 @@ public: // priorities. Returns -1 on error, 1 if a new priority // was assigned, or 0 otherwise. + int finish (); + // Finishes scheduler entry priority assignment by iterating over the + // remaining entries in the last subpriority level, and adjusting + // their subpriorities. + private: TAO_Reconfig_Scheduler_Entry *previous_entry_; // Pointer to previous entry most recently seen in the iteration. - TAO_Reconfig_Scheduler_Entry *first_subpriority_entry_; + TAO_Reconfig_Scheduler_Entry **first_subpriority_entry_; // Pointer to first subpriority entry in the priority level. RtecScheduler::Preemption_Priority_t priority_; @@ -336,6 +342,12 @@ private: RtecScheduler::OS_Priority os_priority_; // Current OS (thread) priority value. + + RtecScheduler::handle_t handles_; + // Number of handles in the entry pointer array. + + TAO_Reconfig_Scheduler_Entry ** entry_ptr_array_; + // An array of pointers to entries we will be visiting. }; template <class RECONFIG_SCHED_STRATEGY> diff --git a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.cpp b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.cpp index cc8dab11355..3f44e3f8163 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.cpp @@ -52,7 +52,9 @@ typedef int (*COMP_FUNC) (const void*, const void*); template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::TAO_Reconfig_Scheduler () - : next_handle_ (0), + : config_info_count_ (0), + rt_info_count_ (0), + next_handle_ (1), entry_ptr_array_ (0), entry_ptr_array_size_ (0), stability_flags_ (SCHED_NONE_STABLE), @@ -73,7 +75,9 @@ TAO_Reconfig_Scheduler (int config_count, int dependency_count, ACE_Scheduler_Factory::POD_Dependency_Info dependency_infos[], u_long stability_flags) - : next_handle_ (0), + : config_info_count_ (0), + rt_info_count_ (0), + next_handle_ (1), stability_flags_ (SCHED_ALL_STABLE), dependency_count_ (0), last_scheduled_priority_ (0) @@ -129,7 +133,9 @@ init (int config_count, // Add the passed config infos to the scheduler auto_ptr<RtecScheduler::Config_Info> new_config_info_ptr; - for (int config_info_count = 0; config_info_count < config_count; ++config_info_count) + for (this->config_info_count_ = 0; + this->config_info_count_ < config_count; + ++this->config_info_count_) { RtecScheduler::Config_Info* new_config_info; ACE_NEW_THROW_EX (new_config_info, @@ -286,8 +292,11 @@ TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::close (CORBA::Environ } - // Finally, start over with the lowest handle number. - next_handle_ = 0; + // Finally, reset the entry counts and start over with the lowest + // handle number. + this->config_info_count_ = 0; + this->rt_info_count_ = 0; + this->next_handle_ = 1; } // Create an RT_Info. If it does not exist, a new RT_Info is @@ -476,13 +485,9 @@ set (RtecScheduler::handle_t handle, { // Get the dependency set for the current entry. RtecScheduler::Dependency_Set *dependency_set = 0; - if (calling_dependency_set_map_.find (rt_info_ptr->handle, - dependency_set) != 0) - { - ACE_THROW (RtecScheduler::INTERNAL ()); - } - - if (dependency_set->length () > 0) + int result = calling_dependency_set_map_.find (rt_info_ptr->handle, + dependency_set); + if (result == 0 && dependency_set->length () > 0) { this->stability_flags_ |= SCHED_PROPAGATION_NOT_STABLE; } @@ -602,11 +607,11 @@ add_dependency (RtecScheduler::handle_t handle /* RT_Info that has the dependenc template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> void TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>:: -compute_scheduling (CORBA::Long /* minimum_priority */, - CORBA::Long /* maximum_priority */, - RtecScheduler::RT_Info_Set_out /* infos */, - RtecScheduler::Config_Info_Set_out /* configs */, - RtecScheduler::Scheduling_Anomaly_Set_out /* anomalies */, +compute_scheduling (CORBA::Long minimum_priority, + CORBA::Long maximum_priority, + RtecScheduler::RT_Info_Set_out infos, + RtecScheduler::Config_Info_Set_out configs, + RtecScheduler::Scheduling_Anomaly_Set_out anomalies, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, RtecScheduler::UTILIZATION_BOUND_EXCEEDED, @@ -661,6 +666,51 @@ compute_scheduling (CORBA::Long /* minimum_priority */, ACE_CHECK; } + // @@ TODO: record any scheduling anomalies in a set within the scheduler, + // storing the maximum severity level recorded so far. + if (anomalies.ptr () == 0) + { + anomalies = + new RtecScheduler::Scheduling_Anomaly_Set (0); + } + + // return the set of scheduled RT_Infos + if (infos.ptr () == 0) + { + infos = new RtecScheduler::RT_Info_Set (this->rt_info_count_); + } + infos->length (this->rt_info_count_); + RtecScheduler::RT_Info* rt_info = 0; + for (RT_INFO_MAP::iterator info_iter (this->rt_info_map_); + info_iter.done () == 0; + ++info_iter) + { + rt_info = (*info_iter).int_id_; + infos[ACE_static_cast (CORBA::ULong, rt_info->handle - 1)] = *rt_info; + } + + // return the set of scheduled Config_Infos + if (configs.ptr () == 0) + { + configs = + new RtecScheduler::Config_Info_Set(this->config_info_count_); + } + configs->length (this->config_info_count_); + RtecScheduler::Config_Info* config_info = 0; + for (CONFIG_INFO_MAP::iterator config_iter (this->config_info_map_); + config_iter.done () == 0; + ++config_iter) + { + config_info = (*config_iter).int_id_; + configs[ACE_static_cast (CORBA::ULong, config_info->preemption_priority)] = *config_info; + } + + ACE_DEBUG ((LM_DEBUG, "Schedule prepared.\n")); + ACE_DEBUG ((LM_DEBUG, "Dumping to stdout.\n")); + ACE_Scheduler_Factory::dump_schedule (*(infos.ptr()), *(configs.ptr()), + *(anomalies.ptr()), 0); + ACE_DEBUG ((LM_DEBUG, "Dump done.\n")); + // Set stability flags last. this->stability_flags_ = SCHED_ALL_STABLE; return; @@ -760,7 +810,7 @@ create_i (const char *entry_point, // Set some reasonable default values, and store the passed ones. TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::init_rt_info (*new_rt_info); - new_rt_info->entry_point = entry_point; + new_rt_info->entry_point = CORBA::string_dup(entry_point); new_rt_info->handle = handle; // Bind the new RT_Info to its handle, in the RT_Info map. @@ -779,8 +829,8 @@ create_i (const char *entry_point, break; } - // Bind the new RT_Info to its entry point, in the tree. - result = rt_info_tree_.bind (entry_point, new_rt_info); + // Bind the new RT_Info to *its* entry point, in the tree. + result = rt_info_tree_.bind (new_rt_info->entry_point, new_rt_info); switch (result) { case -1: @@ -856,7 +906,7 @@ create_i (const char *entry_point, } // Atore in the scheduling entry pointer array. - entry_ptr_array_ [handle] = new_sched_entry; + entry_ptr_array_ [handle - 1] = new_sched_entry; // Store a pointer to the scheduling entry in the scheduling entry // pointer array and in the RT_Info: the double cast is needed to @@ -874,12 +924,16 @@ create_i (const char *entry_point, new_rt_info_ptr.release (); new_sched_entry_ptr.release (); - // With everything safely registered in the map and tree, - // just update the next handle counter and return the new info. - if (handle >= next_handle_) + // With everything safely registered in the map and tree, just + // update the next handle and info counter and return the new info. + if (handle >= this->next_handle_) { this->next_handle_ = handle + 1; } + if (handle > this->rt_info_count_) + { + this->rt_info_count_ = handle; + } return new_rt_info; } @@ -1098,7 +1152,7 @@ dfs_traverse_i (CORBA::Environment &ACE_TRY_ENV) // Reset registered RT_Infos. TAO_RSE_Reset_Visitor reset_visitor; - for (i = 0; i < this->next_handle_; ++i) + for (i = 0; i < this->rt_info_count_; ++i) { if (reset_visitor.visit (* (entry_ptr_array_ [i])) < 0) { @@ -1110,7 +1164,7 @@ dfs_traverse_i (CORBA::Environment &ACE_TRY_ENV) TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK> dfs_visitor (this->calling_dependency_set_map_, this->rt_info_map_); - for (i = 0; i < this->next_handle_; ++i) + for (i = 0; i < this->rt_info_count_; ++i) { if (dfs_visitor.visit (* (entry_ptr_array_ [i])) < 0) { @@ -1174,7 +1228,7 @@ detect_cycles_i (CORBA::Environment &ACE_TRY_ENV) // finish times, which produces a topological ordering, with // callers ahead of called nodes. ::qsort (ACE_reinterpret_cast (void *, entry_ptr_array_), - next_handle_, + this->rt_info_count_, sizeof (TAO_Reconfig_Scheduler_Entry *), ACE_reinterpret_cast (COMP_FUNC, TAO_Reconfig_Scheduler::comp_entry_finish_times)); @@ -1184,7 +1238,7 @@ detect_cycles_i (CORBA::Environment &ACE_TRY_ENV) TAO_RSE_SCC_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK> scc_visitor (this->called_dependency_set_map_, this->rt_info_map_); - for (int i = 0; i < this->next_handle_; ++i) + for (int i = 0; i < this->rt_info_count_; ++i) { // Each new top level entry marks a potential new cycle. scc_visitor.in_a_cycle (0); @@ -1217,7 +1271,7 @@ propagate_characteristics_i (CORBA::Environment &ACE_TRY_ENV) TAO_RSE_Propagation_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK> prop_visitor (this->calling_dependency_set_map_, this->rt_info_map_); - for (int i = 0; i < this->next_handle_; ++i) + for (int i = 0; i < this->rt_info_count_; ++i) { if (prop_visitor.visit (* (entry_ptr_array_ [i])) < 0) { @@ -1252,17 +1306,47 @@ assign_priorities_i (CORBA::Environment &ACE_TRY_ENV) // of static priority and static subpriority, according // to our given scheduling strategy. ::qsort (ACE_reinterpret_cast (void *, entry_ptr_array_), - next_handle_, + this->rt_info_count_, sizeof (TAO_Reconfig_Scheduler_Entry *), ACE_reinterpret_cast (COMP_FUNC, RECONFIG_SCHED_STRATEGY::total_priority_comp)); + // Empty out the previously stored configuration infos, if any. + RtecScheduler::Preemption_Priority_t config_priority; + RtecScheduler::Config_Info *config_info_temp; + while (config_info_map_.current_size () > 0) + { + config_priority = (*config_info_map_.begin ()).ext_id_; + if (config_info_map_.unbind (config_priority, config_info_temp) == 0) + { + delete config_info_temp; + } + else + { + ACE_THROW (RtecScheduler::UNKNOWN_TASK ()); + } + } + // Traverse using a priority assignment visitor, which uses a // strategy to decide when a new priority or subpriority is reached. - TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY> prio_visitor; - for (int i = 0; i < this->next_handle_; ++i) + TAO_RSE_Priority_Visitor<RECONFIG_SCHED_STRATEGY> + prio_visitor (this->rt_info_count_, this->entry_ptr_array_); + auto_ptr<RtecScheduler::Config_Info> new_config_info_ptr; + for (int i = 0; i <= this->rt_info_count_; ++i) { - int result = prio_visitor.visit (* (entry_ptr_array_ [i])); + int result; + + if (i < this->rt_info_count_) + { + // Visit the next entry in the array. + result = prio_visitor.visit (* (this->entry_ptr_array_ [i])); + } + else + { + // Finish up after all enties in the array have been visited. + result = prio_visitor.finish (); + } + if (result < 0) { // Something bad happened with the internal data structures. @@ -1277,7 +1361,7 @@ assign_priorities_i (CORBA::Environment &ACE_TRY_ENV) ACE_CHECK; // Make sure the new config info is cleaned up if we exit abruptly. - auto_ptr<RtecScheduler::Config_Info> new_config_info_ptr (new_config_info); + new_config_info_ptr.reset (new_config_info); // Have the strategy fill in the new config info for that // priority level, using the representative scheduling entry. @@ -1307,6 +1391,7 @@ assign_priorities_i (CORBA::Environment &ACE_TRY_ENV) ACE_THROW (RtecScheduler::DUPLICATE_NAME ()); default: + ++this->config_info_count_; break; } @@ -1325,7 +1410,7 @@ compute_utilization_i (CORBA::Environment &ACE_TRY_ENV) RtecScheduler::INTERNAL)) { TAO_RSE_Utilization_Visitor<RECONFIG_SCHED_STRATEGY> util_visitor; - for (int i = 0; i < this->next_handle_; ++i) + for (int i = 0; i < this->rt_info_count_; ++i) { if (util_visitor.visit (* (entry_ptr_array_ [i])) < 0) { diff --git a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.h b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.h index 88f02fcb032..5b2e378cf0a 100644 --- a/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.h +++ b/TAO/orbsvcs/orbsvcs/Sched/Reconfig_Scheduler_T.h @@ -369,9 +369,16 @@ protected: CONFIG_INFO_MAP config_info_map_; // Map for O(1) lookup of Config_Infos by priority level. + long config_info_count_; + // The number of config infos, which is also the number of priority + // levels. + RT_INFO_MAP rt_info_map_; // Map for O(1) lookup of RT_Infos by handle. + long rt_info_count_; + // The number of registered RT_Infos. + RT_INFO_TREE rt_info_tree_; // Map for O(1) lookup of RT_Infos by handle. @@ -385,7 +392,7 @@ protected: RtecScheduler::handle_t next_handle_; // Next RT_Info descriptor handle to allocate. The first handle is - // 0, so this member also holds the number of handles allocated. + // always 1. TAO_Reconfig_Scheduler_Entry ** entry_ptr_array_; // Array of pointers to scheduling entries. This diff --git a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf.cpp b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf.cpp index 25e52c9c452..1b0a9273f64 100644 --- a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf.cpp +++ b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf.cpp @@ -359,13 +359,14 @@ main (int argc, char *argv[]) // make second half of array depend on first half. for (int i = 0; i < operation_count; ++i) { - // create the RT_Info + // create the RT_Info config_infos[i].handle = ACE_Scheduler_Factory::server ()->create (config_infos[i].entry_point, ACE_TRY_ENV); + ACE_TRY_CHECK; - // initialize the RT_Info - ACE_Scheduler_Factory::server ()-> + // initialize the RT_Info + ACE_Scheduler_Factory::server ()-> set (config_infos[i].handle, ACE_static_cast (RtecScheduler::Criticality_t, config_infos[i].criticality), config_infos[i].worst_case_execution_time, @@ -377,19 +378,21 @@ main (int argc, char *argv[]) config_infos[i].threads, ACE_static_cast (RtecScheduler::Info_Type_t, config_infos[i].info_type), ACE_TRY_ENV); + ACE_TRY_CHECK; - // make operations in second half dependant on - // operations in the first half of the array, - // and have each called twice as a oneway call - if (i >= (operation_count / 2)) - { - ACE_Scheduler_Factory::server ()-> - add_dependency (config_infos[i].handle, - config_infos[i - (operation_count / 2)].handle, - 2, // number of calls - RtecScheduler::ONE_WAY_CALL, // type of dependency - ACE_TRY_ENV); - } + // make operations in second half dependant on + // operations in the first half of the array, + // and have each called twice as a oneway call + if (i >= (operation_count / 2)) + { + ACE_Scheduler_Factory::server ()-> + add_dependency (config_infos[i].handle, + config_infos[i - (operation_count / 2)].handle, + 2, // number of calls + RtecScheduler::ONE_WAY_CALL, // type of dependency + ACE_TRY_ENV); + ACE_TRY_CHECK; + } } RtecScheduler::RT_Info_Set_var infos; diff --git a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp index 4bbb6f5f94b..ba222810d7b 100644 --- a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp +++ b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Anomalies.cpp @@ -222,37 +222,40 @@ main (int argc, char *argv[]) if (ACE_Scheduler_Factory::use_config (my_name_client.get_context (), service_name) < 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to bind to the scheduling service.\n"), - 1); - } - // create and initialize RT_Infos in the scheduler, - // make second half of array depend on first half. - for (int i = 0; i < operation_count; ++i) - { - // create the RT_Info - config_infos[i].handle = - ACE_Scheduler_Factory::server ()->create (config_infos[i].entry_point, - ACE_TRY_ENV); - - // initialize the RT_Info - ACE_Scheduler_Factory::server ()-> - set (config_infos[i].handle, - ACE_static_cast (RtecScheduler::Criticality_t, - config_infos[i].criticality), - config_infos[i].worst_case_execution_time, - config_infos[i].typical_execution_time, - config_infos[i].cached_execution_time, - config_infos[i].period, - ACE_static_cast (RtecScheduler::Importance_t, - config_infos[i].importance), - config_infos[i].quantum, - config_infos[i].threads, - ACE_static_cast (RtecScheduler::Info_Type_t, - config_infos[i].info_type), - ACE_TRY_ENV); - } + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to bind to the scheduling service.\n"), + 1); + } + + // create and initialize RT_Infos in the scheduler, + // make second half of array depend on first half. + for (int i = 0; i < operation_count; ++i) + { + // create the RT_Info + config_infos[i].handle = + ACE_Scheduler_Factory::server ()->create (config_infos[i].entry_point, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // initialize the RT_Info + ACE_Scheduler_Factory::server ()-> + set (config_infos[i].handle, + ACE_static_cast (RtecScheduler::Criticality_t, + config_infos[i].criticality), + config_infos[i].worst_case_execution_time, + config_infos[i].typical_execution_time, + config_infos[i].cached_execution_time, + config_infos[i].period, + ACE_static_cast (RtecScheduler::Importance_t, + config_infos[i].importance), + config_infos[i].quantum, + config_infos[i].threads, + ACE_static_cast (RtecScheduler::Info_Type_t, + config_infos[i].info_type), + ACE_TRY_ENV); + ACE_TRY_CHECK; + } // register dependency of good consumer on good supplier @@ -262,6 +265,7 @@ main (int argc, char *argv[]) 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; // register dependency of consumer that will have unresolved remote // dependencies on supplier with unresolved remote dependencies @@ -271,6 +275,7 @@ main (int argc, char *argv[]) 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; // register dependency of consumer that will have unresolved local @@ -281,6 +286,7 @@ main (int argc, char *argv[]) 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; // register dependencies on each supplier of first consumer that will @@ -291,19 +297,23 @@ main (int argc, char *argv[]) 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_Scheduler_Factory::server ()-> add_dependency (config_infos[6].handle, config_infos[2].handle, 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_Scheduler_Factory::server ()-> add_dependency (config_infos[6].handle, config_infos[4].handle, 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); - + ACE_TRY_CHECK; // Register dependencies on each of the other consumers by second // consumer that will have both unresolved local and unresolved remote @@ -314,25 +324,31 @@ main (int argc, char *argv[]) 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_Scheduler_Factory::server ()-> add_dependency (config_infos[7].handle, config_infos[3].handle, 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_Scheduler_Factory::server ()-> add_dependency (config_infos[7].handle, config_infos[5].handle, 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_Scheduler_Factory::server ()-> add_dependency (config_infos[7].handle, config_infos[6].handle, 1, // number of calls RtecScheduler::ONE_WAY_CALL, // type of dependency ACE_TRY_ENV); - + ACE_TRY_CHECK; RtecScheduler::RT_Info_Set_var infos; RtecScheduler::Config_Info_Set_var configs; diff --git a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp index 1d34ef773d4..31c1fbf987f 100644 --- a/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp +++ b/TAO/orbsvcs/tests/Sched_Conf/Sched_Conf_Runtime.cpp @@ -60,14 +60,19 @@ main (int argc, char *argv[]) ACE_ASSERT (infos [i].handle == runtime_scheduler->create (infos [i].entry_point, ACE_TRY_ENV)); + ACE_TRY_CHECK; + ACE_ASSERT (infos [i].handle == runtime_scheduler->lookup (infos [i].entry_point, ACE_TRY_ENV)); + ACE_TRY_CHECK; // Make sure the values in the RT_Info returned by get are OK. delete rt_info; rt_info = runtime_scheduler->get (infos [i].handle, ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_ASSERT (rt_info != 0); ACE_ASSERT (ACE_OS::strcmp (rt_info->entry_point, infos [i].entry_point) == 0); @@ -114,6 +119,7 @@ main (int argc, char *argv[]) ACE_static_cast (RtecScheduler::Info_Type_t, infos [i].info_type), ACE_TRY_ENV); + ACE_TRY_CHECK; // Make sure the correct priority values are returned. runtime_scheduler->priority (infos [i].handle, @@ -121,6 +127,8 @@ main (int argc, char *argv[]) subpriority, p_priority, ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_ASSERT (priority == infos [i].priority); ACE_ASSERT (subpriority == infos [i].static_subpriority); ACE_ASSERT (p_priority == infos [i].preemption_priority); @@ -129,6 +137,8 @@ main (int argc, char *argv[]) subpriority, p_priority, ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_ASSERT (priority == infos [i].priority); ACE_ASSERT (subpriority == infos [i].static_subpriority); ACE_ASSERT (p_priority == infos [i].preemption_priority); @@ -145,6 +155,8 @@ main (int argc, char *argv[]) priority, dispatching_type, ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_ASSERT (priority == configs [j].thread_priority); ACE_ASSERT (dispatching_type == configs [j].dispatching_type); |