diff options
Diffstat (limited to 'ACE/ace/Sched_Params.cpp')
-rw-r--r-- | ACE/ace/Sched_Params.cpp | 137 |
1 files changed, 10 insertions, 127 deletions
diff --git a/ACE/ace/Sched_Params.cpp b/ACE/ace/Sched_Params.cpp index 8f63c093432..409e7120ac5 100644 --- a/ACE/ace/Sched_Params.cpp +++ b/ACE/ace/Sched_Params.cpp @@ -13,73 +13,13 @@ #include "ace/Sched_Params.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) -# include "ace/OS_NS_string.h" -# include /**/ <sys/priocntl.h> -#endif /* ACE_HAS_PRIOCNTL && ACE_HAS_THREADS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_Sched_Params::priority_min (const Policy policy, const int scope) { -#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (scope); - - // Assume that ACE_SCHED_OTHER indicates TS class, and that other - // policies indicate RT class. - - // Call ACE_OS::priority_control only for processes (lightweight - // or otherwise). Calling ACE_OS::priority_control for thread - // priorities gives incorrect results. - if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP) - { - if (policy == ACE_SCHED_OTHER) - { - // Get the priority class ID and attributes. - pcinfo_t pcinfo; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); - ACE_OS::strcpy (pcinfo.pc_clname, "TS"); - - if (ACE_OS::priority_control (P_ALL /* ignored */, - P_MYID /* ignored */, - PC_GETCID, - (char *) &pcinfo) == -1) - // Just hope that priority range wasn't configured from -1 - // .. 1 - return -1; - - // OK, now we've got the class ID in pcinfo.pc_cid. In - // addition, the maximum configured time-share priority is in - // ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri. The minimum - // priority is just the negative of that. - - return -((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri; - } - else - return 0; - } - else - { - // Here we handle the case for ACE_SCOPE_THREAD. Calling - // ACE_OS::priority_control for thread scope gives incorrect - // results. - switch (policy) - { - case ACE_SCHED_FIFO: - return ACE_THR_PRI_FIFO_MIN; - case ACE_SCHED_RR: - return ACE_THR_PRI_RR_MIN; - case ACE_SCHED_OTHER: - default: - return ACE_THR_PRI_OTHER_MIN; - } - } -#elif defined(ACE_HAS_PTHREADS) && \ - (!defined(ACE_LACKS_SETSCHED)) +#if defined(ACE_HAS_PTHREADS) && !defined(ACE_LACKS_SETSCHED) switch (scope) { case ACE_SCOPE_THREAD: @@ -108,14 +48,10 @@ ACE_Sched_Params::priority_min (const Policy policy, } } -#elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE) +#elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); return THREAD_PRIORITY_IDLE; -#elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (policy); - ACE_UNUSED_ARG (scope); - return 255; #elif defined (ACE_VXWORKS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); @@ -128,63 +64,14 @@ ACE_Sched_Params::priority_min (const Policy policy, ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */ +#endif /* ACE_HAS_PTHREADS */ } int ACE_Sched_Params::priority_max (const Policy policy, const int scope) { -#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (scope); - - // Call ACE_OS::priority_control only for processes (lightweight - // or otherwise). Calling ACE_OS::priority_control for thread - // priorities gives incorrect results. - if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP) - { - // Assume that ACE_SCHED_OTHER indicates TS class, and that other - // policies indicate RT class. - - // Get the priority class ID and attributes. - pcinfo_t pcinfo; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); - ACE_OS::strcpy (pcinfo.pc_clname, - policy == ACE_SCHED_OTHER ? "TS" : "RT"); - - if (ACE_OS::priority_control (P_ALL /* ignored */, - P_MYID /* ignored */, - PC_GETCID, - (char *) &pcinfo) == -1) - return -1; - - // OK, now we've got the class ID in pcinfo.pc_cid. In addition, - // the maximum configured real-time priority is in ((rtinfo_t *) - // pcinfo.pc_clinfo)->rt_maxpri, or similarly for the TS class. - - return policy == ACE_SCHED_OTHER - ? ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri - : ((rtinfo_t *) pcinfo.pc_clinfo)->rt_maxpri; - } - else - { - // Here we handle the case for ACE_SCOPE_THREAD. Calling - // ACE_OS::priority_control for thread scope gives incorrect - // results. - switch (policy) - { - case ACE_SCHED_FIFO: - return ACE_THR_PRI_FIFO_MAX; - case ACE_SCHED_RR: - return ACE_THR_PRI_RR_MAX; - case ACE_SCHED_OTHER: - default: - return ACE_THR_PRI_OTHER_MAX; - } - } -#elif defined(ACE_HAS_PTHREADS) && \ +#if defined(ACE_HAS_PTHREADS) && \ (!defined(ACE_LACKS_SETSCHED) || \ defined (ACE_HAS_PTHREAD_SCHEDPARAM)) @@ -216,14 +103,10 @@ ACE_Sched_Params::priority_max (const Policy policy, } } -#elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE) +#elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); return THREAD_PRIORITY_TIME_CRITICAL; -#elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (policy); - ACE_UNUSED_ARG (scope); - return 0; #elif defined (ACE_VXWORKS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); @@ -236,7 +119,7 @@ ACE_Sched_Params::priority_max (const Policy policy, ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */ +#endif /* ACE_HAS_PTHREADS */ } int @@ -244,7 +127,7 @@ ACE_Sched_Params::next_priority (const Policy policy, const int priority, const int scope) { -#if defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE) +#if defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); switch (priority) @@ -272,7 +155,7 @@ ACE_Sched_Params::next_priority (const Policy policy, // including STHREADS, and PTHREADS int const max = priority_max (policy, scope); return priority < max ? priority + 1 : max; -#elif defined (ACE_VXWORKS) || defined (ACE_HAS_WINCE) +#elif defined (ACE_VXWORKS) int const max = priority_max (policy, scope); return priority > max ? priority - 1 : max; #else @@ -288,7 +171,7 @@ ACE_Sched_Params::previous_priority (const Policy policy, const int priority, const int scope) { -#if defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE) +#if defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (policy); ACE_UNUSED_ARG (scope); switch (priority) @@ -316,7 +199,7 @@ ACE_Sched_Params::previous_priority (const Policy policy, // including STHREADS and PTHREADS int const min = priority_min (policy, scope); return priority > min ? priority - 1 : min; -#elif defined (ACE_VXWORKS) || defined (ACE_HAS_WINCE) +#elif defined (ACE_VXWORKS) int const min = priority_min (policy, scope); return priority < min ? priority + 1 : min; #else |