diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-21 16:06:38 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-21 16:06:38 +0000 |
commit | 7ea8ebf6558487a08603f1354db987c6bb7a975d (patch) | |
tree | 7a0cd009de79e94abf65b9e637d910bae6abc98e | |
parent | 02cabf4598fbdbecf44efa9adb6f5670a13788f7 (diff) | |
download | ATCD-7ea8ebf6558487a08603f1354db987c6bb7a975d.tar.gz |
factored out thread creation flags to Globals::thr_create_flags, and only set THR_SCHED_FIFO flag if sched_fifo_init operation to set process FIFO scheduling succeeded
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.cpp | 14 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.h | 10 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/client.cpp | 101 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp | 47 |
4 files changed, 101 insertions, 71 deletions
diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.cpp index 72e4ae4ec5b..83c02497c97 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.cpp @@ -3,7 +3,8 @@ #include "Globals.h" Globals::Globals (void) - : ior_file (0), + : thr_create_flags (THR_BOUND), + ior_file (0), base_port (0), num_of_objs (2), thread_per_rate (0), @@ -83,9 +84,12 @@ Globals::sched_fifo_init (void) ACE_SCOPE_PROCESS))) { if (ACE_OS::last_error () == EPERM) - ACE_DEBUG ((LM_MAX, - "User is not superuser, " - "so remain in time-sharing class\n")); + { + ACE_DEBUG ((LM_MAX, + "User is not superuser, " + "so remain in time-sharing class\n")); + return 1; + } else ACE_ERROR_RETURN ((LM_ERROR, "%n: ACE_OS::sched_params failed\n%a"), @@ -96,6 +100,8 @@ Globals::sched_fifo_init (void) "Test will not run. This platform doesn't seem to have threads.\n"), -1); #endif /* ACE_HAS_THREADS */ + + ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_SCHED_FIFO); return 0; } diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.h index d760a2d2eb3..2c46f3c06ad 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Globals.h @@ -117,7 +117,15 @@ public: // parse the arguments. static int sched_fifo_init (void); - // enables fifo scheduling eg.RT scheduling class on solaris. + // Enables fifo scheduling eg., RT scheduling class on solaris. + // Returns 0 on success, 1 if insufficient permission, or -1 + // for other failure. As a side effect, sets thr_create_flags + // appropriately. + + long thr_create_flags; + // Thread creation flags. Must call sched_fifo_init () before + // accessing. + char hostname[BUFSIZ]; // hostname to be used for ORB_init. diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.cpp index f302b31c151..f5075bc3852 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.cpp @@ -92,7 +92,7 @@ Client_i::init (int argc, char *argv[]) int result; result = GLOBALS::instance ()->sched_fifo_init (); - if (result != 0) + if (result == -1) return result; VX_VME_INIT; FORCE_ARGV (this->argc_,this->argv_); @@ -322,16 +322,17 @@ Client_i::activate_high_client (void) ACE_DEBUG ((LM_DEBUG, "Creating 1 client with high priority of %d\n", this->high_priority_)); - if (this->high_priority_client_->activate (THR_BOUND | THR_SCHED_FIFO, - 1, - 0, - this->high_priority_, - -1, - 0, - 0, - 0, - 0, - (ACE_thread_t *) &this->task_id_) == -1) + if (this->high_priority_client_->activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 0, + this->high_priority_, + -1, + 0, + 0, + 0, + 0, + (ACE_thread_t *) &this->task_id_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p; priority is %d\n", "activate failed", @@ -390,17 +391,17 @@ Client_i::activate_low_client (void) this->low_priority_)); // The first thread starts at the lowest priority of all the low // priority clients. - if (this->low_priority_client_[i - 1]->activate - (THR_BOUND | THR_SCHED_FIFO, - 1, - 0, - this->low_priority_, // These are constructor defaults. - -1, // int grp_id = -1, - 0, // ACE_Task_Base *task = 0, - 0, // ACE_hthread_t thread_handles[] = 0, - 0, // void *stack[] = 0, - 0, // size_t stack_size[] = 0, - (ACE_thread_t *) &this->task_id_) == -1) + if (this->low_priority_client_[i - 1]->activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 0, + this->low_priority_, // These are constructor defaults. + -1, // int grp_id = -1, + 0, // ACE_Task_Base *task = 0, + 0, // ACE_hthread_t thread_handles[] = 0, + 0, // void *stack[] = 0, + 0, // size_t stack_size[] = 0, + (ACE_thread_t *) &this->task_id_) == -1) ACE_ERROR ((LM_ERROR, "%p; priority is %d\n", "activate failed", @@ -448,11 +449,11 @@ Client_i::activate_util_thread (void) // Activate the Utilization thread. It will wait until all // threads have finished binding. - this->util_thread_->activate - (THR_BOUND | THR_SCHED_FIFO, - 1, - 0, - this->low_priority_); + this->util_thread_->activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 0, + this->low_priority_); } else this->util_thread_->close (); @@ -604,11 +605,11 @@ Client_i::start_servant (void) this->high_priority_)); // Make the high priority task an active object. - if (high_priority_task->activate - (THR_BOUND | THR_SCHED_FIFO, - 1, - 0, - this->high_priority_) == -1) + if (high_priority_task->activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 0, + this->high_priority_) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "\thigh_priority_task->activate failed")); @@ -739,10 +740,11 @@ Client_i::do_thread_per_rate_test (void) "Creating 20 Hz client with priority %d\n", priority)); - if (CB_20Hz_client.activate (THR_BOUND | THR_SCHED_FIFO, - 1, - 1, - priority) == -1) + if (CB_20Hz_client.activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 1, + priority) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) errno = %p: activate failed\n")); // The high priority thread is parsing the arguments, so wait on the @@ -768,10 +770,11 @@ Client_i::do_thread_per_rate_test (void) "Creating 10 Hz client with priority %d\n", priority)); - if (CB_10Hz_client.activate (THR_BOUND | THR_SCHED_FIFO, - 1, - 1, - priority) == -1) + if (CB_10Hz_client.activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 1, + priority) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) errno = %p: activate failed\n")); @@ -782,10 +785,11 @@ Client_i::do_thread_per_rate_test (void) "Creating 5 Hz client with priority %d\n", priority)); - if (CB_5Hz_client.activate (THR_BOUND | THR_SCHED_FIFO, - 1, - 1, - priority) == -1) + if (CB_5Hz_client.activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 1, + priority) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) errno = %p: activate failed\n")); @@ -796,10 +800,11 @@ Client_i::do_thread_per_rate_test (void) "Creating 1 Hz client with priority %d\n", priority)); - if (CB_1Hz_client.activate (THR_BOUND | THR_SCHED_FIFO, - 1, - 1, - priority) == -1) + if (CB_1Hz_client.activate ( + GLOBALS::instance ()->thr_create_flags, + 1, + 1, + priority) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) errno = %p: activate failed\n")); diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp index 17e744c6b0e..4eb1187d7b3 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp @@ -42,7 +42,7 @@ Server::init (int argc, char **argv) int result; result = GLOBALS::instance ()->sched_fifo_init (); - if (result != 0) + if (result == -1) return result; this->argc_ = argc; @@ -199,13 +199,15 @@ Server::activate_high_servant (void) // Make the high priority task an active object. if (this->high_priority_task_->activate - (THR_BOUND | THR_SCHED_FIFO, + (GLOBALS::instance ()->thr_create_flags, 1, 0, this->high_priority_) == -1) - ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n", - "\thigh_priority_task->activate failed")); + ACE_DEBUG ((LM_ERROR, + ASYS_TEXT ("(%P|%t) task activation at priority %d ") + ASYS_TEXT (" failed, exiting!\n%a"), + this->high_priority_, + -1)); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, @@ -230,14 +232,20 @@ Server::activate_low_servants (void) ACE_OS::sprintf (orbhost, "-ORBhost %s ", GLOBALS::instance ()->hostname); - ACE_DEBUG ((LM_DEBUG, - "Creating %d servants starting at priority %d\n", - this->num_low_priority_, - this->low_priority_)); - // Create the low priority servants. - ACE_NEW_RETURN (this->low_priority_tasks_, - Cubit_Task *[GLOBALS::instance ()->num_of_objs], - -1); + + if (ACE_static_cast (int, this->num_low_priority_) > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Creating %d servants starting at priority %d\n", + this->num_low_priority_, + this->low_priority_)); + + // Create the low priority servants. + ACE_NEW_RETURN (this->low_priority_tasks_, + Cubit_Task *[GLOBALS::instance ()->num_of_objs], + -1); + } + for (int i = this->num_low_priority_; i > 0; i--) @@ -269,14 +277,17 @@ Server::activate_low_servants (void) -1); // Make the low priority task an active object. - if (this->low_priority_tasks_ [i - 1]->activate - (THR_BOUND | THR_SCHED_FIFO, + if (this->low_priority_tasks_[i - 1]->activate + (GLOBALS::instance ()->thr_create_flags, 1, 0, this->low_priority_) == -1) - ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n" - "\tthis->low_priority_tasks_[i]->activate")); + ACE_DEBUG ((LM_ERROR, + ASYS_TEXT ("(%P|%t) task activation at priority %d ") + ASYS_TEXT (" failed, exiting!\n%a"), + this->low_priority_, + -1)); + ACE_DEBUG ((LM_DEBUG, "Created servant %d with priority %d\n", i, |