Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmplock.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 cmplock.h 00008 00009 Abstract: 00010 00011 Macros that hide the system calls used to do locking. Allows 00012 cm and reg code to run in a variety of environments. 00013 00014 Note that there is a single lock (in particular, a mutex) which 00015 protects the entire registry. 00016 00017 Author: 00018 00019 Bryan M. Willman (bryanwi) 30-Oct-91 00020 00021 Environment: 00022 00023 Revision History: 00024 00025 --*/ 00026 00027 // 00028 // Macros for kernel mode environment 00029 // 00030 00031 extern KMUTEX CmpRegistryMutex; 00032 #if DBG 00033 extern LONG CmpRegistryLockLocked; 00034 #endif 00035 00036 // 00037 // Test macro 00038 // 00039 #if DBG 00040 #define ASSERT_CM_LOCK_OWNED() \ 00041 if ( (CmpRegistryMutex.OwnerThread != KeGetCurrentThread()) || \ 00042 (CmpRegistryMutex.Header.SignalState >= 1) ) \ 00043 { \ 00044 ASSERT(FALSE); \ 00045 } 00046 #else 00047 #define ASSERT_CM_LOCK_OWNED() 00048 #endif 00049 00050 // 00051 // This set of macros serializes all access to the registry via 00052 // a single Mutex. 00053 // 00054 00055 // 00056 // CMP_LOCK_REGISTRY( 00057 // NTSTATUS *pstatus, 00058 // PLARGE_INTEGER timeout 00059 // ); 00060 // 00061 // Routine Description: 00062 // 00063 // Acquires the CmpRegistryMutex, with specified timeout, and 00064 // returns status. 00065 // 00066 // Arguments: 00067 // 00068 // pstatus - pointer to variable to receive status from wait call 00069 // 00070 // timeout - pointer to timeout value 00071 // 00072 00073 #if DBG 00074 #define CMP_LOCK_REGISTRY(status, timeout) \ 00075 { \ 00076 status = KeWaitForSingleObject( \ 00077 &CmpRegistryMutex, \ 00078 Executive, \ 00079 KernelMode, \ 00080 FALSE, \ 00081 timeout \ 00082 ); \ 00083 CmpRegistryLockLocked++; \ 00084 } 00085 #else 00086 #define CMP_LOCK_REGISTRY(status, timeout) \ 00087 { \ 00088 status = KeWaitForSingleObject( \ 00089 &CmpRegistryMutex, \ 00090 Executive, \ 00091 KernelMode, \ 00092 FALSE, \ 00093 timeout \ 00094 ); \ 00095 } 00096 #endif 00097 00098 // 00099 // CMP_UNLOCK_REGISTRY( 00100 // ); 00101 // 00102 // Routine Description: 00103 // 00104 // Releases the CmpRegistryMutex. 00105 // 00106 // 00107 00108 #if DBG 00109 #define CMP_UNLOCK_REGISTRY() \ 00110 { \ 00111 ASSERT(CmpRegistryLockLocked > 0); \ 00112 KeReleaseMutex(&CmpRegistryMutex, FALSE); \ 00113 CmpRegistryLockLocked--; \ 00114 } 00115 #else 00116 #define CMP_UNLOCK_REGISTRY() \ 00117 { \ 00118 KeReleaseMutex(&CmpRegistryMutex, FALSE); \ 00119 } 00120 #endif 00121 00122 00123 // 00124 // Debugging asserts 00125 // 00126 00127 #if DBG 00128 #define ASSERT_REGISTRY_LOCKED() ASSERT(CmpRegistryLockLocked > 0) 00129 #else 00130 #define ASSERT_REGISTRY_LOCKED() 00131 #endif

Generated on Sat May 15 19:39:28 2004 for test by doxygen 1.3.7