diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-29 04:01:33 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-29 04:01:33 +0000 |
commit | 45f6114ba2581a7d1dec2bd8a9b84aeb876e052a (patch) | |
tree | 0680ad1b72afefe67e5c973324783b5553f32e11 | |
parent | c01e57bb9e0e5e2e88bb885d24aa7b56bf0e0660 (diff) | |
download | ATCD-45f6114ba2581a7d1dec2bd8a9b84aeb876e052a.tar.gz |
added ACE_OS::set_sched_params (), and ACE_Scheduling_Parameters and ACE_Thread_Priority classes
-rw-r--r-- | ChangeLog-97a | 10 | ||||
-rw-r--r-- | ace/OS.cpp | 93 | ||||
-rw-r--r-- | ace/OS.h | 24 | ||||
-rw-r--r-- | ace/Sched_Params.cpp | 34 | ||||
-rw-r--r-- | ace/Sched_Params.h | 77 | ||||
-rw-r--r-- | ace/Sched_Params.i | 72 | ||||
-rw-r--r-- | ace/Thread_Priority.cpp | 266 | ||||
-rw-r--r-- | ace/Thread_Priority.h | 113 | ||||
-rw-r--r-- | ace/Thread_Priority.i | 82 |
9 files changed, 771 insertions, 0 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a index ac2c45b1c0d..c3c00808b76 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,3 +1,13 @@ +Tue Jan 28 21:57:45 1997 David L. Levine <levine@cs.wustl.edu> + + * ace/OS.{h,cpp}: added ACE_OS::set_sched_params (). It permits + platform-independent setting of thread priorities and priority + classes. It is currently supported on Solaris, Win32, and VxWorks. + + * ace/Scheduling_Parameters.{h,i,cpp}, + ace/Thread_Priority.{h,i,cpp}, ace/Makefile: + Added these two classes to support ACE_OS::set_sched_params (). + Tue Jan 28 16:49:44 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * ace/OS.i (thr_setprio): Fixed a typo that was left over from a diff --git a/ace/OS.cpp b/ace/OS.cpp index 0f378aaed9a..53063b2a271 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -3,6 +3,7 @@ // OS.cpp #define ACE_BUILD_DLL #include "ace/OS.h" +#include "ace/Scheduling_Params.h" #if defined (ACE_WIN32) #include "ace/ARGV.h" @@ -448,6 +449,98 @@ ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...) #endif /* ACE_WIN32 */ } +#if defined (ACE_HAS_STHREADS) +#include <sys/rtpriocntl.h> +#include <sys/tspriocntl.h> +#endif /* ACE_HAS_STHREADS */ + +int +ACE_OS::set_sched_params (const ACE_Scheduling_Params &scheduling_params) +{ + // ACE_TRACE ("ACE_OS::set_sched_params"); +#if defined (ACE_HAS_STHREADS) + // Set priority class, priority, and quantum of this LWP or process as + // specified in scheduling_params. + + pcparms_t pcparms; + pcparms.pc_cid = scheduling_params.priority ().os_priority_class (); + + if (scheduling_params.priority ().priority_class () == + ACE_Thread_Priority::ACE_HIGH_PRIORITY_CLASS || + scheduling_params.priority ().priority_class () == + ACE_Thread_Priority::ACE_REALTIME_PRIORITY_CLASS) + { + rtparms_t rtparms; + rtparms.rt_pri = + scheduling_params.priority ().os_default_thread_priority (); + if (scheduling_params.quantum () == ACE_Time_Value::zero) + { + rtparms.rt_tqsecs = 0ul; + rtparms.rt_tqnsecs = RT_TQINF; + } + else + { + rtparms.rt_tqsecs = (ulong) scheduling_params.quantum ().sec (); + rtparms.rt_tqnsecs = scheduling_params.quantum ().usec () * 1000; + } + + // Package up the RT class ID and parameters for the ::priocntl () call. + ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms); + } + else + { + tsparms_t tsparms; + // Don't bother changing ts_uprilim (user priority limit) from its + // default of 0. + tsparms.ts_uprilim = 0; + tsparms.ts_upri = + scheduling_params.priority ().os_default_thread_priority (); + + // Package up the TS class ID and parameters for the ::priocntl () call. + ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms); + } + + if (::priocntl ((idtype_t) scheduling_params.scope (), P_MYID, PC_SETPARMS, + (char *) &pcparms) < 0) + { + return ACE_OS::last_error (); + } + +#elif defined (ACE_WIN32) + // Set the priority class of this process to the real-time process class. + if (! ::SetPriorityClass (::GetCurrentProcess (), + scheduling_params.priority ().os_priority_class ()) + { + return -1; + } + + // Set the thread priority on the current thread. + if (! ::SetThreadPriority ( + ::GetCurrentThread (), + scheduling_params.priority ().os_default_thread_priority ()) + { + return -1; + } + + +#elif defined (VXWORKS) + // There is only one class of priorities on VxWorks, and no + // time quanta. So, just set the current thread's priority. + + ACE_htread_t my_thread_id; + ACE_OS::thr_self (&my_thread_id); + ACE_OS::thr_setprio ( + my_thread_id, + scheduling_params.priority ().os_default_thread_priority ()); + + +#else + ACE_NOTSUP_RETURN (ENOTSUP); +#endif /* ACE_HAS_STHREADS */ + + return 0; +} + // = Static initialization. // This is necessary to deal with POSIX pthreads insanity. This @@ -810,6 +810,11 @@ struct cancel_state #if defined (ACE_HAS_STHREADS) #include /**/ <synch.h> #include /**/ <thread.h> +#define ACE_SCOPE_PROCESS P_PID +#define ACE_SCOPE_LWP P_LWPID +#else +#define ACE_SCOPE_PROCESS 0 +#define ACE_SCOPE_LWP 1 #endif /* ACE_HAS_STHREADS */ #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) @@ -955,6 +960,11 @@ struct ACE_sema_t }; #endif /* !ACE_HAS_POSIX_SEM */ +#if !defined (VXWORKS) && !defined (ACE_WIN32) +typedef short ACE_id_t; +typedef short ACE_pri_t; +#endif /* ! VXWORKS) && ! ACE_WIN32 */ + #else // If we are on Solaris we can just reuse the existing implementations // of these synchronization types. @@ -962,6 +972,9 @@ typedef rwlock_t ACE_rwlock_t; #if !defined (ACE_HAS_POSIX_SEM) typedef sema_t ACE_sema_t; #endif /* !ACE_HAS_POSIX_SEM */ +#include <sys/priocntl.h> +typedef id_t ACE_id_t; +typedef pri_t ACE_pri_t; #endif /* !ACE_HAS_STHREADS */ #elif defined (ACE_HAS_STHREADS) // Typedefs to help compatibility with Windows NT and Pthreads. @@ -1020,6 +1033,8 @@ typedef semaphore * ACE_sema_t; typedef char * ACE_thread_t; typedef int ACE_hthread_t; typedef int ACE_thread_key_t; +typedef short ACE_id_t; +typedef short ACE_pri_t; #elif defined (ACE_HAS_WTHREADS) typedef CRITICAL_SECTION ACE_thread_mutex_t; @@ -1512,6 +1527,9 @@ struct iovec size_t iov_len; // byte count to read/write }; +typedef DWORD ACE_id_t; +typedef DWORD ACE_pri_t; + #else /* !defined (ACE_WIN32) */ // We're some kind of UNIX... @@ -2191,6 +2209,9 @@ extern "C" int _xti_error(char *); #endif /* UNIXWARE */ #endif /* ACE_REDEFINES_XTI_FUNCTIONS */ +// forward declaration +class ACE_Scheduling_Params; + class ACE_Export ACE_OS // = TITLE // This class defines an operating system independent @@ -2477,6 +2498,9 @@ public: static int semget (key_t key, int nsems, int flags); static int semop (int int_id, struct sembuf *sops, size_t nsops); + // = Thread scheduler interface. + static int set_sched_params (const ACE_Scheduling_Params &); + // = A set of wrappers for System V shared memory. static void *shmat (int int_id, void *shmaddr, int shmflg); static int shmctl (int int_id, int cmd, struct shmid_ds *buf); diff --git a/ace/Sched_Params.cpp b/ace/Sched_Params.cpp new file mode 100644 index 00000000000..afdf0d61937 --- /dev/null +++ b/ace/Sched_Params.cpp @@ -0,0 +1,34 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Scheduling_Params.cpp +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +#include "ace/ACE.h" + +#if defined (ACE_HAS_THREADS) + + +#include "ace/Scheduling_Params.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Scheduling_Params.i" +#endif /* __ACE_INLINE__ */ + + +#endif /* ACE_HAS_THREADS */ + + +// EOF diff --git a/ace/Sched_Params.h b/ace/Sched_Params.h new file mode 100644 index 00000000000..b4936b769dc --- /dev/null +++ b/ace/Sched_Params.h @@ -0,0 +1,77 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Scheduling_Params.h +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +#if ! defined (SCHEDULING_PARAMS_H) +#define SCHEDULING_PARAMS_H + +#include "ace/Thread_Priority.h" +#include "ace/OS.h" // for ACE_Time_Value and ACE_SCOPE_PROCESS + +class ACE_Scheduling_Params +{ +public: + ACE_Scheduling_Params ( + const ACE_Thread_Priority &priority = ACE_Thread_Priority (), + const int scope = ACE_SCOPE_PROCESS, + const ACE_Time_Value &quantum = ACE_Time_Value::zero); + // default priority: sets the priority to be used for newly spawned threads. + // It is intended that this function be called from main () before + // any threads have been spawned. If spawned threads inherit their + // parent's priority (I think that's the case for all of our platforms), + // then this sets the default base priority. Individual thread + // priorities can be adjusted as usual. + // + // "scope" must be either ACE_SCOPE_PROCESS or ACE_SCOPE_LWP (which is + // only used on Solaris, and ignored on Win32 and VxWorks) + // + // The "quantum" is for time slicing. An ACE_Time_Value of 0 has + // special significance: it means time-slicing is disabled; with + // that, a thread that is running on a CPU will continue to run until + // it blocks or is preempted. Currently ignored if the OS doesn't + // directly support time slicing, such as on VxWorks, or setting the + // quantum (can that be done on Win32?). + + ~ACE_Scheduling_Params (); + + // get/set accessors: + + const ACE_Thread_Priority &priority () const; + void set_priority (const ACE_Thread_Priority &); + + int scope () const; + void set_scope(const int); + + const ACE_Time_Value &quantum () const; + void set_quantum (const ACE_Time_Value &); + +private: + ACE_Thread_Priority priority_; + int scope_; + ACE_Time_Value quantum_; +}; + + +#if defined (__ACE_INLINE__) +#include "ace/Scheduling_Params.i" +#endif /* __ACE_INLINE__ */ + +#endif /* SCHEDULING_PARAMS_H */ + + +// EOF diff --git a/ace/Sched_Params.i b/ace/Sched_Params.i new file mode 100644 index 00000000000..95ad74c0ec7 --- /dev/null +++ b/ace/Sched_Params.i @@ -0,0 +1,72 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Scheduling_Params.i +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +ACE_INLINE +ACE_Scheduling_Params::ACE_Scheduling_Params ( + const ACE_Thread_Priority &priority, + const int scope, + const ACE_Time_Value &quantum) : + priority_ (priority), + scope_ (scope), + quantum_ (quantum) +{ +} + +ACE_INLINE +ACE_Scheduling_Params::~ACE_Scheduling_Params () +{ +} + +ACE_INLINE +const ACE_Thread_Priority & +ACE_Scheduling_Params::priority () const +{ + return priority_; +} + +ACE_INLINE +int +ACE_Scheduling_Params::scope () const +{ + return scope_; +} + +ACE_INLINE +void +ACE_Scheduling_Params::set_scope (const int scope) +{ + scope_ = scope; +} + +ACE_INLINE +const ACE_Time_Value & +ACE_Scheduling_Params::quantum () const +{ + return quantum_; +} + +ACE_INLINE +void +ACE_Scheduling_Params::set_quantum (const ACE_Time_Value &quantum) +{ + quantum_ = quantum; +} + + +// EOF diff --git a/ace/Thread_Priority.cpp b/ace/Thread_Priority.cpp new file mode 100644 index 00000000000..5d6d24c4bdb --- /dev/null +++ b/ace/Thread_Priority.cpp @@ -0,0 +1,266 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Thread_Priority.cpp +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +#include "ace/ACE.h" + +#if defined (ACE_HAS_THREADS) + +#include "ace/Thread_Priority.h" +#include "ace/OS.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Thread_Priority.i" +#endif /* __ACE_INLINE__ */ + + +#if defined (ACE_HAS_STHREADS) +#include <sys/priocntl.h> +#include <sys/rtpriocntl.h> +#include <sys/tspriocntl.h> + +/* mapping of + ACE_Thread_Priority:: to Solaris + Priority_Class Thread_Priority class priority + ============== =============== ===== ======== + ACE_LOW_PRIORITY_CLASS 0 .. 6 TS 0 .. 6 + ACE_NORMAL_PRIORITY_CLASS 0 .. 6 TS 7 .. 13 + ACE_HIGH_PRIORITY_CLASS 0 .. 6 RT 0 .. 6 + ACE_REALTIME_PRIORITY_CLASS 0 .. 6 RT 7 .. 13 + */ + +long +ACE_Thread_Priority::normalize () +{ + // Get the priority class ID and attributes. + pcinfo_t pcinfo; + ACE_OS::strcpy (pcinfo.pc_clname, + priority_class_ == ACE_HIGH_PRIORITY_CLASS || + priority_class_ == ACE_REALTIME_PRIORITY_CLASS + ? "RT" + : "TS"); + + if (::priocntl (P_ALL /* ignored */, P_MYID /* ignored */, PC_GETCID, + (char *) &pcinfo) < 0) + { + 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. + + os_priority_class_ = pcinfo.pc_cid; + + if (ACE_PRIORITY_MIN <= default_thread_priority_ && + default_thread_priority_ <= ACE_PRIORITY_MAX) + { + os_default_thread_priority_ = + priority_class_ == ACE_NORMAL_PRIORITY_CLASS || + priority_class_ == ACE_REALTIME_PRIORITY_CLASS + ? default_thread_priority_ + 7 + : default_thread_priority_; + } + else + { + // The user specified a thread priority outside the enum range, so + // use it without modification. + os_default_thread_priority_ = default_thread_priority_; + } + + return 0; +} + + +#elif defined (ACE_WIN32) + +/* mapping of + ACE_Thread_Priority:: to Win32 + Priority_Class Thread_Priority class THREAD_PRIORITY_ + ============== =============== ===== ================ + ACE_LOW_PRIORITY_CLASS 0 .. 6 IDLE_... IDLE... + TIME_CRITICAL + ACE_NORMAL_PRIORITY_CLASS 0 .. 6 NORMAL_... "" + ACE_HIGH_PRIORITY_CLASS 0 .. 6 HIGH_... "" + ACE_REALTIME_PRIORITY_CLASS 0 .. 6 REALTIME_... "" + */ + +long +ACE_Thread_Priority::normalize () +{ + switch (priority_class) + { + case ACE_LOW_PRIORITY_CLASS : + os_priority_class_ = IDLE_PRIORITY_CLASS; + break; + case ACE_NORMAL_PRIORITY_CLASS : + os_priority_class_ = NORMAL_PRIORITY_CLASS; + break; + case ACE_HIGH_PRIORITY_CLASS : + os_priority_class_ = HIGH_PRIORITY_CLASS; + break; + case ACE_REALTIME_PRIORITY_CLASS : + os_priority_class_ = REALTIME_PRIORITY_CLASS; + break; + } + + if (ACE_PRIORITY_MIN <= default_thread_priority_ && + default_thread_priority_ <= ACE_PRIORITY_MAX) + { + switch (default_thread_priority_) + { + case ACE_PRIORITY_0 : + os_default_thread_priority_ = THREAD_PRIORITY_IDLE; + break; + case ACE_PRIORITY_1 : + os_default_thread_priority_ = THREAD_PRIORITY_LOWEST; + break; + case ACE_PRIORITY_2 : + os_default_thread_priority_ = THREAD_PRIORITY_BELOW_NORMAL; + break; + case ACE_PRIORITY_3 : + os_default_thread_priority_ = THREAD_PRIORITY_NORMAL; + break; + case ACE_PRIORITY_4 : + os_default_thread_priority_ = THREAD_PRIORITY_ABOVE_NORMAL; + break; + case ACE_PRIORITY_5 : + os_default_thread_priority_ = THREAD_PRIORITY_HIGHEST; + break; + case ACE_PRIORITY_6 : + os_default_thread_priority_ = THREAD_PRIORITY_TIME_CRITICAL; + break; + } + } + else + { + // The user specified a thread priority outside the enum range, so + // use it without modification. The user had better know what they're + // doing on Win32 platforms. + os_default_thread_priority_ = default_thread_priority_; + } + + return 0; +} + + +#elif defined (VXWORKS) + +/* mapping of + ACE_Thread_Priority:: to VxWorks + Priority_Class Thread_Priority class priority + ============== =============== ===== ======== + ACE_LOW_PRIORITY_CLASS 0 .. 6 N/A 27 .. 21 + ACE_NORMAL_PRIORITY_CLASS 0 .. 6 N/A 20 .. 14 + ACE_HIGH_PRIORITY_CLASS 0 .. 6 N/A 13 .. 7 + ACE_REALTIME_PRIORITY_CLASS 0 .. 6 N/A 6 .. 0 + */ + +long +ACE_Thread_Priority::normalize () +{ + os_priority_class_ = -1; /* unused on this platform */ + + if (ACE_PRIORITY_MIN <= default_thread_priority_ && + default_thread_priority_ <= ACE_PRIORITY_MAX) + { + switch (priority_class) + { + case ACE_LOW_PRIORITY_CLASS : + os_default_thread_priority_ = ACE_PRIORITY_MAX - + default_thread_priority_ + 21; + break; + case ACE_NORMAL_PRIORITY_CLASS : + os_default_thread_priority_ = ACE_PRIORITY_MAX - + default_thread_priority_ + 14; + break; + case ACE_HIGH_PRIORITY_CLASS : + os_default_thread_priority_ = ACE_PRIORITY_MAX - + default_thread_priority_ + 7; + break; + case ACE_REALTIME_PRIORITY_CLASS : + os_default_thread_priority_ = ACE_PRIORITY_MAX - + default_thread_priority_; + break; + } + } + else + { + // The user specified a thread priority outside the enum range, so + // use it without modification. + os_default_thread_priority_ = default_thread_priority_; + } + + return 0; +} + + +#else + +/* mapping of + ACE_Thread_Priority:: to VxWorks + Priority_Class Thread_Priority class priority + ============== =============== ===== ======== + ACE_LOW_PRIORITY_CLASS 0 .. 6 N/A 0 .. 6 + ACE_NORMAL_PRIORITY_CLASS 0 .. 6 N/A 7 .. 13 + ACE_HIGH_PRIORITY_CLASS 0 .. 6 N/A 14 .. 20 + ACE_REALTIME_PRIORITY_CLASS 0 .. 6 N/A 21 .. 27 + */ + +// assumes that priority increases with increasing ACE_pri_t value +long +ACE_Thread_Priority::normalize () +{ + os_priority_class_ = -1; /* unused on this platform */ + + if (ACE_PRIORITY_MIN <= default_thread_priority_ && + default_thread_priority_ <= ACE_PRIORITY_MAX) + { + switch (priority_class) + { + case ACE_LOW_PRIORITY_CLASS : + os_default_thread_priority_ = default_thread_priority_; + break; + case ACE_NORMAL_PRIORITY_CLASS : + os_default_thread_priority_ = default_thread_priority_ + 7; + break; + case ACE_HIGH_PRIORITY_CLASS : + os_default_thread_priority_ = default_thread_priority_ + 14; + break; + case ACE_REALTIME_PRIORITY_CLASS : + os_default_thread_priority_ = default_thread_priority_ + 21; + break; + } + } + else + { + // The user specified a thread priority outside the enum range, so + // use it without modification. + os_default_thread_priority_ = default_thread_priority_; + } + + return 0; +} + + +#endif /* ACE_HAS_STHREADS */ + + +#endif /* ACE_HAS_THREADS */ + + +// EOF diff --git a/ace/Thread_Priority.h b/ace/Thread_Priority.h new file mode 100644 index 00000000000..a3f20b3f653 --- /dev/null +++ b/ace/Thread_Priority.h @@ -0,0 +1,113 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Thread_Priority.h +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +#if ! defined (THREAD_PRIORITY_H) +#define THREAD_PRIORITY_H + +class ACE_Thread_Priority +{ +public: + enum Priority_Class + { + ACE_LOW_PRIORITY_CLASS, + ACE_NORMAL_PRIORITY_CLASS, + ACE_HIGH_PRIORITY_CLASS, + ACE_REALTIME_PRIORITY_CLASS + }; + + enum Thread_Priority + { + ACE_PRIORITY_0 = 0, + ACE_PRIORITY_MIN = ACE_PRIORITY_0, + ACE_PRIORITY_1, + ACE_PRIORITY_2, + ACE_PRIORITY_3, + ACE_PRIORITY_4, + ACE_PRIORITY_5, + ACE_PRIORITY_6, + ACE_PRIORITY_MAX = ACE_PRIORITY_6 + }; + // This enum is provided to help users create OS-independent priorities + // (but see the NOTE below). For applications that don't require OS- + // independence, they can take advantage of a greater range of thread + // priorities offered by their platform. This can be done by casting + // the OS-dependent priority to ACE_Thread_Priority::Thread_Priority + // when calling the member functions that take it as an argument. + // In other words, this class will not "break" if a Thread_Priority + // outside of [ACE_PRIORITY_MIN .. ACE_PRIORITY_MAX] is used. + // + // NOTE: the following distinct ACE_Thread_Priority combinations map to + // identical priority class/thread priority combinations on Win32. They + // may map to distinct priorities on other platforms. So, if OS-independent + // behavior is desired, applications should not depend on these having + // either the same or different OS priorities: + // * ACE_LOW_PRIORITY_CLASS/ACE_PRIORITY_0 == + // ACE_NORMAL_PRIORITY_CLASS/ACE_PRIORITY_0 == + // ACE_HIGH_PRIORITY_CLASS/ACE_PRIORITY_0 + // * ACE_NORMAL_PRIORITY_CLASS/ACE_PRIORITY_5 == + // ACE_HIGH_PRIORITY_CLASS/ACE_PRIORITY_1 + // * ACE_LOW_PRIORITY_CLASS/ACE_PRIORITY_6 == + // ACE_NORMAL_PRIORITY_CLASS/ACE_PRIORITY_6 == + // ACE_HIGH_PRIORITY_CLASS/ACE_PRIORITY_5 == + // ACE_HIGH_PRIORITY_CLASS/ACE_PRIORITY_6 + + ACE_Thread_Priority ( + Priority_Class priority_class = ACE_NORMAL_PRIORITY_CLASS, + Thread_Priority default_thread_priority = ACE_PRIORITY_MIN); + // There can be more than one ACE_Thread_Priority instance per process, + // e.g., one per Solaris Lightweight Process. + + ~ACE_Thread_Priority (); + + long set_priority_class (const Priority_Class); + long set_default_thread_priority (const Thread_Priority); + // set accessors: return 0 on success and -1 on failure (and set errno) + + Priority_Class priority_class () const; + Thread_Priority default_thread_priority () const; + // get accessors for OS-independent values + + ACE_id_t os_priority_class () const; + // get accessor for the OS-specific priority class + + ACE_pri_t os_default_thread_priority () const; + // get accessor for the numeric default thread priority value, which + // is OS-dependent + +private: + Priority_Class priority_class_; + Thread_Priority default_thread_priority_; + + ACE_id_t os_priority_class_; + ACE_pri_t os_default_thread_priority_; + + // for internal use, to convert OS-dependent priorities into + // OS-independent priorities. + long normalize (); +}; + + +#if defined (__ACE_INLINE__) +#include "ace/Thread_Priority.i" +#endif /* __ACE_INLINE__ */ + +#endif /* THREAD_PRIORITY_H */ + + +// EOF diff --git a/ace/Thread_Priority.i b/ace/Thread_Priority.i new file mode 100644 index 00000000000..e22ae865d8a --- /dev/null +++ b/ace/Thread_Priority.i @@ -0,0 +1,82 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE +// +// = FILENAME +// Thread_Priority.i +// +// = CREATION DATE +// 28 January 1997 +// +// = AUTHOR +// David Levine +// +// ============================================================================ + +ACE_INLINE +ACE_Thread_Priority::ACE_Thread_Priority ( + Priority_Class priority_class, + Thread_Priority default_thread_priority) : + priority_class_ (priority_class), + default_thread_priority_ (default_thread_priority) +{ + // normalize () sets os_priority_class_ and os_default_thread_priority_ + (void) normalize (); +} + +ACE_INLINE +ACE_Thread_Priority::~ACE_Thread_Priority () +{ +} + +ACE_INLINE +long +ACE_Thread_Priority::set_priority_class (const Priority_Class priority_class) +{ + priority_class_ = priority_class; + return normalize (); +} + +ACE_INLINE +long +ACE_Thread_Priority::set_default_thread_priority ( + const Thread_Priority default_thread_priority) +{ + default_thread_priority_ = default_thread_priority; + return normalize (); +} + +ACE_INLINE +ACE_Thread_Priority::Priority_Class +ACE_Thread_Priority::priority_class () const +{ + return priority_class_; +} + +ACE_INLINE +ACE_Thread_Priority::Thread_Priority +ACE_Thread_Priority::default_thread_priority () const +{ + return default_thread_priority_; +} + +ACE_INLINE +ACE_id_t +ACE_Thread_Priority::os_priority_class () const +{ + return os_priority_class_; +} + +ACE_INLINE +ACE_pri_t +ACE_Thread_Priority::os_default_thread_priority () const +{ + return os_default_thread_priority_; +} + + +// EOF |