diff options
author | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-03-06 05:06:22 +0000 |
---|---|---|
committer | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-03-06 05:06:22 +0000 |
commit | cbba326027526832b3b5ed5f0f005203326ed2ca (patch) | |
tree | f4320058468a7161842f9114e04860c02bc39329 | |
parent | 977717812053cb3e3d8cf2956c29ebce0c5ff942 (diff) | |
download | ATCD-cbba326027526832b3b5ed5f0f005203326ed2ca.tar.gz |
ChangeLogTag:Fri Mar 5 23:09:14 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r-- | ChangeLog | 46 | ||||
-rw-r--r-- | ace/OS_NS_sys_socket.inl | 1 | ||||
-rw-r--r-- | ace/Task.cpp | 9 | ||||
-rw-r--r-- | ace/Task.h | 12 | ||||
-rw-r--r-- | ace/Thread.cpp | 78 | ||||
-rw-r--r-- | ace/Thread_Manager.cpp | 59 | ||||
-rw-r--r-- | ace/Thread_Manager.h | 24 | ||||
-rw-r--r-- | ace/os_include/os_langinfo.h | 2 | ||||
-rw-r--r-- | ace/os_include/os_spawn.h | 2 |
9 files changed, 174 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog index feaf03794f7..b7ba4d9b892 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +Fri Mar 5 23:09:14 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * ace/OS_NS_sys_socket.inl (closesocket): + + Win32 distinguishes between shutting down a socket connection + and closing a socket. Therefore call shutdown on the socket + before closing down the socket. Thanks to Kitty for digging up + the MSDN documentation and the patch. + + * ace/Task.cpp (activate): + * ace/Task.h (activate): + + Added an extra argument, inherit_priority which tells the thread + manager to inherit the priority of the calling thread or use the + priority passed in. + + * ace/Thread_Manager.cpp: + * ace/Thread_Manager.h (spawn, spawn_n, spawn_i): + + Added an extra argument, inherit_priority which tells the thread + manager to inherit the priority of the calling thread or use the + value of the priority passed in. This argument is set to false + by default, which would retain the classical behaviour. + + Thanks to Abhi <abhi@qualcomm.com> for reporting the bug. Thanks + to Dr. Schmidt and Kitty for motivating me to add the fix in + ACE. + + I am not still certain whether the above fix is okay. Folks who + call ACE_Thread::spawn* and ACE_OS::thr_create () will not get + this feature. Still wondering whether we should propogate this + feature down to ACE_Thread or ACE_OS level. Willing to hear any + advise or motivation on this. + + * ace/Thread.cpp: + + Cosmetic formatting fixes. + + * ace/os_include/os_langinfo.h: + * ace/os_include/os_spawn.h: + + Fixed typos in the included file names. Thanks to Robert + Schiele<robert.schiele@t-online.de> for reporting the problem. + Fri Mar 5 18:12:24 2004 Steve Huston <shuston@riverace.com> * ace/Asynch_Acceptor.cpp (open): If any of the steps in the open fail, @@ -13,7 +57,7 @@ Fri Mar 5 22:56:45 UTC 2004 Don Hinton <dhinton@dre.vanderbilt.edu> Fri Mar 5 16:56:25 2004 Yamuna Krishnamurthy <yamuna@oomworks.com> - * bin\tao_other_tests.lst: + * bin/tao_other_tests.lst: Replaced the string 'RTP/UDP' with 'RTP_UDP' where specified as a command line argument to the AVStreams tests run_test.pl. This diff --git a/ace/OS_NS_sys_socket.inl b/ace/OS_NS_sys_socket.inl index c486513ad22..4d69c6a5bcf 100644 --- a/ace/OS_NS_sys_socket.inl +++ b/ace/OS_NS_sys_socket.inl @@ -102,6 +102,7 @@ ACE_OS::closesocket (ACE_HANDLE handle) { ACE_OS_TRACE ("ACE_OS::closesocket"); #if defined (ACE_WIN32) + ACE_OS::shutdown (handle, SD_SEND); ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1); #elif defined (ACE_PSOS_DIAB_PPC) ACE_OSCALL_RETURN (::pna_close (handle), int, -1); diff --git a/ace/Task.cpp b/ace/Task.cpp index dc7b5abdf0e..9862dbf181b 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -70,7 +70,8 @@ ACE_Task_Base::activate (long flags, ACE_hthread_t thread_handles[], void *stack[], size_t stack_size[], - ACE_thread_t thread_ids[]) + ACE_thread_t thread_ids[], + bool inherit_priority) { ACE_TRACE ("ACE_Task_Base::activate"); @@ -115,7 +116,8 @@ ACE_Task_Base::activate (long flags, task, thread_handles, stack, - stack_size); + stack_size, + inherit_priority); else // thread names were specified grp_spawned = @@ -129,7 +131,8 @@ ACE_Task_Base::activate (long flags, stack, stack_size, thread_handles, - task); + task, + inherit_priority); if (grp_spawned == -1) { // If spawn_n fails, restore original thread count. diff --git a/ace/Task.h b/ace/Task.h index 039bec6f273..69fb15b788c 100644 --- a/ace/Task.h +++ b/ace/Task.h @@ -168,7 +168,14 @@ public: * the base of the stacks to use for the threads being spawned. * Likewise, if <stack_size> != 0 it is assumed to be an array of * <n> values indicating how big each of the corresponding <stack>s - * are. */ + * are. + * + * The argument <inherit_priority> is used to assign the priority of + * the calling thread on the spawned thread. The spawned thread will + * inherit the priority and scheduling policy of the invoking thread, + * if the value of the <inherit_priority> is set to true. + * + */ virtual int activate (long flags = THR_NEW_LWP | THR_JOINABLE, int n_threads = 1, int force_active = 0, @@ -178,7 +185,8 @@ public: ACE_hthread_t thread_handles[] = 0, void *stack[] = 0, size_t stack_size[] = 0, - ACE_thread_t thread_ids[] = 0); + ACE_thread_t thread_ids[] = 0, + bool inherit_priority = false); /** * Block until there are no more threads running in this task. diff --git a/ace/Thread.cpp b/ace/Thread.cpp index 45a0dce23eb..426e9535955 100644 --- a/ace/Thread.cpp +++ b/ace/Thread.cpp @@ -7,18 +7,20 @@ #include "ace/Thread.i" #endif /* !defined (__ACE_INLINE__) */ -ACE_RCSID(ace, Thread, "$Id$") +ACE_RCSID(ace, + Thread, + "$Id$") #if defined (ACE_HAS_THREADS) size_t -ACE_Thread::spawn_n (size_t n, - ACE_THR_FUNC func, - void *arg, - long flags, - long priority, - void *stack[], - size_t stack_size[], +ACE_Thread::spawn_n (size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority, + void *stack[], + size_t stack_size[], ACE_Thread_Adapter *thread_adapter) { ACE_TRACE ("ACE_Thread::spawn_n"); @@ -28,14 +30,14 @@ ACE_Thread::spawn_n (size_t n, for (i = 0; i < n; i++) // Bail out if error occurs. if (ACE_OS::thr_create (func, - arg, - flags, - &t_id, - 0, - priority, - stack == 0 ? 0 : stack[i], - stack_size == 0 ? 0 : stack_size[i], - thread_adapter) != 0) + arg, + flags, + &t_id, + 0, + priority, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? 0 : stack_size[i], + thread_adapter) != 0) break; return i; @@ -43,14 +45,14 @@ ACE_Thread::spawn_n (size_t n, size_t ACE_Thread::spawn_n (ACE_thread_t thread_ids[], - size_t n, - ACE_THR_FUNC func, - void *arg, - long flags, - long priority, - void *stack[], - size_t stack_size[], - ACE_hthread_t thread_handles[], + size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority, + void *stack[], + size_t stack_size[], + ACE_hthread_t thread_handles[], ACE_Thread_Adapter *thread_adapter) { ACE_TRACE ("ACE_Thread::spawn_n"); @@ -61,24 +63,24 @@ ACE_Thread::spawn_n (ACE_thread_t thread_ids[], ACE_thread_t t_id; ACE_hthread_t t_handle; - int result = - ACE_OS::thr_create (func, - arg, - flags, - &t_id, - &t_handle, - priority, - stack == 0 ? 0 : stack[i], - stack_size == 0 ? 0 : stack_size[i], - thread_adapter); + int result = + ACE_OS::thr_create (func, + arg, + flags, + &t_id, + &t_handle, + priority, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? 0 : stack_size[i], + thread_adapter); if (result == 0) - { + { if (thread_ids != 0) thread_ids[i] = t_id; - if (thread_handles != 0) - thread_handles[i] = t_handle; - } + if (thread_handles != 0) + thread_handles[i] = t_handle; + } else // Bail out if error occurs. break; diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index 9a546e1895e..d68565afc03 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -540,7 +540,8 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, int grp_id, void *stack, size_t stack_size, - ACE_Task_Base *task) + ACE_Task_Base *task, + bool inherit_priority) { // First, threads created by Thread Manager should not be daemon threads. // Using assertion is probably a bit too strong. However, it helps @@ -611,6 +612,34 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, // removing this Thread Descriptor before it gets put into our // thread table. + if (inherit_priority) + { + int tmp_priority; + int sched_policy = ACE_SCHED_OTHER; + + // Get the system policy and priority + if (ACE_Thread::getprio (ACE_Thread::self (), + tmp_priority, + sched_policy) == -1) + { + priority = ACE_DEFAULT_THREAD_PRIORITY; + } + else + { + priority = tmp_priority; + } + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) xxx \n")); + if (sched_policy == ACE_SCHED_FIFO) + ACE_SET_BITS (flags, THR_SCHED_FIFO); + else if (sched_policy == ACE_SCHED_RR) + ACE_SET_BITS (flags, THR_SCHED_FIFO); + else + ACE_SET_BITS (flags, THR_SCHED_DEFAULT); + + } + int result = ACE_Thread::spawn (func, args, flags, @@ -675,7 +704,8 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, long priority, int grp_id, void *stack, - size_t stack_size) + size_t stack_size, + bool inherit_priority) { ACE_TRACE ("ACE_Thread_Manager::spawn"); @@ -684,8 +714,17 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, if (grp_id == -1) grp_id = this->grp_id_++; // Increment the group id. - if (this->spawn_i (func, args, flags, t_id, t_handle, - priority, grp_id, stack, stack_size) == -1) + if (this->spawn_i (func, + args, + flags, + t_id, + t_handle, + priority, + grp_id, + stack, + stack_size, + 0, + inherit_priority) == -1) return -1; return grp_id; @@ -703,7 +742,8 @@ ACE_Thread_Manager::spawn_n (size_t n, ACE_Task_Base *task, ACE_hthread_t thread_handles[], void *stack[], - size_t stack_size[]) + size_t stack_size[], + bool inherit_priority) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); @@ -724,7 +764,8 @@ ACE_Thread_Manager::spawn_n (size_t n, grp_id, stack == 0 ? 0 : stack[i], stack_size == 0 ? 0 : stack_size[i], - task) == -1) + task, + inherit_priority) == -1) return -1; } @@ -744,7 +785,8 @@ ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[], void *stack[], size_t stack_size[], ACE_hthread_t thread_handles[], - ACE_Task_Base *task) + ACE_Task_Base *task, + bool inherit_priority) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); @@ -765,7 +807,8 @@ ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[], grp_id, stack == 0 ? 0 : stack[i], stack_size == 0 ? 0 : stack_size[i], - task) == -1) + task, + inherit_priority) == -1) return -1; } diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index d0b6ea1876b..013ea744eac 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -501,7 +501,8 @@ public: long priority = ACE_DEFAULT_THREAD_PRIORITY, int grp_id = -1, void *stack = 0, - size_t stack_size = 0); + size_t stack_size = 0, + bool inherit_priority = false); /** * Spawn N new threads, which execute <func> with argument <arg>. @@ -529,6 +530,11 @@ public: * <ACE_Task_Base::activate>. It associates the newly spawned * threads with an ACE_Task instance, which defaults to <this>. * + * The argument <inherit_priority> is used to assign the priority of + * the calling thread on the spawned thread. The spawned thread will + * inherit the priority and scheduling policy of the invoking thread + * if the value of the <inherit_priority> is set to true. + * * @retval -1 on failure (<errno> will explain...), otherwise returns the * group id of the threads. */ @@ -541,7 +547,8 @@ public: ACE_Task_Base *task = 0, ACE_hthread_t thread_handles[] = 0, void *stack[] = 0, - size_t stack_size[] = 0); + size_t stack_size[] = 0, + bool inherit_priority = false); /** * Spawn N new threads, which execute <func> with argument <arg>. @@ -569,6 +576,11 @@ public: * <ACE_Task_Base::activate>. It associates the newly spawned * threads with an ACE_Task instance, which defaults to <this>. * + * The argument <inherit_priority> is used to assign the priority of + * the calling thread on the spawned thread. The spawned thread will + * inherit the priority and scheduling policy, of the invoking + * thread if the value of the <inherit_priority> is set to true. + * * @retval -1 on failure (<errno> will explain...), otherwise returns the * group id of the threads. */ @@ -582,7 +594,8 @@ public: void *stack[] = 0, size_t stack_size[] = 0, ACE_hthread_t thread_handles[] = 0, - ACE_Task_Base *task = 0); + ACE_Task_Base *task = 0, + bool inherit_priority = false); /** * Called to clean up when a thread exits. @@ -726,7 +739,7 @@ public: * True if <t_id> has terminated (i.e., is no longer running), * but the slot in the thread manager hasn't been reclaimed yet, * else false. Always return false if <t_id> is not managed by the - * Thread_Manager. + * Thread_Manager. */ int testterminate (ACE_thread_t t_id); @@ -954,7 +967,8 @@ protected: int grp_id = -1, void *stack = 0, size_t stack_size = 0, - ACE_Task_Base *task = 0); + ACE_Task_Base *task = 0, + bool inherit_priority = false); /// Run the registered hooks when the thread exits. void run_thread_exit_hooks (int i); diff --git a/ace/os_include/os_langinfo.h b/ace/os_include/os_langinfo.h index d2a737a2e02..9023750f8cd 100644 --- a/ace/os_include/os_langinfo.h +++ b/ace/os_include/os_langinfo.h @@ -24,7 +24,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/os_include/so_nl_types.h" +#include "ace/os_include/os_nl_types.h" #if !defined (ACE_LACKS_LANGINFO_H) # include /**/ <langinfo.h> diff --git a/ace/os_include/os_spawn.h b/ace/os_include/os_spawn.h index b13dbacbff1..797e48af614 100644 --- a/ace/os_include/os_spawn.h +++ b/ace/os_include/os_spawn.h @@ -25,7 +25,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/os_include/os_signal.h" -#include "ace/os_include/os_sys/types.h" +#include "ace/os_include/sys/os_types.h" #include "ace/os_include/os_sched.h" #if !defined (ACE_LACKS_SPAWN_H) |