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

cmsubs3.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 cmsubs3.c 00008 00009 Abstract: 00010 00011 This module contains locking support routines for the configuration manager. 00012 00013 Author: 00014 00015 Bryan M. Willman (bryanwi) 30-Mar-1992 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include "cmp.h" 00022 00023 #ifdef ALLOC_PRAGMA 00024 #pragma alloc_text(PAGE,CmpUnlockRegistry) 00025 00026 #if DBG 00027 #pragma alloc_text(PAGE,CmpTestRegistryLock) 00028 #pragma alloc_text(PAGE,CmpTestRegistryLockExclusive) 00029 #endif 00030 00031 #endif 00032 00033 00034 // 00035 // Global registry lock 00036 // 00037 00038 ERESOURCE CmpRegistryLock; 00039 00040 PVOID CmpCaller; 00041 PVOID CmpCallerCaller; 00042 00043 VOID 00044 CmpLockRegistry( 00045 VOID 00046 ) 00047 /*++ 00048 00049 Routine Description: 00050 00051 Lock the registry for shared (read-only) access 00052 00053 Arguments: 00054 00055 None. 00056 00057 Return Value: 00058 00059 None, the registry lock will be held for shared access upon return. 00060 00061 --*/ 00062 { 00063 #if DBG 00064 PVOID Caller; 00065 PVOID CallerCaller; 00066 #endif 00067 00068 KeEnterCriticalRegion(); 00069 ExAcquireResourceShared(&CmpRegistryLock, TRUE); 00070 00071 #if DBG 00072 RtlGetCallersAddress(&Caller, &CallerCaller); 00073 CMLOG(CML_FLOW, CMS_LOCKING) { 00074 KdPrint(("CmpLockRegistry: c, cc: %08lx %08lx\n", Caller, CallerCaller)); 00075 } 00076 #endif 00077 00078 } 00079 00080 VOID 00081 CmpLockRegistryExclusive( 00082 VOID 00083 ) 00084 /*++ 00085 00086 Routine Description: 00087 00088 Lock the registry for exclusive (write) access. 00089 00090 Arguments: 00091 00092 CanWait - Supplies whether or not the call should wait 00093 for the resource or return immediately. 00094 00095 If CanWait is TRUE, this will always return 00096 TRUE. 00097 00098 Return Value: 00099 00100 TRUE - Lock was acquired exclusively 00101 00102 FALSE - Lock is owned by another thread. 00103 00104 --*/ 00105 { 00106 BOOLEAN Status; 00107 00108 00109 KeEnterCriticalRegion(); 00110 ExAcquireResourceExclusive(&CmpRegistryLock,TRUE); 00111 00112 RtlGetCallersAddress(&CmpCaller, &CmpCallerCaller); 00113 } 00114 00115 VOID 00116 CmpUnlockRegistry( 00117 ) 00118 /*++ 00119 00120 Routine Description: 00121 00122 Unlock the registry. 00123 00124 --*/ 00125 { 00126 ASSERT_CM_LOCK_OWNED(); 00127 ExReleaseResource(&CmpRegistryLock); 00128 KeLeaveCriticalRegion(); 00129 } 00130 00131 00132 #if DBG 00133 00134 BOOLEAN 00135 CmpTestRegistryLock(VOID) 00136 { 00137 BOOLEAN rc; 00138 00139 rc = TRUE; 00140 if (ExIsResourceAcquiredShared(&CmpRegistryLock) == 0) { 00141 rc = FALSE; 00142 } 00143 return rc; 00144 } 00145 00146 BOOLEAN 00147 CmpTestRegistryLockExclusive(VOID) 00148 { 00149 if (ExIsResourceAcquiredExclusive(&CmpRegistryLock) == 0) { 00150 return(FALSE); 00151 } 00152 return(TRUE); 00153 } 00154 00155 #endif

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