diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-04-21 16:29:35 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-04-21 16:29:35 +0000 |
commit | 9060a4cc8cc2e3627229c0873dd8d73f056a8d0a (patch) | |
tree | ef4504018de8717b75d420a49050c47376015429 | |
parent | 629953f4a5ac42feb79528e22d4e40bf96525cf9 (diff) | |
download | ATCD-9060a4cc8cc2e3627229c0873dd8d73f056a8d0a.tar.gz |
Fri Apr 21 16:28:26 UTC 2006 William R. Otte <wotte@dre.vanderbilt.edu>
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ace/OS_NS_Thread.cpp | 84 | ||||
-rw-r--r-- | ace/Process_Manager.cpp | 40 | ||||
-rw-r--r-- | ace/Process_Manager.h | 16 | ||||
-rw-r--r-- | bin/MakeProjectCreator/config/ciao_config_handlers.mpb | 4 |
5 files changed, 125 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog index 717140d1080..bab008e984b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Apr 21 16:28:26 UTC 2006 William R. Otte <wotte@dre.vanderbilt.edu> + + * ace/OS_NS_Thread.cpp + * ace/Process_Manager.cpp + * ace/Process_Manager.h + * bin/MakeProjectCreator/config/ciao_config_handlers.mpb + + Merge from ARMS Escher repository. + Fri Apr 21 07:41:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl> * ace/Caching_Utility_T.cpp: diff --git a/ace/OS_NS_Thread.cpp b/ace/OS_NS_Thread.cpp index 7a9f9041fd3..c855adb7729 100644 --- a/ace/OS_NS_Thread.cpp +++ b/ace/OS_NS_Thread.cpp @@ -3714,7 +3714,6 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params, #elif defined (ACE_HAS_PTHREADS) && \ (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ defined (ACE_HAS_PTHREAD_SCHEDPARAM)) - ACE_UNUSED_ARG (id); if (sched_params.quantum () != ACE_Time_Value::zero) { // quantums not supported @@ -3735,7 +3734,7 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params, # if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM) ACE_NOTSUP_RETURN (-1); # else /* ! ACE_TANDEM_T1248_PTHREADS */ - int result = ::sched_setscheduler (0, // this process + int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id, sched_params.policy (), ¶m) == -1 ? -1 : 0; # if defined (DIGITAL_UNIX) @@ -3791,40 +3790,73 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params, EtsSetTimeSlice (sched_params.quantum().msec()); # else - ACE_UNUSED_ARG (id); - if (sched_params.scope () != ACE_SCOPE_PROCESS - || sched_params.quantum () != ACE_Time_Value::zero) + if (sched_params.quantum () != ACE_Time_Value::zero) { - // Win32 only allows setting priority class (therefore, policy) - // at the process level. I don't know of a way to set the - // quantum. + // I don't know of a way to set the quantum on Win32. errno = EINVAL; return -1; } -// Setting the REALTIME_PRIORITY_CLASS on Windows is almost always -// a VERY BAD THING. This include guard will allow people -// to easily disable this feature in ACE. -#ifndef ACE_DISABLE_WIN32_INCREASE_PRIORITY - // Set the priority class of this process to the REALTIME process class - // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL. - if (!::SetPriorityClass (::GetCurrentProcess (), - (sched_params.policy () == ACE_SCHED_FIFO || - sched_params.policy () == ACE_SCHED_RR) - ? REALTIME_PRIORITY_CLASS - : NORMAL_PRIORITY_CLASS)) + if (sched_params.scope () == ACE_SCOPE_THREAD) { - ACE_OS::set_errno_to_last_error (); - return -1; - } + + // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always + // a VERY BAD THING. This include guard will allow people + // to easily disable this feature in ACE. +#ifndef ACE_DISABLE_WIN32_INCREASE_PRIORITY + // Set the priority class of this process to the REALTIME process class + // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL. + if (!::SetPriorityClass (::GetCurrentProcess (), + (sched_params.policy () == ACE_SCHED_FIFO || + sched_params.policy () == ACE_SCHED_RR) + ? REALTIME_PRIORITY_CLASS + : NORMAL_PRIORITY_CLASS)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */ # endif /* ACE_HAS_PHARLAP_RT */ - - // Set the thread priority on the current thread. - return ACE_OS::thr_setprio (sched_params.priority ()); - + // Now that we have set the priority class of the process, set the + // priority of the current thread to the desired value. + return ACE_OS::thr_setprio (sched_params.priority ()); + } + else if (sched_params.scope () == ACE_SCOPE_PROCESS) + { + HANDLE hProcess = ::OpenProcess (PROCESS_SET_INFORMATION, + FALSE, + id); + if (!hProcess) + { + ACE_OS::set_errno_to_last_error(); + return -1; + } + // There is no way for us to set the priority of the thread when we + // are setting the priority of a different process. So just ignore + // the priority argument when ACE_SCOPE_PROCESS is specified. + // Setting the priority class will automatically increase the base + // priority of all the threads within a process while maintaining the + // relative priorities of the threads within it. + if (!::SetPriorityClass (hProcess, + (sched_params.policy () == ACE_SCHED_FIFO || + sched_params.policy () == ACE_SCHED_RR) + ? REALTIME_PRIORITY_CLASS + : NORMAL_PRIORITY_CLASS)) + { + ACE_OS::set_errno_to_last_error (); + ::CloseHandle (hProcess); + return -1; + } + ::CloseHandle (hProcess); + return 0; + } + else + { + errno = EINVAL; + return -1; + } #elif defined (VXWORKS) || defined (ACE_PSOS) ACE_UNUSED_ARG (id); diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index 9589885ca84..f476fc04a10 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -652,6 +652,46 @@ ACE_Process_Manager::terminate (pid_t pid, return ACE_OS::kill (pid, sig); } + +int +ACE_Process_Manager::set_scheduler (const ACE_Sched_Params & params, + pid_t pid) +{ + ACE_TRACE ("ACE_Process_Manager::sched_setscheduler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, this->lock_, -1)); + + // Check to see if the process identified by the given pid is managed by + // this instance of ACE_Process_Manager. + ssize_t i = this->find_proc (pid); + + if (i == -1) + // set "no such process" error + return ACE_INVALID_PID; + + return ACE_OS::sched_params (params, pid); +} + +int +ACE_Process_Manager::set_scheduler_all (const ACE_Sched_Params & params) +{ + ACE_TRACE ("ACE_Process_Manager::setscheduler_all"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, this->lock_, -1)); + pid_t pid; + for (size_t i = 0; i < this->current_count_; ++i) + { + pid = this->process_table_[i].process_->getpid (); + if (ACE_OS::sched_params (params, pid) != 0) + return -1; + } + return 0; + +} + + // Locate the index in the table associated with <pid>. Must be // called with the lock held. diff --git a/ace/Process_Manager.h b/ace/Process_Manager.h index 8d50e29a2a1..7bfcc545dcd 100644 --- a/ace/Process_Manager.h +++ b/ace/Process_Manager.h @@ -302,6 +302,22 @@ public: /// Return the number of managed Processes. size_t managed (void) const; + /** + * Sets the scheduling parameters for the <Process> managed by + * <ACE_Process_Manager> identified by pid by passing <params>, <pid> to + * <ACE_OS::sched_params>. Returns 0 on success, -1 on failure, and + * ACE_INVALID_PID when given pid is not managed by + * <ACE_Process_Manager>. + */ + int set_scheduler (const ACE_Sched_Params ¶ms, + pid_t pid); + + /** + * Sets the scheduling parameters for all the <Process>es managed by + * <ACE_Process_Manager> by passing <params> to + * <ACE_OS::sched_params>. Returns 0 on success, -1 on failure. + */ + int set_scheduler_all (const ACE_Sched_Params &); /// Dump the state of an object. void dump (void) const; diff --git a/bin/MakeProjectCreator/config/ciao_config_handlers.mpb b/bin/MakeProjectCreator/config/ciao_config_handlers.mpb index 5fbdecaf47b..7575a2d8a51 100644 --- a/bin/MakeProjectCreator/config/ciao_config_handlers.mpb +++ b/bin/MakeProjectCreator/config/ciao_config_handlers.mpb @@ -5,8 +5,8 @@ project : ciao_xml_utils, dynamicany, typecodefactory { verbatim(gnuace, macros) { override no_hidden_visibility = 1 } - after += XSC_DynAny_Handler XSC_Config_Handlers XSC_XML_Handlers RT_CCM_Config_Handlers CIAO_Events_Handlers - libs += XSC_DynAny_Handler XSC_Config_Handlers XSC_XML_Handlers RT_CCM_Config_Handlers CIAO_Events_Handlers + after += XSC_DynAny_Handler XSC_Config_Handlers XSC_XML_Handlers RT_CCM_Config_Handlers CIAO_Events_Handlers Package_Config_Handlers + libs += XSC_DynAny_Handler XSC_Config_Handlers XSC_XML_Handlers RT_CCM_Config_Handlers CIAO_Events_Handlers Package_Config_Handlers } |