summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-04-16 17:57:35 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-04-16 17:57:35 +0000
commit20ed9d12258ba5250f0bd27c374a1836ec9678cc (patch)
treec38dbd5e8836b7f1cc210a61c5228e8b9fd587ed /ace
parent6e3819d1ab25897551c493f7481007f4b7e8dabc (diff)
downloadATCD-20ed9d12258ba5250f0bd27c374a1836ec9678cc.tar.gz
ChangeLogTag: Wed Apr 16 13:44:47 2003 Irfan Pyarali <irfan@oomworks.com>
Diffstat (limited to 'ace')
-rw-r--r--ace/OS.h12
-rw-r--r--ace/OS.i107
-rw-r--r--ace/Thread.h7
-rw-r--r--ace/Thread.i69
4 files changed, 108 insertions, 87 deletions
diff --git a/ace/OS.h b/ace/OS.h
index 7b81d92347c..15d6e160095 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -5863,8 +5863,6 @@ public:
size_t stacksize = 0,
ACE_Base_Thread_Adapter *thread_adapter = 0);
- static int thr_getprio (ACE_hthread_t thr_id,
- int &prio);
static int thr_join (ACE_hthread_t waiter_id,
ACE_THR_FUNC_RETURN *status);
static int thr_join (ACE_thread_t waiter_id,
@@ -5874,8 +5872,14 @@ public:
int signum);
static ACE_thread_t thr_self (void);
static void thr_self (ACE_hthread_t &);
- static int thr_setprio (ACE_hthread_t thr_id,
- int prio, int thr_policy=-1);
+ static int thr_getprio (ACE_hthread_t id,
+ int &priority);
+ static int thr_getprio (ACE_hthread_t id,
+ int &priority,
+ int &policy);
+ static int thr_setprio (ACE_hthread_t id,
+ int priority,
+ int policy = -1);
static int thr_setprio (const ACE_Sched_Priority prio);
static int thr_suspend (ACE_hthread_t target_thread);
static int thr_cancel (ACE_thread_t t_id);
diff --git a/ace/OS.i b/ace/OS.i
index ef140f38641..64ddaac52a2 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -6472,18 +6472,19 @@ ACE_OS::thr_getconcurrency (void)
}
ACE_INLINE int
-ACE_OS::thr_getprio (ACE_hthread_t thr_id, int &prio)
+ACE_OS::thr_getprio (ACE_hthread_t id, int &priority, int &policy)
{
ACE_OS_TRACE ("ACE_OS::thr_getprio");
+ ACE_UNUSED_ARG (policy);
#if defined (ACE_HAS_THREADS)
# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED))
# if defined (ACE_HAS_PTHREADS_DRAFT4)
int result;
- result = ::pthread_getprio (thr_id);
+ result = ::pthread_getprio (id);
if (result != -1)
{
- prio = result;
+ priority = result;
return 0;
}
else
@@ -6491,9 +6492,9 @@ ACE_OS::thr_getprio (ACE_hthread_t thr_id, int &prio)
# elif defined (ACE_HAS_PTHREADS_DRAFT6)
pthread_attr_t attr;
- if (pthread_getschedattr (thr_id, &attr) == 0)
+ if (pthread_getschedattr (id, &attr) == 0)
{
- prio = pthread_attr_getprio(&attr);
+ priority = pthread_attr_getprio(&attr);
return 0;
}
return -1;
@@ -6501,39 +6502,46 @@ ACE_OS::thr_getprio (ACE_hthread_t thr_id, int &prio)
struct sched_param param;
int result;
- int policy = 0;
- ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_id, &policy, &param),
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, &param),
result), int,
-1, result);
- prio = param.sched_priority;
+ priority = param.sched_priority;
return result;
# endif /* ACE_HAS_PTHREADS_DRAFT4 */
# elif defined (ACE_HAS_STHREADS)
- ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (thr_id, &prio), ace_result_), int, -1);
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (id, &priority), ace_result_), int, -1);
# elif defined (ACE_HAS_WTHREADS)
- prio = ::GetThreadPriority (thr_id);
- if (prio == THREAD_PRIORITY_ERROR_RETURN)
+ priority = ::GetThreadPriority (id);
+ if (priority == THREAD_PRIORITY_ERROR_RETURN)
ACE_FAIL_RETURN (-1);
else
return 0;
# elif defined (ACE_PSOS)
// passing a 0 in the second argument does not alter task priority, third arg gets existing one
- ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (thr_id, 0, (u_long *) &prio), ace_result_), int, -1);
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, 0, (u_long *) &priority), ace_result_), int, -1);
# elif defined (VXWORKS)
- ACE_OSCALL_RETURN (::taskPriorityGet (thr_id, &prio), int, -1);
+ ACE_OSCALL_RETURN (::taskPriorityGet (id, &priority), int, -1);
# else
- ACE_UNUSED_ARG (thr_id);
- ACE_UNUSED_ARG (prio);
+ ACE_UNUSED_ARG (id);
+ ACE_UNUSED_ARG (priority);
ACE_NOTSUP_RETURN (-1);
# endif /* ACE_HAS_STHREADS */
#else
- ACE_UNUSED_ARG (thr_id);
- ACE_UNUSED_ARG (prio);
+ ACE_UNUSED_ARG (id);
+ ACE_UNUSED_ARG (priority);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_THREADS */
}
+ACE_INLINE int
+ACE_OS::thr_getprio (ACE_hthread_t id, int &priority)
+{
+ ACE_OS_TRACE ("ACE_OS::thr_getprio");
+ int policy = 0;
+ return ACE_OS::thr_getprio (id, priority, policy);
+}
+
#if defined (ACE_HAS_TSS_EMULATION)
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
@@ -7280,72 +7288,71 @@ ACE_OS::thr_setconcurrency (int hint)
}
ACE_INLINE int
-ACE_OS::thr_setprio (ACE_hthread_t thr_id, int prio, int thr_policy)
+ACE_OS::thr_setprio (ACE_hthread_t id, int priority, int policy)
{
ACE_OS_TRACE ("ACE_OS::thr_setprio");
- ACE_UNUSED_ARG(thr_policy);
+ ACE_UNUSED_ARG (policy);
#if defined (ACE_HAS_THREADS)
# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED))
# if defined (ACE_HAS_PTHREADS_DRAFT4)
int result;
- result = ::pthread_setprio(thr_id, prio);
+ result = ::pthread_setprio (id, priority);
return (result == -1 ? -1 : 0);
# elif defined (ACE_HAS_PTHREADS_DRAFT6)
pthread_attr_t attr;
- if (pthread_getschedattr (thr_id, &attr) == -1)
+ if (pthread_getschedattr (id, &attr) == -1)
return -1;
- if (pthread_attr_setprio (attr, prio) == -1)
+ if (pthread_attr_setprio (attr, priority) == -1)
return -1;
- return pthread_setschedattr (thr_id, attr);
+ return pthread_setschedattr (id, attr);
# else
- struct sched_param param;
- int policy = 0;
int result;
+ struct sched_param param;
+ memset ((void *) &param, 0, sizeof param);
- ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_id, &policy, &param), result);
- if (result != 0)
- result = -1;
-
- if (result == -1)
- return result; // error in pthread_getschedparam
-
- /* if thr_policy is -1, we don't want to use it for pthread_setschedparam().
- Instead, use policy which was obtained from pthread_getschedparam() */
- if (thr_policy == -1)
- thr_policy = policy;
+ // If <policy> is -1, we don't want to use it for
+ // pthread_setschedparam(). Instead, obtain policy from
+ // pthread_getschedparam().
+ if (policy == -1)
+ {
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, &param),
+ result),
+ int, -1, result);
+ if (result == -1)
+ return result;
+ }
- param.sched_priority = prio;
- ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, thr_policy, &param), result);
- if (result != 0)
- result = -1;
+ param.sched_priority = priority;
- return result;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (id, policy, &param),
+ ace_result_),
+ int, -1);
# endif /* ACE_HAS_PTHREADS_DRAFT4 */
# elif defined (ACE_HAS_STHREADS)
- ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (thr_id, prio),
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (id, priority),
ace_result_),
int, -1);
# elif defined (ACE_HAS_WTHREADS)
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (thr_id, prio),
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (id, priority),
ace_result_),
int, -1);
# elif defined (ACE_PSOS)
- u_long oldprio;
- ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (thr_id, prio, &oldprio),
+ u_long oldpriority;
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, priority, &oldpriority),
ace_result_),
int, -1);
# elif defined (VXWORKS)
- ACE_OSCALL_RETURN (::taskPrioritySet (thr_id, prio), int, -1);
+ ACE_OSCALL_RETURN (::taskPrioritySet (id, priority), int, -1);
# else
// For example, platforms that support Pthreads but LACK_SETSCHED.
- ACE_UNUSED_ARG (thr_id);
- ACE_UNUSED_ARG (prio);
+ ACE_UNUSED_ARG (id);
+ ACE_UNUSED_ARG (priority);
ACE_NOTSUP_RETURN (-1);
# endif /* ACE_HAS_STHREADS */
#else
- ACE_UNUSED_ARG (thr_id);
- ACE_UNUSED_ARG (prio);
+ ACE_UNUSED_ARG (id);
+ ACE_UNUSED_ARG (priority);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_THREADS */
}
diff --git a/ace/Thread.h b/ace/Thread.h
index 30cbc611097..48f960da386 100644
--- a/ace/Thread.h
+++ b/ace/Thread.h
@@ -147,10 +147,13 @@ public:
static int suspend (ACE_hthread_t);
/// Get the priority of a particular thread.
- static int getprio (ACE_hthread_t, int &prio);
+ static int getprio (ACE_hthread_t id, int &priority);
+
+ /// Get the priority and policy of a particular thread.
+ static int getprio (ACE_hthread_t id, int &priority, int &policy);
/// Set the priority of a particular thread.
- static int setprio (ACE_hthread_t, int prio);
+ static int setprio (ACE_hthread_t id, int priority, int policy = -1);
/// Send a signal to the thread.
static int kill (ACE_thread_t, int signum);
diff --git a/ace/Thread.i b/ace/Thread.i
index f678c47b336..0a489f873b9 100644
--- a/ace/Thread.i
+++ b/ace/Thread.i
@@ -10,11 +10,11 @@
ACE_INLINE int
ACE_Thread::keycreate (ACE_thread_key_t *keyp,
#if defined (ACE_HAS_THR_C_DEST)
- ACE_THR_C_DEST destructor,
+ ACE_THR_C_DEST destructor,
#else
- ACE_THR_DEST destructor,
+ ACE_THR_DEST destructor,
#endif /* ACE_HAS_THR_C_DEST */
- void *inst)
+ void *inst)
{
// ACE_TRACE ("ACE_Thread::keycreate");
return ACE_OS::thr_keycreate (keyp, destructor, inst);
@@ -72,25 +72,25 @@ ACE_Thread::yield (void)
ACE_INLINE int
ACE_Thread::spawn (ACE_THR_FUNC func,
- void *arg,
- long flags,
- ACE_thread_t *t_id,
- ACE_hthread_t *t_handle,
- long priority,
- void *thr_stack,
- size_t thr_stack_size,
+ void *arg,
+ long flags,
+ ACE_thread_t *t_id,
+ ACE_hthread_t *t_handle,
+ long priority,
+ void *thr_stack,
+ size_t thr_stack_size,
ACE_Thread_Adapter *thread_adapter)
{
ACE_TRACE ("ACE_Thread::spawn");
return ACE_OS::thr_create (func,
- arg,
- flags,
- t_id,
- t_handle,
- priority,
- thr_stack,
- thr_stack_size,
+ arg,
+ flags,
+ t_id,
+ t_handle,
+ priority,
+ thr_stack,
+ thr_stack_size,
thread_adapter);
}
@@ -117,8 +117,8 @@ ACE_Thread::kill (ACE_thread_t t_id, int signum)
ACE_INLINE int
ACE_Thread::join (ACE_thread_t wait_for,
- ACE_thread_t *departed,
- ACE_THR_FUNC_RETURN *status)
+ ACE_thread_t *departed,
+ ACE_THR_FUNC_RETURN *status)
{
ACE_TRACE ("ACE_Thread::join");
return ACE_OS::thr_join (wait_for, departed, status);
@@ -126,7 +126,7 @@ ACE_Thread::join (ACE_thread_t wait_for,
ACE_INLINE int
ACE_Thread::join (ACE_hthread_t wait_for,
- ACE_THR_FUNC_RETURN *status)
+ ACE_THR_FUNC_RETURN *status)
{
ACE_TRACE ("ACE_Thread::join");
return ACE_OS::thr_join (wait_for, status);
@@ -148,8 +148,8 @@ ACE_Thread::setconcurrency (int new_level)
ACE_INLINE int
ACE_Thread::sigsetmask (int how,
- const sigset_t *sigset,
- sigset_t *osigset)
+ const sigset_t *sigset,
+ sigset_t *osigset)
{
ACE_TRACE ("ACE_Thread::sigsetmask");
return ACE_OS::thr_sigsetmask (how, sigset, osigset);
@@ -175,7 +175,7 @@ ACE_Thread::disablecancel (struct cancel_state *old_state)
ACE_INLINE int
ACE_Thread::enablecancel (struct cancel_state *old_state,
- int flag)
+ int flag)
{
ACE_TRACE ("ACE_Thread::enablecancel");
int old_cstate = 0;
@@ -203,7 +203,7 @@ ACE_Thread::enablecancel (struct cancel_state *old_state,
ACE_INLINE int
ACE_Thread::setcancelstate (struct cancel_state &new_state,
- struct cancel_state *old_state)
+ struct cancel_state *old_state)
{
ACE_TRACE ("ACE_Thread::setcancelstate");
int old_cstate = 0;
@@ -211,17 +211,17 @@ ACE_Thread::setcancelstate (struct cancel_state &new_state,
if (new_state.cancelstate != 0
&& ACE_OS::thr_setcancelstate (new_state.cancelstate,
- &old_cstate) != 0)
+ &old_cstate) != 0)
return -1;
if (new_state.canceltype != 0
&& ACE_OS::thr_setcanceltype (new_state.canceltype,
- &old_ctype) != 0)
+ &old_ctype) != 0)
{
int o_cstate;
ACE_OS::thr_setcancelstate (old_cstate,
- &o_cstate);
+ &o_cstate);
return -1;
}
@@ -258,15 +258,22 @@ ACE_Thread::self (ACE_hthread_t &t_id)
}
ACE_INLINE int
-ACE_Thread::getprio (ACE_hthread_t t_id, int &prio)
+ACE_Thread::getprio (ACE_hthread_t id, int &priority)
{
ACE_TRACE ("ACE_Thread::getprio");
- return ACE_OS::thr_getprio (t_id, prio);
+ return ACE_OS::thr_getprio (id, priority);
}
ACE_INLINE int
-ACE_Thread::setprio (ACE_hthread_t t_id, int prio)
+ACE_Thread::getprio (ACE_hthread_t id, int &priority, int &policy)
+{
+ ACE_TRACE ("ACE_Thread::getprio");
+ return ACE_OS::thr_getprio (id, priority, policy);
+}
+
+ACE_INLINE int
+ACE_Thread::setprio (ACE_hthread_t id, int priority, int policy)
{
ACE_TRACE ("ACE_Thread::setprio");
- return ACE_OS::thr_setprio (t_id, prio);
+ return ACE_OS::thr_setprio (id, priority, policy);
}