Changeset 9938 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Mar 26, 2003, 5:02:33 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r9911 r9938 1 /* $Id: HandleManager.cpp,v 1.9 5 2003-03-06 10:44:32sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.96 2003-03-26 16:02:33 sandervl Exp $ */ 2 2 3 3 /* … … 2069 2069 //To avoid this problem, we temporarily switch to time critical priority. 2070 2070 HANDLE hThread = GetCurrentThread(); 2071 DWORD dwThreadPriority = GetThreadPriority(hThread); 2072 2073 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 2074 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 2075 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 2076 //round to 8 ms units to get more precise timeouts 2077 if(dwTimeout > 8) 2078 dwTimeout = (dwTimeout/8)*8; 2079 } 2080 else dwThreadPriority = -1; 2071 BOOL fChangePriority = FALSE; 2072 DWORD dwThreadPriority; 2073 2074 if(dwTimeout && dwTimeout < 20) { 2075 dwThreadPriority = GetThreadPriority(hThread); 2076 if(dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) 2077 { 2078 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 2079 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 2080 //round to 8 ms units to get more precise timeouts 2081 if(dwTimeout > 8) 2082 dwTimeout = (dwTimeout/8)*8; 2083 fChangePriority = TRUE; 2084 } 2085 } 2081 2086 2082 2087 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ … … 2085 2090 2086 2091 //Restore thread priority if we previously changed it 2087 if( dwThreadPriority != -1) {2092 if(fChangePriority) { 2088 2093 SetThreadPriority(hThread, dwThreadPriority); 2089 2094 } … … 3006 3011 DWORD dwTimeout) 3007 3012 { 3008 #ifdef USE_OS2SEMAPHORES3009 int iIndex; /* index into the handle table */3010 DWORD dwResult; /* result from the device handler's API */3011 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */3012 3013 if(cObjects == 1) {3014 return HMWaitForSingleObject(*lphObjects, dwTimeout);3015 }3016 3017 if(cObjects > MAXIMUM_WAIT_OBJECTS) {3018 dprintf(("KERNEL32: HMWaitForMultipleObjects: Too many objects (%d)", cObjects));3019 SetLastError(ERROR_INVALID_PARAMETER);3020 return WAIT_FAILED;3021 }3022 3023 /* validate handle */3024 iIndex = _HMHandleQuery(*lphObjects); /* get the index */3025 if (-1 == iIndex) /* error ? */3026 {//oh, oh. possible problem here3027 //TODO: rewrite handling of other handles; don't forward to open323028 dprintf(("WANRING: HMWaitForMultipleObjects: unknown handle passed on to Open32 -> will not work if other handles are semaphores"));3029 return O32_WaitForMultipleObjects(cObjects, lphObjects, fWaitAll, dwTimeout);3030 }3031 3032 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */3033 dwResult = pHMHandle->pDeviceHandler->WaitForMultipleObjects(&pHMHandle->hmHandleData,3034 cObjects, lphObjects, fWaitAll,3035 dwTimeout);3036 3037 return (dwResult); /* deliver return code */3038 #else3039 3013 ULONG ulIndex; 3040 3014 PHANDLE pArrayOfHandles; … … 3089 3063 //To avoid this problem, we temporarily switch to time critical priority. 3090 3064 HANDLE hThread = GetCurrentThread(); 3091 DWORD dwThreadPriority = GetThreadPriority(hThread); 3092 3093 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 3094 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3095 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3096 //round to 8 ms units to get more precise timeouts 3097 if(dwTimeout > 8) 3098 dwTimeout = (dwTimeout/8)*8; 3099 } 3100 else dwThreadPriority = -1; 3065 BOOL fChangePriority = FALSE; 3066 DWORD dwThreadPriority; 3067 3068 if(dwTimeout && dwTimeout < 20) { 3069 dwThreadPriority = GetThreadPriority(hThread); 3070 if(dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) 3071 { 3072 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3073 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3074 //round to 8 ms units to get more precise timeouts 3075 if(dwTimeout > 8) 3076 dwTimeout = (dwTimeout/8)*8; 3077 fChangePriority = TRUE; 3078 } 3079 } 3101 3080 3102 3081 // OK, now forward to Open32. … … 3109 3088 3110 3089 //Restore old thread priority if we changed it before 3111 if( dwThreadPriority != -1) {3090 if(fChangePriority) { 3112 3091 SetThreadPriority(hThread, dwThreadPriority); 3113 3092 } 3114 3093 3115 3094 return (rc); // OK, done 3116 #endif3117 3095 } 3118 3096 … … 3161 3139 DWORD dwWakeMask) 3162 3140 { 3163 #ifdef USE_OS2SEMAPHORES3164 int iIndex; /* index into the handle table */3165 DWORD dwResult; /* result from the device handler's API */3166 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */3167 3168 3169 if(dwWakeMask == 0) {3170 dprintf(("WARNING: wakemask == 0 -> calling WaitForMultipleObjects"));3171 return HMWaitForMultipleObjects(cObjects, lphObjects, fWaitAll, dwTimeout);3172 }3173 /* validate handle */3174 iIndex = _HMHandleQuery(*lphObjects); /* get the index */3175 if (-1 == iIndex) /* error ? */3176 {//oh, oh. possible problem here3177 //TODO: rewrite handling of other handles; don't forward to open323178 dprintf(("WANRING: HMWaitForMultipleObjects: unknown handle passed on to Open32 -> will not work if other handles are semaphores"));3179 return O32_MsgWaitForMultipleObjects(cObjects, lphObjects, fWaitAll, dwTimeout, dwWakeMask);3180 }3181 3182 if(cObjects > MAXIMUM_WAIT_OBJECTS) {3183 dprintf(("KERNEL32: HMMsgWaitForMultipleObjects: Too many objects (%d)", cObjects));3184 SetLastError(ERROR_INVALID_PARAMETER);3185 return WAIT_FAILED;3186 }3187 3188 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */3189 dwResult = pHMHandle->pDeviceHandler->MsgWaitForMultipleObjects(&pHMHandle->hmHandleData,3190 cObjects, lphObjects, fWaitAll,3191 dwTimeout, dwWakeMask);3192 3193 return (dwResult); /* deliver return code */3194 #else3195 3141 ULONG ulIndex; 3196 3142 PHANDLE pArrayOfHandles; … … 3240 3186 //To avoid this problem, we temporarily switch to time critical priority. 3241 3187 HANDLE hThread = GetCurrentThread(); 3242 DWORD dwThreadPriority = GetThreadPriority(hThread); 3243 3244 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 3245 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3246 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3247 //round to 8 ms units to get more precise timeouts 3248 if(dwTimeout > 8) 3249 dwTimeout = (dwTimeout/8)*8; 3250 } 3251 else dwThreadPriority = -1; 3188 BOOL fChangePriority = FALSE; 3189 DWORD dwThreadPriority; 3190 3191 if(dwTimeout && dwTimeout < 20) { 3192 dwThreadPriority = GetThreadPriority(hThread); 3193 if(dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) 3194 { 3195 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3196 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3197 //round to 8 ms units to get more precise timeouts 3198 if(dwTimeout > 8) 3199 dwTimeout = (dwTimeout/8)*8; 3200 fChangePriority = TRUE; 3201 } 3202 } 3252 3203 3253 3204 // OK, now forward to Open32. … … 3260 3211 3261 3212 //Restore old thread priority if we changed it before 3262 if( dwThreadPriority != -1) {3213 if(fChangePriority) { 3263 3214 SetThreadPriority(hThread, dwThreadPriority); 3264 3215 } … … 3266 3217 dprintf2(("MsgWaitForMultipleObjects returned %d", rc)); 3267 3218 return (rc); // OK, done 3268 #endif3269 3219 } 3270 3220 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.