From e490c2bc24c56d0b2c815bb0704163cbee95cf16 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 10 Jul 2002 22:58:01 +0000 Subject: [PATCH] take advantage off additional priority levels when running with a real time priority class --- src/libCom/osi/os/WIN32/osdThread.c | 133 ++++++++++++++++++---------- 1 file changed, 85 insertions(+), 48 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 3506b6715..c67599c81 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -50,35 +50,33 @@ typedef struct epicsThreadPrivateOSD { static HANDLE win32ThreadGlobalMutex = 0; static int win32ThreadInitOK = 0; -#if WINVER >= 500 && 0 -# define osdPriorityStateCount 14u -#else -# define osdPriorityStateCount 5u -#endif -// -// apparently these additional priorities only work if the process -// priority class is real time? -// -static const int osdPriorityList [osdPriorityStateCount] = +#define osdOrdinaryPriorityStateCount 5u +static const int osdOrdinaryPriorityList [osdOrdinaryPriorityStateCount] = { -#if WINVER >= 500 && 0 - -7, // allowed on >= W2k, but no #define supplied - -6, // allowed on >= W2k, but no #define supplied - -5, // allowed on >= W2k, but no #define supplied - -4, // allowed on >= W2k, but no #define supplied - -3, // allowed on >= W2k, but no #define supplied -#endif THREAD_PRIORITY_LOWEST, // -2 on >= W2K ??? on W95 THREAD_PRIORITY_BELOW_NORMAL, // -1 on >= W2K ??? on W95 THREAD_PRIORITY_NORMAL, // 0 on >= W2K ??? on W95 THREAD_PRIORITY_ABOVE_NORMAL, // 1 on >= W2K ??? on W95 THREAD_PRIORITY_HIGHEST // 2 on >= W2K ??? on W95 -#if WINVER >= 500 && 0 +}; + +# define osdRealtimePriorityStateCount 14u +static const int osdRealtimePriorityList [osdRealtimePriorityStateCount] = +{ + -7, // allowed on >= W2k, but no #define supplied + -6, // allowed on >= W2k, but no #define supplied + -5, // allowed on >= W2k, but no #define supplied + -4, // allowed on >= W2k, but no #define supplied + -3, // allowed on >= W2k, but no #define supplied + THREAD_PRIORITY_LOWEST, // -2 on >= W2K ??? on W95 + THREAD_PRIORITY_BELOW_NORMAL, // -1 on >= W2K ??? on W95 + THREAD_PRIORITY_NORMAL, // 0 on >= W2K ??? on W95 + THREAD_PRIORITY_ABOVE_NORMAL, // 1 on >= W2K ??? on W95 + THREAD_PRIORITY_HIGHEST, // 2 on >= W2K ??? on W95 3, // allowed on >= W2k, but no #define supplied 4, // allowed on >= W2k, but no #define supplied 5, // allowed on >= W2k, but no #define supplied 6 // allowed on >= W2k, but no #define supplied -#endif }; static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) @@ -139,7 +137,7 @@ epicsShareFunc void epicsShareAPI epicsThreadExitMain ( void ) /* * osdPriorityMagFromPriorityOSI () */ -static unsigned osdPriorityMagFromPriorityOSI ( unsigned osiPriority ) +static unsigned osdPriorityMagFromPriorityOSI ( unsigned osiPriority, unsigned priorityStateCount ) { unsigned magnitude; @@ -153,7 +151,7 @@ static unsigned osdPriorityMagFromPriorityOSI ( unsigned osiPriority ) osiPriority = epicsThreadPriorityMax; } - magnitude = osiPriority * osdPriorityStateCount; + magnitude = osiPriority * priorityStateCount; magnitude /= ( epicsThreadPriorityMax - epicsThreadPriorityMin ) + 1; return magnitude; @@ -164,32 +162,28 @@ static unsigned osdPriorityMagFromPriorityOSI ( unsigned osiPriority ) */ static int epicsThreadGetOsdPriorityValue ( unsigned osiPriority ) { - unsigned magnitude = osdPriorityMagFromPriorityOSI ( osiPriority ); - return osdPriorityList[magnitude]; -} - -/* - * osdPriorityMagFromPriorityOSI () - */ -static unsigned osdPriorityMagFromPriorityOSD ( int osdPriority ) -{ + const DWORD priorityClass = GetPriorityClass ( GetCurrentProcess () ); + const unsigned * pStateList; + unsigned stateCount; unsigned magnitude; - for ( magnitude=0u; magnitude 1u ) { - *pPriorityJustBelow = osiPriorityMagFromMagnitueOSD ( magnitude - 1u ); + *pPriorityJustBelow = osiPriorityMagFromMagnitueOSD ( magnitude - 1u, stateCount ); status = epicsThreadBooleanStatusSuccess; } else {