ReactOS 0.4.15-dev-8241-g63935f8
resource.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for resource.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define IsExclusiveWaiting(r)   (r->NumberOfExclusiveWaiters > 0)
 
#define IsSharedWaiting(r)   (r->NumberOfSharedWaiters > 0)
 
#define IsOwnedExclusive(r)   (r->Flag & ResourceOwnedExclusive)
 
#define IsBoostAllowed(r)   (!(r->Flag & ResourceHasDisabledPriorityBoost))
 
#define ExpVerifyResource(r)
 
#define ExpCheckForApcsDisabled(b, r, t)
 

Functions

FORCEINLINE VOID ExAcquireResourceLock (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
FORCEINLINE VOID ExReleaseResourceLock (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID NTAPI ExpResourceInitialization (VOID)
 
VOID NTAPI ExpAllocateExclusiveWaiterEvent (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID NTAPI ExpAllocateSharedWaiterSemaphore (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID NTAPI ExpExpandResourceOwnerTable (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
POWNER_ENTRY FASTCALL ExpFindFreeEntry (IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
POWNER_ENTRY FASTCALL ExpFindEntryForThread (IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread, IN PKLOCK_QUEUE_HANDLE LockHandle, IN BOOLEAN FirstEntryInelligible)
 
VOID FASTCALL ExpBoostOwnerThread (IN PKTHREAD Thread, IN PKTHREAD OwnerThread)
 
VOID FASTCALL ExpWaitForResource (IN PERESOURCE Resource, IN PVOID Object)
 
BOOLEAN NTAPI ExAcquireResourceExclusiveLite (IN PERESOURCE Resource, IN BOOLEAN Wait)
 
BOOLEAN NTAPI ExAcquireResourceSharedLite (IN PERESOURCE Resource, IN BOOLEAN Wait)
 
BOOLEAN NTAPI ExAcquireSharedStarveExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait)
 
BOOLEAN NTAPI ExAcquireSharedWaitForExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait)
 
VOID NTAPI ExConvertExclusiveToSharedLite (IN PERESOURCE Resource)
 
NTSTATUS NTAPI ExDeleteResourceLite (IN PERESOURCE Resource)
 
VOID NTAPI ExDisableResourceBoostLite (IN PERESOURCE Resource)
 
ULONG NTAPI ExGetExclusiveWaiterCount (IN PERESOURCE Resource)
 
ULONG NTAPI ExGetSharedWaiterCount (IN PERESOURCE Resource)
 
NTSTATUS NTAPI ExInitializeResourceLite (IN PERESOURCE Resource)
 
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite (IN PERESOURCE Resource)
 
ULONG NTAPI ExIsResourceAcquiredSharedLite (IN PERESOURCE Resource)
 
NTSTATUS NTAPI ExReinitializeResourceLite (IN PERESOURCE Resource)
 
VOID FASTCALL ExReleaseResourceLite (IN PERESOURCE Resource)
 
VOID NTAPI ExReleaseResourceForThreadLite (IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
 
VOID NTAPI ExSetResourceOwnerPointer (IN PERESOURCE Resource, IN PVOID OwnerPointer)
 
BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite (IN PERESOURCE Resource)
 
PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceExclusive (IN PERESOURCE Resource)
 
PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceShared (IN PERESOURCE Resource)
 
PVOID NTAPI ExEnterCriticalRegionAndAcquireSharedWaitForExclusive (IN PERESOURCE Resource)
 
VOID FASTCALL ExReleaseResourceAndLeaveCriticalRegion (IN PERESOURCE Resource)
 

Variables

LARGE_INTEGER ExShortTime = {{-100000, -1}}
 
LARGE_INTEGER ExpTimeout
 
ULONG ExpResourceTimeoutCount = 90 * 3600 / 2
 
KSPIN_LOCK ExpResourceSpinLock
 
LIST_ENTRY ExpSystemResourcesList
 
BOOLEAN ExResourceStrict = TRUE
 

Macro Definition Documentation

◆ ExpCheckForApcsDisabled

#define ExpCheckForApcsDisabled (   b,
  r,
  t 
)

Definition at line 155 of file resource.c.

◆ ExpVerifyResource

#define ExpVerifyResource (   r)

Definition at line 154 of file resource.c.

◆ IsBoostAllowed

#define IsBoostAllowed (   r)    (!(r->Flag & ResourceHasDisabledPriorityBoost))

Definition at line 19 of file resource.c.

◆ IsExclusiveWaiting

#define IsExclusiveWaiting (   r)    (r->NumberOfExclusiveWaiters > 0)

Definition at line 16 of file resource.c.

◆ IsOwnedExclusive

#define IsOwnedExclusive (   r)    (r->Flag & ResourceOwnedExclusive)

Definition at line 18 of file resource.c.

◆ IsSharedWaiting

#define IsSharedWaiting (   r)    (r->NumberOfSharedWaiters > 0)

Definition at line 17 of file resource.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file resource.c.

Function Documentation

◆ ExAcquireResourceExclusiveLite()

BOOLEAN NTAPI ExAcquireResourceExclusiveLite ( IN PERESOURCE  Resource,
IN BOOLEAN  Wait 
)

Definition at line 775 of file resource.c.

777{
781
782 /* Sanity check */
783 ASSERT((Resource->Flag & ResourceNeverExclusive) == 0);
784
785 /* Get the thread */
787
788 /* Sanity check and validation */
791
792 /* Acquire the lock */
795
796 /* Check if there is a shared owner or exclusive owner */
797TryAcquire:
798 if (Resource->ActiveEntries)
799 {
800 /* Check if it's exclusively owned, and we own it */
801 if ((IsOwnedExclusive(Resource)) &&
802 (Resource->OwnerEntry.OwnerThread == Thread))
803 {
804 /* Increase the owning count */
805 Resource->OwnerEntry.OwnerCount++;
806 Success = TRUE;
807 }
808 else
809 {
810 /*
811 * If the caller doesn't want us to wait, we can't acquire the
812 * resource because someone else then us owns it. If we can wait,
813 * then we'll wait.
814 */
815 if (!Wait)
816 {
817 Success = FALSE;
818 }
819 else
820 {
821 /* Check if it has exclusive waiters */
822 if (!Resource->ExclusiveWaiters)
823 {
824 /* It doesn't, allocate the event and try acquiring again */
826 goto TryAcquire;
827 }
828
829 /* Has exclusive waiters, wait on it */
830 Resource->NumberOfExclusiveWaiters++;
832 ExpWaitForResource(Resource, Resource->ExclusiveWaiters);
833
834 /* Set owner and return success */
835 Resource->OwnerEntry.OwnerThread = ExGetCurrentResourceThread();
836 return TRUE;
837 }
838 }
839 }
840 else
841 {
842 /* Nobody owns it, so let's! */
843 ASSERT(Resource->ActiveEntries == 0);
844 ASSERT(Resource->ActiveCount == 0);
846 Resource->ActiveEntries = 1;
847 Resource->ActiveCount = 1;
848 Resource->OwnerEntry.OwnerThread = Thread;
849 Resource->OwnerEntry.OwnerCount = 1;
850 Success = TRUE;
851 }
852
853 /* Release the lock and return */
855 return Success;
856}
unsigned char BOOLEAN
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define ResourceOwnedExclusive
Definition: dldetect.h:32
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI KeIsExecutingDpc(VOID)
Definition: dpc.c:947
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
@ Success
Definition: eventcreate.c:712
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define ASSERT(a)
Definition: mode.c:44
FORCEINLINE VOID ExReleaseResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:37
#define ExpCheckForApcsDisabled(b, r, t)
Definition: resource.c:155
VOID NTAPI ExpAllocateExclusiveWaiterEvent(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:200
#define ExpVerifyResource(r)
Definition: resource.c:154
FORCEINLINE VOID ExAcquireResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:25
#define IsOwnedExclusive(r)
Definition: resource.c:18
VOID FASTCALL ExpWaitForResource(IN PERESOURCE Resource, IN PVOID Object)
Definition: resource.c:622
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define ResourceNeverExclusive
Definition: extypes.h:245
ULONG_PTR ERESOURCE_THREAD
Definition: extypes.h:208
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

◆ ExAcquireResourceLock()

◆ ExAcquireResourceSharedLite()

BOOLEAN NTAPI ExAcquireResourceSharedLite ( IN PERESOURCE  Resource,
IN BOOLEAN  Wait 
)

Definition at line 890 of file resource.c.

892{
896 BOOLEAN FirstEntryBusy;
897
898 /* Get the thread */
900
901 /* Sanity check and validation */
904
905 /* Acquire the lock */
908
909 /* Check how many active entries we've got */
910 while (Resource->ActiveEntries != 0)
911 {
912 /* Check if it's exclusively owned */
914 {
915 /* Check if we own it */
916 if (Resource->OwnerEntry.OwnerThread == Thread)
917 {
918 /* Increase the owning count */
919 Resource->OwnerEntry.OwnerCount++;
920
921 /* Release the lock and return */
923 return TRUE;
924 }
925
926 /* Find a free entry */
928 if (!Owner) continue;
929 }
930 else
931 {
932 /* Resource is shared, find who owns it */
933 FirstEntryBusy = IsExclusiveWaiting(Resource);
935 Thread,
936 &LockHandle,
937 FirstEntryBusy);
938 if (!Owner) continue;
939
940 /* Is it us? */
941 if (Owner->OwnerThread == Thread)
942 {
943 /* Increase acquire count and return */
944 Owner->OwnerCount++;
945 ASSERT(Owner->OwnerCount != 0);
946
947 /* Release the lock and return */
949 return TRUE;
950 }
951
952 /* Try to find if there are exclusive waiters */
953 if (!FirstEntryBusy)
954 {
955 /* There are none, so acquire it */
956 Owner->OwnerThread = Thread;
957 Owner->OwnerCount = 1;
958
959 /* Check how many active entries we had */
960 if (Resource->ActiveEntries == 0)
961 {
962 /* Set initial counts */
963 ASSERT(Resource->ActiveCount == 0);
964 Resource->ActiveEntries = 1;
965 Resource->ActiveCount = 1;
966 }
967 else
968 {
969 /* Increase active entries */
970 ASSERT(Resource->ActiveCount == 1);
971 Resource->ActiveEntries++;
972 }
973
974 /* Release the lock and return */
976 return TRUE;
977 }
978 }
979
980 /* If we got here, then we need to wait. Are we allowed? */
981 if (!Wait)
982 {
983 /* Release the lock and return */
985 return FALSE;
986 }
987
988 /* Check if we have a shared waiters semaphore */
989 if (!Resource->SharedWaiters)
990 {
991 /* Allocate it and try another acquire */
993 }
994 else
995 {
996 /* We have shared waiters, wait for it */
997 break;
998 }
999 }
1000
1001 /* Did we get here because we don't have active entries? */
1002 if (Resource->ActiveEntries == 0)
1003 {
1004 /* Acquire it */
1005 ASSERT(Resource->ActiveEntries == 0);
1006 ASSERT(Resource->ActiveCount == 0);
1007 Resource->ActiveEntries = 1;
1008 Resource->ActiveCount = 1;
1009 Resource->OwnerEntry.OwnerThread = Thread;
1010 Resource->OwnerEntry.OwnerCount = 1;
1011
1012 /* Release the lock and return */
1014 return TRUE;
1015 }
1016
1017 /* Now wait for the resource */
1018 Owner->OwnerThread = Thread;
1019 Owner->OwnerCount = 1;
1020 Resource->NumberOfSharedWaiters++;
1021
1022 /* Release the lock and return */
1024 ExpWaitForResource(Resource, Resource->SharedWaiters);
1025 return TRUE;
1026}
#define NULL
Definition: types.h:112
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1597
VOID NTAPI ExpAllocateSharedWaiterSemaphore(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:260
#define IsExclusiveWaiting(r)
Definition: resource.c:16
POWNER_ENTRY FASTCALL ExpFindEntryForThread(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread, IN PKLOCK_QUEUE_HANDLE LockHandle, IN BOOLEAN FirstEntryInelligible)
Definition: resource.c:483
POWNER_ENTRY FASTCALL ExpFindFreeEntry(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:420
Definition: extypes.h:210

◆ ExAcquireSharedStarveExclusive()

BOOLEAN NTAPI ExAcquireSharedStarveExclusive ( IN PERESOURCE  Resource,
IN BOOLEAN  Wait 
)

Definition at line 1068 of file resource.c.

1070{
1074
1075 /* Get the thread */
1077
1078 /* Sanity check and validation */
1081
1082 /* Acquire the lock */
1084
1085 /* See if anyone owns it */
1086TryAcquire:
1087 if (Resource->ActiveEntries == 0)
1088 {
1089 /* Nobody owns it, so let's take control */
1090 ASSERT(Resource->ActiveEntries == 0);
1091 ASSERT(Resource->ActiveCount == 0);
1092 Resource->ActiveCount = 1;
1093 Resource->ActiveEntries = 1;
1094 Resource->OwnerEntry.OwnerThread = Thread;
1095 Resource->OwnerEntry.OwnerCount = 1;
1096
1097 /* Release the lock and return */
1099 return TRUE;
1100 }
1101
1102 /* Check if it's exclusively owned */
1104 {
1105 /* Check if we own it */
1106 if (Resource->OwnerEntry.OwnerThread == Thread)
1107 {
1108 /* Increase the owning count */
1109 Resource->OwnerEntry.OwnerCount++;
1110
1111 /* Release the lock and return */
1113 return TRUE;
1114 }
1115
1116 /* Find a free entry */
1118 if (!Owner) goto TryAcquire;
1119 }
1120 else
1121 {
1122 /* Resource is shared, find who owns it */
1124 if (!Owner) goto TryAcquire;
1125
1126 /* Is it us? */
1127 if (Owner->OwnerThread == Thread)
1128 {
1129 /* Increase acquire count and return */
1130 Owner->OwnerCount++;
1131 ASSERT(Owner->OwnerCount != 0);
1132
1133 /* Release the lock and return */
1135 return TRUE;
1136 }
1137
1138 /* Acquire it */
1139 Owner->OwnerThread = Thread;
1140 Owner->OwnerCount = 1;
1141
1142 /* Check how many active entries we had */
1143 if (Resource->ActiveEntries == 0)
1144 {
1145 /* Set initial counts */
1146 ASSERT(Resource->ActiveCount == 0);
1147 Resource->ActiveEntries = 1;
1148 Resource->ActiveCount = 1;
1149 }
1150 else
1151 {
1152 /* Increase active entries */
1153 ASSERT(Resource->ActiveCount == 1);
1154 Resource->ActiveEntries++;
1155 }
1156
1157 /* Release the lock and return */
1159 return TRUE;
1160 }
1161
1162 /* If we got here, then we need to wait. Are we allowed? */
1163 if (!Wait)
1164 {
1165 /* Release the lock and return */
1167 return FALSE;
1168 }
1169
1170 /* Check if we have a shared waiters semaphore */
1171 if (!Resource->SharedWaiters)
1172 {
1173 /* Allocate it and try another acquire */
1175 goto TryAcquire;
1176 }
1177
1178 /* Now wait for the resource */
1179 Owner->OwnerThread = Thread;
1180 Owner->OwnerCount = 1;
1181 Resource->NumberOfSharedWaiters++;
1182
1183 /* Release the lock and return */
1185 ExpWaitForResource(Resource, Resource->SharedWaiters);
1186 return TRUE;
1187}

Referenced by __RxAcquireFcb(), _Requires_lock_held_(), CcpGetAppropriateBcb(), CcpPinData(), CmpLockRegistry(), Ext2FloppyFlush(), Ext2FlushVolume(), Ext2PurgeFile(), Ext2PurgeVolume(), Ext2WriteFile(), Ext2WriteVolume(), get_block_bh_mdl(), get_block_bh_pin(), TestResourceExclusiveAccess(), TestResourceSharedAccess(), and TestResourceWithThreads().

◆ ExAcquireSharedWaitForExclusive()

BOOLEAN NTAPI ExAcquireSharedWaitForExclusive ( IN PERESOURCE  Resource,
IN BOOLEAN  Wait 
)

Definition at line 1222 of file resource.c.

1224{
1228
1229 /* Get the thread */
1231
1232 /* Sanity check and validation */
1235
1236 /* Acquire the lock */
1238
1239 /* See if nobody owns us */
1240TryAcquire:
1241 if (!Resource->ActiveEntries)
1242 {
1243 /* Nobody owns it, so let's take control */
1244 ASSERT(Resource->ActiveEntries == 0);
1245 ASSERT(Resource->ActiveCount == 0);
1246 Resource->ActiveCount = 1;
1247 Resource->ActiveEntries = 1;
1248 Resource->OwnerEntry.OwnerThread = Thread;
1249 Resource->OwnerEntry.OwnerCount = 1;
1250
1251 /* Release the lock and return */
1253 return TRUE;
1254 }
1255
1256 /* Check if it's exclusively owned */
1258 {
1259 /* Check if we own it */
1260 if (Resource->OwnerEntry.OwnerThread == Thread)
1261 {
1262 /* Increase the owning count */
1263 Resource->OwnerEntry.OwnerCount++;
1264
1265 /* Release the lock and return */
1267 return TRUE;
1268 }
1269
1270 /* Find a free entry */
1272 if (!Owner) goto TryAcquire;
1273 }
1274 else
1275 {
1276 /* Try to find if there are exclusive waiters */
1278 {
1279 /* We have to wait for the exclusive waiter to be done */
1280 if (!Wait)
1281 {
1282 /* So bail out if we're not allowed */
1284 return FALSE;
1285 }
1286
1287 /* Check if we have a shared waiters semaphore */
1288 if (!Resource->SharedWaiters)
1289 {
1290 /* Allocate one and try again */
1292 goto TryAcquire;
1293 }
1294
1295 /* Now wait for the resource */
1296 Resource->NumberOfSharedWaiters++;
1298 ExpWaitForResource(Resource, Resource->SharedWaiters);
1299
1300 /* Get the lock back */
1302
1303 /* Find who owns it now */
1305
1306 /* Sanity checks */
1308 ASSERT(Resource->ActiveEntries > 0);
1309 ASSERT(Owner->OwnerThread != Thread);
1310
1311 /* Take control */
1312 Owner->OwnerThread = Thread;
1313 Owner->OwnerCount = 1;
1314
1315 /* Release the lock and return */
1317 return TRUE;
1318 }
1319 else
1320 {
1321 /* Resource is shared, find who owns it */
1323 if (!Owner) goto TryAcquire;
1324
1325 /* Is it us? */
1326 if (Owner->OwnerThread == Thread)
1327 {
1328 /* Increase acquire count and return */
1329 Owner->OwnerCount++;
1330 ASSERT(Owner->OwnerCount != 0);
1331
1332 /* Release the lock and return */
1334 return TRUE;
1335 }
1336
1337 /* No exclusive waiters, so acquire it */
1338 Owner->OwnerThread = Thread;
1339 Owner->OwnerCount = 1;
1340
1341 /* Check how many active entries we had */
1342 if (Resource->ActiveEntries == 0)
1343 {
1344 /* Set initial counts */
1345 ASSERT(Resource->ActiveCount == 0);
1346 Resource->ActiveEntries = 1;
1347 Resource->ActiveCount = 1;
1348 }
1349 else
1350 {
1351 /* Increase active entries */
1352 ASSERT(Resource->ActiveCount == 1);
1353 Resource->ActiveEntries++;
1354 }
1355
1356 /* Release the lock and return */
1358 return TRUE;
1359 }
1360 }
1361
1362 /* We have to wait for the exclusive waiter to be done */
1363 if (!Wait)
1364 {
1365 /* So bail out if we're not allowed */
1367 return FALSE;
1368 }
1369
1370 /* Check if we have a shared waiters semaphore */
1371 if (!Resource->SharedWaiters)
1372 {
1373 /* Allocate one and try again */
1375 goto TryAcquire;
1376 }
1377
1378 /* Take control */
1379 Owner->OwnerThread = Thread;
1380 Owner->OwnerCount = 1;
1381 Resource->NumberOfSharedWaiters++;
1382
1383 /* Release the lock and return */
1385 ExpWaitForResource(Resource, Resource->SharedWaiters);
1386 return TRUE;
1387}

Referenced by __RxAcquireFcb(), ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(), FsRtlAcquireFileForModWriteEx(), TestResourceExclusiveAccess(), TestResourceSharedAccess(), and TestResourceWithThreads().

◆ ExConvertExclusiveToSharedLite()

VOID NTAPI ExConvertExclusiveToSharedLite ( IN PERESOURCE  Resource)

Definition at line 1407 of file resource.c.

1408{
1409 ULONG OldWaiters;
1411
1412 /* Sanity checks */
1416 ASSERT(Resource->OwnerEntry.OwnerThread == (ERESOURCE_THREAD)PsGetCurrentThread());
1417
1418 /* Lock the resource */
1420
1421 /* Erase the exclusive flag */
1422 Resource->Flag &= ~ResourceOwnedExclusive;
1423
1424 /* Check if we have shared waiters */
1426 {
1427 /* Make the waiters active owners */
1428 OldWaiters = Resource->NumberOfSharedWaiters;
1429 Resource->ActiveEntries += OldWaiters;
1430 Resource->NumberOfSharedWaiters = 0;
1431
1432 /* Release lock and wake the waiters */
1434 KeReleaseSemaphore(Resource->SharedWaiters, 0, OldWaiters, FALSE);
1435 }
1436 else
1437 {
1438 /* Release lock */
1440 }
1441}
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define IsSharedWaiting(r)
Definition: resource.c:17
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
uint32_t ULONG
Definition: typedefs.h:59

◆ ExDeleteResourceLite()

NTSTATUS NTAPI ExDeleteResourceLite ( IN PERESOURCE  Resource)

Definition at line 1461 of file resource.c.

1462{
1464
1465 /* Sanity checks */
1470
1471 /* Lock the resource */
1473
1474 /* Remove the resource */
1475 RemoveEntryList(&Resource->SystemResourcesList);
1476
1477 /* Release the lock */
1479
1480 /* Free every structure */
1481 if (Resource->OwnerTable) ExFreePoolWithTag(Resource->OwnerTable, TAG_RESOURCE_TABLE);
1482 if (Resource->SharedWaiters) ExFreePoolWithTag(Resource->SharedWaiters, TAG_RESOURCE_SEMAPHORE);
1483 if (Resource->ExclusiveWaiters) ExFreePoolWithTag(Resource->ExclusiveWaiters, TAG_RESOURCE_EVENT);
1484
1485 /* Return success */
1486 return STATUS_SUCCESS;
1487}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
KSPIN_LOCK ExpResourceSpinLock
Definition: resource.c:79
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TAG_RESOURCE_TABLE
Definition: tag.h:23
#define TAG_RESOURCE_EVENT
Definition: tag.h:24
#define TAG_RESOURCE_SEMAPHORE
Definition: tag.h:25

◆ ExDisableResourceBoostLite()

VOID NTAPI ExDisableResourceBoostLite ( IN PERESOURCE  Resource)

Definition at line 1506 of file resource.c.

1507{
1509
1510 /* Sanity check */
1512
1513 /* Lock the resource */
1515
1516 /* Remove the flag */
1518
1519 /* Release the lock */
1521}
#define ResourceHasDisabledPriorityBoost
Definition: extypes.h:169

◆ ExEnterCriticalRegionAndAcquireResourceExclusive()

PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceExclusive ( IN PERESOURCE  Resource)

Definition at line 2194 of file resource.c.

2195{
2196 /* Enter critical region */
2198
2199 /* Acquire the resource */
2201
2202 /* Return the Win32 Thread */
2203 return KeGetCurrentThread()->Win32Thread;
2204}
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define KeGetCurrentThread
Definition: hal.h:55
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287

Referenced by _Acquires_lock_().

◆ ExEnterCriticalRegionAndAcquireResourceShared()

PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceShared ( IN PERESOURCE  Resource)

Definition at line 2223 of file resource.c.

2224{
2225 /* Enter critical region */
2227
2228 /* Acquire the resource */
2230
2231 /* Return the Win32 Thread */
2232 return KeGetCurrentThread()->Win32Thread;
2233}
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621

◆ ExEnterCriticalRegionAndAcquireSharedWaitForExclusive()

PVOID NTAPI ExEnterCriticalRegionAndAcquireSharedWaitForExclusive ( IN PERESOURCE  Resource)

Definition at line 2254 of file resource.c.

2255{
2256 /* Enter critical region */
2258
2259 /* Acquire the resource */
2261
2262 /* Return the Win32 Thread */
2263 return KeGetCurrentThread()->Win32Thread;
2264}
BOOLEAN NTAPI ExAcquireSharedWaitForExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1222

◆ ExGetExclusiveWaiterCount()

ULONG NTAPI ExGetExclusiveWaiterCount ( IN PERESOURCE  Resource)

Definition at line 1540 of file resource.c.

1541{
1542 /* Return the count */
1543 return Resource->NumberOfExclusiveWaiters;
1544}

◆ ExGetSharedWaiterCount()

ULONG NTAPI ExGetSharedWaiterCount ( IN PERESOURCE  Resource)

Definition at line 1563 of file resource.c.

1564{
1565 /* Return the count */
1566 return Resource->NumberOfSharedWaiters;
1567}

◆ ExInitializeResourceLite()

NTSTATUS NTAPI ExInitializeResourceLite ( IN PERESOURCE  Resource)

Definition at line 1587 of file resource.c.

1588{
1590
1591 /* Clear the structure */
1593
1594 /* Initialize the lock */
1595 KeInitializeSpinLock(&Resource->SpinLock);
1596
1597 /* Add it into the system list */
1599 InsertTailList(&ExpSystemResourcesList, &Resource->SystemResourcesList);
1601
1602 /* Return success */
1603 return STATUS_SUCCESS;
1604}
#define InsertTailList(ListHead, Entry)
ULONG ERESOURCE
Definition: env_spec_w32.h:594
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
LIST_ENTRY ExpSystemResourcesList
Definition: resource.c:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ ExIsResourceAcquiredExclusiveLite()

BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite ( IN PERESOURCE  Resource)

◆ ExIsResourceAcquiredSharedLite()

ULONG NTAPI ExIsResourceAcquiredSharedLite ( IN PERESOURCE  Resource)

Definition at line 1663 of file resource.c.

1664{
1666 ULONG i, Size;
1667 ULONG Count = 0;
1670
1671 /* Sanity check */
1673
1674 /* Check if nobody owns us */
1675 if (!Resource->ActiveEntries) return 0;
1676
1677 /* Get the thread */
1679
1680 /* Check if we are in the thread list */
1681 if (Resource->OwnerEntry.OwnerThread == Thread)
1682 {
1683 /* Found it, return count */
1684 Count = Resource->OwnerEntry.OwnerCount;
1685 }
1686 else
1687 {
1688 /* We can't own an exclusive resource at this point */
1689 if (IsOwnedExclusive(Resource)) return 0;
1690
1691 /* Lock the resource */
1693
1694 /* Not in the list, do a full table look up */
1695 Owner = Resource->OwnerTable;
1696 if (Owner)
1697 {
1698 /* Get the resource index */
1699 i = ((PKTHREAD)Thread)->ResourceIndex;
1700 Size = Owner->TableSize;
1701
1702 /* Check if the index is valid and check if we don't match */
1703 if ((i >= Size) || (Owner[i].OwnerThread != Thread))
1704 {
1705 /* Sh*t! We need to do a full search */
1706 for (i = 1; i < Size; i++)
1707 {
1708 /* Move to next owner */
1709 Owner++;
1710
1711 /* Try to find a match */
1712 if (Owner->OwnerThread == Thread)
1713 {
1714 /* Finally! */
1715 Count = Owner->OwnerCount;
1716 break;
1717 }
1718 }
1719 }
1720 else
1721 {
1722 /* We found the match directlry */
1723 Count = Owner[i].OwnerCount;
1724 }
1725 }
1726
1727 /* Release the lock */
1729 }
1730
1731 /* Return count */
1732 return Count;
1733}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int Count
Definition: noreturn.cpp:7
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by _Dispatch_type_(), _Function_class_(), CcSetBcbOwnerPointer(), CmpTestHiveFlusherLockShared(), CmpTestRegistryLock(), do_read_job(), find_file_in_dir(), FsRtlAcquireFileForCcFlushEx(), open_fileref_child(), UDFAcquireResourceExclusiveWithCheck(), UDFAcquireResourceSharedWithCheck(), UDFCommonFlush(), UDFIsResourceAcquired(), and UserIsEntered().

◆ ExpAllocateExclusiveWaiterEvent()

VOID NTAPI ExpAllocateExclusiveWaiterEvent ( IN PERESOURCE  Resource,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 200 of file resource.c.

202{
204
205 /* Release the lock */
207
208 /* Loop as long as we keep running out of memory */
209 do
210 {
211 /* Allocate the event */
213 sizeof(KEVENT),
215 if (Event)
216 {
217 /* Initialize it */
219
220 /* Set it */
221 if (InterlockedCompareExchangePointer((PVOID*)&Resource->ExclusiveWaiters,
222 Event,
223 NULL))
224 {
225 /* Someone already set it, free our event */
226 DPRINT1("WARNING: Handling race condition\n");
228 }
229
230 break;
231 }
232
233 /* Wait a bit before trying again */
235 } while (TRUE);
236
237 /* Re-acquire the lock */
239}
#define DPRINT1
Definition: precomp.h:8
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NonPagedPool
Definition: env_spec_w32.h:307
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
LARGE_INTEGER ExShortTime
Definition: resource.c:73

Referenced by ExAcquireResourceExclusiveLite().

◆ ExpAllocateSharedWaiterSemaphore()

VOID NTAPI ExpAllocateSharedWaiterSemaphore ( IN PERESOURCE  Resource,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 260 of file resource.c.

262{
263 PKSEMAPHORE Semaphore;
264
265 /* Release the lock */
267
268 /* Loop as long as we keep running out of memory */
269 do
270 {
271 /* Allocate the semaphore */
273 sizeof(KSEMAPHORE),
275 if (Semaphore)
276 {
277 /* Initialize it */
278 KeInitializeSemaphore(Semaphore, 0, MAXLONG);
279
280 /* Set it */
282 Semaphore,
283 NULL))
284 {
285 /* Someone already set it, free our semaphore */
286 DPRINT1("WARNING: Handling race condition\n");
288 }
289
290 break;
291 }
292
293 /* Wait a bit before trying again */
295 } while (TRUE);
296
297 /* Re-acquire the lock */
299}
VOID NTAPI KeInitializeSemaphore(IN PKSEMAPHORE Semaphore, IN LONG Count, IN LONG Limit)
Definition: semphobj.c:22
#define MAXLONG
Definition: umtypes.h:116

Referenced by ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), and ExAcquireSharedWaitForExclusive().

◆ ExpBoostOwnerThread()

VOID FASTCALL ExpBoostOwnerThread ( IN PKTHREAD  Thread,
IN PKTHREAD  OwnerThread 
)

Definition at line 576 of file resource.c.

578{
579 /* Make sure the owner thread is a pointer, not an ID */
580 if (!((ULONG_PTR)OwnerThread & 0x3))
581 {
582 /* Check if we can actually boost it */
583 if ((OwnerThread->Priority < Thread->Priority) &&
584 (OwnerThread->Priority < 14))
585 {
586 /* Acquire the thread lock */
588
589 /* Set the new priority */
590 OwnerThread->PriorityDecrement += 14 - OwnerThread->Priority;
591
592 /* Update quantum */
593 OwnerThread->Quantum = OwnerThread->QuantumReset;
594
595 /* Update the kernel state */
596 KiSetPriorityThread(OwnerThread, 14);
597
598 /* Release the thread lock */
600 }
601 }
602}
FORCEINLINE VOID KiAcquireThreadLock(IN PKTHREAD Thread)
Definition: ke_x.h:240
FORCEINLINE VOID KiReleaseThreadLock(IN PKTHREAD Thread)
Definition: ke_x.h:250
VOID FASTCALL KiSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdschd.c:511
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by ExpWaitForResource().

◆ ExpExpandResourceOwnerTable()

VOID NTAPI ExpExpandResourceOwnerTable ( IN PERESOURCE  Resource,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 320 of file resource.c.

322{
325 ULONG NewSize, OldSize;
326
327 /* Get the owner table */
328 Owner = Resource->OwnerTable;
329 if (!Owner)
330 {
331 /* Start with the default size of 3 */
332 OldSize = 0;
333 NewSize = 3;
334 }
335 else
336 {
337 /* Add 4 more entries */
338 OldSize = Owner->TableSize;
339 NewSize = OldSize + 4;
340 }
341
342 /* Release the lock */
344
345 /* Allocate memory for the table */
347 NewSize * sizeof(OWNER_ENTRY),
349
350 /* Zero the table */
351 RtlZeroMemory(Table + OldSize,
352 (NewSize - OldSize) * sizeof(OWNER_ENTRY));
353
354 /* Lock the resource */
356
357 /* Make sure nothing has changed */
358 if ((Owner != Resource->OwnerTable) ||
359 ((Owner) && (OldSize != Owner->TableSize)))
360 {
361 /* Resource changed while we weren't holding the lock; bail out */
364 }
365 else
366 {
367 /* Copy the table */
368 if (Owner) RtlCopyMemory(Table, Owner, OldSize * sizeof(OWNER_ENTRY));
369
370 /* Acquire dispatcher lock to prevent thread boosting */
372
373 /* Set the new table data */
374 Table->TableSize = NewSize;
375 Resource->OwnerTable = Table;
376
377 /* Release dispatcher lock */
379
380 /* Sanity check */
382
383 /* Release lock */
385
386 /* Free the old table */
388
389 /* Set the resource index */
390 if (!OldSize) OldSize = 1;
391 }
392
393 /* Set the resource index */
394 KeGetCurrentThread()->ResourceIndex = (UCHAR)OldSize;
395
396 /* Lock the resource again */
398}
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
ASMGENDATA Table[]
Definition: genincdata.c:61
FORCEINLINE VOID KiReleaseDispatcherLock(IN KIRQL OldIrql)
Definition: ke_x.h:157
FORCEINLINE KIRQL KiAcquireDispatcherLock(VOID)
Definition: ke_x.h:149
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by ExpFindEntryForThread(), and ExpFindFreeEntry().

◆ ExpFindEntryForThread()

POWNER_ENTRY FASTCALL ExpFindEntryForThread ( IN PERESOURCE  Resource,
IN ERESOURCE_THREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  LockHandle,
IN BOOLEAN  FirstEntryInelligible 
)

Definition at line 483 of file resource.c.

487{
488 POWNER_ENTRY FreeEntry, Owner, Limit;
489
490 /* Start by looking in the static array */
491 Owner = &Resource->OwnerEntry;
492 if (Owner->OwnerThread == Thread) return Owner;
493
494 /* Check if this is a free entry */
495 if ((FirstEntryInelligible) || (Owner->OwnerThread))
496 {
497 /* No free entry */
498 FreeEntry = NULL;
499 }
500 else
501 {
502 /* Use the first entry as our free entry */
503 FreeEntry = Owner;
504 }
505
506 /* Get the current table pointer */
507 Owner = Resource->OwnerTable;
508 if (Owner)
509 {
510 /* Set the limit, move to the next owner and loop owner entries */
511 Limit = &Owner[Owner->TableSize];
512 Owner++;
513 while (Owner->OwnerThread != Thread)
514 {
515 /* Check if we don't have a free entry */
516 if (!FreeEntry)
517 {
518 /* Check if this entry is free */
519 if (!Owner->OwnerThread)
520 {
521 /* Save it as our free entry */
522 FreeEntry = Owner;
523 }
524 }
525
526 /* Move to the next one */
527 Owner++;
528
529 /* Check if the entry is free */
530 if (Owner == Limit) goto Expand;
531 }
532
533 /* Update the resource entry */
534 KeGetCurrentThread()->ResourceIndex = (UCHAR)(Owner - Resource->OwnerTable);
535 return Owner;
536 }
537 else
538 {
539Expand:
540 /* Check if it's OK to do an expansion */
541 if (!LockHandle) return NULL;
542
543 /* If we found a free entry by now, return it */
544 if (FreeEntry)
545 {
546 /* Set the resource index */
547 KeGetCurrentThread()->ResourceIndex = (UCHAR)(FreeEntry - Resource->OwnerTable);
548 return FreeEntry;
549 }
550
551 /* No free entry, expand the table */
553 return NULL;
554 }
555}
VOID NTAPI ExpExpandResourceOwnerTable(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:320
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304

Referenced by ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), ExAcquireSharedWaitForExclusive(), and ExSetResourceOwnerPointer().

◆ ExpFindFreeEntry()

POWNER_ENTRY FASTCALL ExpFindFreeEntry ( IN PERESOURCE  Resource,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 420 of file resource.c.

422{
424
425 /* Sanity check */
426 ASSERT(LockHandle != 0);
427 ASSERT(Resource->OwnerEntry.OwnerThread != 0);
428
429 /* Get the current table pointer */
430 Owner = Resource->OwnerTable;
431 if (Owner)
432 {
433 /* Set the limit, move to the next owner and loop owner entries */
434 Limit = &Owner[Owner->TableSize];
435 Owner++;
436 while (Owner->OwnerThread)
437 {
438 /* Move to the next one */
439 Owner++;
440
441 /* Check if the entry is free */
442 if (Owner == Limit) goto Expand;
443 }
444
445 /* Update the resource entry */
446 KeGetCurrentThread()->ResourceIndex = (UCHAR)(Owner - Resource->OwnerTable);
447 }
448 else
449 {
450Expand:
451 /* No free entry, expand the table */
453 Owner = NULL;
454 }
455
456 /* Return the entry found */
457 return Owner;
458}

Referenced by ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), and ExAcquireSharedWaitForExclusive().

◆ ExpResourceInitialization()

VOID NTAPI ExpResourceInitialization ( VOID  )

Definition at line 173 of file resource.c.

174{
175 /* Setup the timeout */
176 ExpTimeout.QuadPart = Int32x32To64(4, -10000000);
179}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define Int32x32To64(a, b)
LARGE_INTEGER ExpTimeout
Definition: resource.c:74
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by ExpInitSystemPhase0().

◆ ExpWaitForResource()

VOID FASTCALL ExpWaitForResource ( IN PERESOURCE  Resource,
IN PVOID  Object 
)

Definition at line 622 of file resource.c.

624{
625 ULONG i;
626 ULONG Size;
628 ULONG WaitCount = 0;
631 PKTHREAD Thread, OwnerThread;
632#if DBG
634#endif
635
636 /* Increase contention count and use a 5 second timeout */
637 Resource->ContentionCount++;
638 Timeout.QuadPart = 500 * -10000LL;
639 for (;;)
640 {
641 /* Wait for ownership */
645 FALSE,
646 &Timeout);
647 if (Status != STATUS_TIMEOUT)
648 break;
649
650 /* Increase wait count */
651 WaitCount++;
653
654 /* Check if we've exceeded the limit */
655 if (WaitCount > ExpResourceTimeoutCount)
656 {
657 /* Reset wait count */
658 WaitCount = 0;
659#if DBG
660 /* Lock the resource */
662
663 /* Dump debug information */
664 DPRINT1("Resource @ %p\n", Resource);
665 DPRINT1(" ActiveEntries = %04lx Flags = %s%s%s\n",
666 Resource->ActiveEntries,
667 IsOwnedExclusive(Resource) ? "IsOwnedExclusive " : "",
668 IsSharedWaiting(Resource) ? "SharedWaiter " : "",
669 IsExclusiveWaiting(Resource) ? "ExclusiveWaiter " : "");
670 DPRINT1(" NumberOfExclusiveWaiters = %04lx\n",
671 Resource->NumberOfExclusiveWaiters);
672 DPRINT1(" Thread = %08lx, Count = %02x\n",
673 Resource->OwnerEntry.OwnerThread,
674 Resource->OwnerEntry.OwnerCount);
675
676 /* Dump out the table too */
677 Owner = Resource->OwnerTable;
678 if (Owner)
679 {
680 /* Loop every entry */
681 Size = Owner->TableSize;
682 for (i = 1; i < Size; i++)
683 {
684 /* Print the data */
685 Owner++;
686 DPRINT1(" Thread = %08lx, Count = %02x\n",
687 Owner->OwnerThread,
688 Owner->OwnerCount);
689 }
690 }
691
692 /* Break */
694 DPRINT1("EX - Rewaiting\n");
696#endif
697 }
698
699 /* Check if we can boost */
701 {
702 /* Get the current kernel thread and lock the dispatcher */
704 Thread->WaitIrql = KiAcquireDispatcherLock();
705 Thread->WaitNext = TRUE;
706
707 /* Get the owner thread and boost it */
708 OwnerThread = (PKTHREAD)Resource->OwnerEntry.OwnerThread;
709 if (OwnerThread) ExpBoostOwnerThread(Thread, OwnerThread);
710
711 /* If it's a shared resource */
713 {
714 /* Get the table */
715 Owner = Resource->OwnerTable;
716 if (Owner)
717 {
718 /* Loop every entry */
719 Size = Owner->TableSize;
720 for (i = 1; i < Size; i++)
721 {
722 /* Move to next entry */
723 Owner++;
724
725 /* Get the thread */
726 OwnerThread = (PKTHREAD)Owner->OwnerThread;
727
728 /* Boost it */
729 if (OwnerThread) ExpBoostOwnerThread(Thread, OwnerThread);
730 }
731 }
732 }
733 }
734 }
735}
LONG NTSTATUS
Definition: precomp.h:26
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
Status
Definition: gdiplustypes.h:25
NTSYSAPI void WINAPI DbgBreakPoint(void)
if(dx< 0)
Definition: linetemp.h:194
ULONG ExpResourceTimeoutCount
Definition: resource.c:77
#define IsBoostAllowed(r)
Definition: resource.c:19
VOID FASTCALL ExpBoostOwnerThread(IN PKTHREAD Thread, IN PKTHREAD OwnerThread)
Definition: resource.c:576
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
static ULONG Timeout
Definition: ping.c:61
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
@ WrResource
Definition: ketypes.h:442

Referenced by ExAcquireResourceExclusiveLite(), ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), and ExAcquireSharedWaitForExclusive().

◆ ExReinitializeResourceLite()

NTSTATUS NTAPI ExReinitializeResourceLite ( IN PERESOURCE  Resource)

Definition at line 1761 of file resource.c.

1762{
1763 PKEVENT Event;
1764 PKSEMAPHORE Semaphore;
1765 ULONG i, Size;
1767
1768 /* Get the owner table */
1769 Owner = Resource->OwnerTable;
1770 if (Owner)
1771 {
1772 /* Get the size and loop it */
1773 Size = Owner->TableSize;
1774 for (i = 0; i < Size; i++)
1775 {
1776 /* Zero the table */
1777 Owner[i].OwnerThread = 0;
1778 Owner[i].OwnerCount = 0;
1779 }
1780 }
1781
1782 /* Zero the flags and count */
1783 Resource->Flag = 0;
1784 Resource->ActiveCount = 0;
1785 Resource->ActiveEntries = 0;
1786
1787 /* Reset the semaphore */
1788 Semaphore = Resource->SharedWaiters;
1789 if (Semaphore) KeInitializeSemaphore(Semaphore, 0, MAXLONG);
1790
1791 /* Reset the event */
1792 Event = Resource->ExclusiveWaiters;
1794
1795 /* Clear the resource data */
1796 Resource->OwnerEntry.OwnerThread = 0;
1797 Resource->OwnerEntry.OwnerCount = 0;
1798 Resource->ContentionCount = 0;
1799 Resource->NumberOfSharedWaiters = 0;
1800 Resource->NumberOfExclusiveWaiters = 0;
1801 return STATUS_SUCCESS;
1802}

Referenced by START_TEST().

◆ ExReleaseResourceAndLeaveCriticalRegion()

VOID FASTCALL ExReleaseResourceAndLeaveCriticalRegion ( IN PERESOURCE  Resource)

Definition at line 2283 of file resource.c.

2284{
2285 /* Release the resource */
2287
2288 /* Leave critical region */
2290}
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822

Referenced by _Releases_lock_().

◆ ExReleaseResourceForThreadLite()

VOID NTAPI ExReleaseResourceForThreadLite ( IN PERESOURCE  Resource,
IN ERESOURCE_THREAD  Thread 
)

Definition at line 1849 of file resource.c.

1851{
1852 ULONG i;
1853 ULONG Count;
1856 ASSERT(Thread != 0);
1857
1858 /* Get the thread and lock the resource */
1860
1861 /* Sanity checks */
1864
1865 /* Check if it's exclusively owned */
1867 {
1868 /* Decrement owner count and check if we're done */
1869 ASSERT(Resource->OwnerEntry.OwnerThread == Thread);
1870 if (--Resource->OwnerEntry.OwnerCount)
1871 {
1872 /* Done, release lock! */
1874 return;
1875 }
1876
1877 /* Clear the owner */
1878 Resource->OwnerEntry.OwnerThread = 0;
1879
1880 /* Decrement the number of active entries */
1881 ASSERT(Resource->ActiveEntries == 1);
1882 Resource->ActiveEntries--;
1883
1884 /* Check if there are shared waiters */
1886 {
1887 /* Remove the exclusive flag */
1888 Resource->Flag &= ~ResourceOwnedExclusive;
1889
1890 /* Give ownage to another thread */
1891 Count = Resource->NumberOfSharedWaiters;
1892 Resource->ActiveEntries = Count;
1893 Resource->NumberOfSharedWaiters = 0;
1894
1895 /* Release lock and let someone else have it */
1896 ASSERT(Resource->ActiveCount == 1);
1898 KeReleaseSemaphore(Resource->SharedWaiters, 0, Count, FALSE);
1899 return;
1900 }
1901 else if (IsExclusiveWaiting(Resource))
1902 {
1903 /* Give exclusive access */
1904 Resource->OwnerEntry.OwnerThread = 1;
1905 Resource->OwnerEntry.OwnerCount = 1;
1906 Resource->ActiveEntries = 1;
1907 Resource->NumberOfExclusiveWaiters--;
1908
1909 /* Release the lock and give it away */
1910 ASSERT(Resource->ActiveCount == 1);
1912 KeSetEventBoostPriority(Resource->ExclusiveWaiters,
1913 (PKTHREAD*)&Resource->OwnerEntry.OwnerThread);
1914 return;
1915 }
1916
1917 /* Remove the exclusive flag */
1918 Resource->Flag &= ~ResourceOwnedExclusive;
1919 Resource->ActiveCount = 0;
1920 }
1921 else
1922 {
1923 /* Check if we are in the thread list */
1924 if (Resource->OwnerEntry.OwnerThread == Thread)
1925 {
1926 /* Found it, get owner */
1927 Owner = &Resource->OwnerEntry;
1928 }
1929 else
1930 {
1931 /* Assume no valid index */
1932 i = 1;
1933
1934 /* If we got a valid pointer, try to get the resource index */
1935 if (!((ULONG)Thread & 3)) i = ((PKTHREAD)Thread)->ResourceIndex;
1936
1937 /* Do a table lookup */
1938 Owner = Resource->OwnerTable;
1939 ASSERT(Owner != NULL);
1940
1941 /* Check if we're out of the size and don't match */
1942 if ((i >= Owner->TableSize) || (Owner[i].OwnerThread != Thread))
1943 {
1944 /* Get the last entry */
1945 Limit = &Owner[Owner->TableSize];
1946 for (;;)
1947 {
1948 /* Move to the next entry */
1949 Owner++;
1950
1951 /* Make sure we're not out of bounds */
1952 if (Owner >= Limit)
1953 {
1954 /* Bugcheck, nobody owns us */
1955 KeBugCheckEx(RESOURCE_NOT_OWNED,
1958 (ULONG_PTR)Resource->OwnerTable,
1959 (ULONG_PTR)3);
1960 }
1961
1962 /* Check for a match */
1963 if (Owner->OwnerThread == Thread) break;
1964 }
1965 }
1966 else
1967 {
1968 /* Get the entry directly */
1969 Owner = &Owner[i];
1970 }
1971 }
1972
1973 /* Sanity checks */
1974 ASSERT(Owner->OwnerThread == Thread);
1975 ASSERT(Owner->OwnerCount > 0);
1976
1977 /* Check if we are the last owner */
1978 if (--Owner->OwnerCount)
1979 {
1980 /* There are other owners, release lock */
1982 return;
1983 }
1984
1985 /* Clear owner */
1986 Owner->OwnerThread = 0;
1987
1988 /* See if the resource isn't being owned anymore */
1989 ASSERT(Resource->ActiveEntries > 0);
1990 if (!(--Resource->ActiveEntries))
1991 {
1992 /* Check if there's an exclusive waiter */
1994 {
1995 /* Give exclusive access */
1997 Resource->OwnerEntry.OwnerThread = 1;
1998 Resource->OwnerEntry.OwnerCount = 1;
1999 Resource->ActiveEntries = 1;
2000 Resource->NumberOfExclusiveWaiters--;
2001
2002 /* Release the lock and give it away */
2003 ASSERT(Resource->ActiveCount == 1);
2005 KeSetEventBoostPriority(Resource->ExclusiveWaiters,
2006 (PKTHREAD*)&Resource->OwnerEntry.OwnerThread);
2007 return;
2008 }
2009
2010 /* Clear the active count */
2011 Resource->ActiveCount = 0;
2012 }
2013 }
2014
2015 /* Release lock */
2017}
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ ExReleaseResourceLite()

VOID FASTCALL ExReleaseResourceLite ( IN PERESOURCE  Resource)

Definition at line 1822 of file resource.c.

1823{
1824 /* Just call the For-Thread function */
1826}
#define ExReleaseResourceForThreadLite(res, thrdID)
Definition: env_spec_w32.h:635

Referenced by __attribute__(), __brelse(), __RxAcquireFcb(), __RxReleaseFcb(), _Dispatch_type_(), _Function_class_(), _Requires_lock_held_(), acquire_for_lazy_write(), add_balance_item(), add_children_to_move_list(), add_device(), add_dir_child(), add_metadata_reloc_extent_item(), add_volume_device(), AddUnregisteredProvider(), allocate_cache(), ApphelpCacheReleaseLock(), balance_data_chunk(), balance_metadata_chunk(), BroadcastOpen(), BuildAndSubmitIrp(), bus_query_device_relations(), CcUnpinRepinnedBcb(), check_system_root(), chunk_lock_range(), chunk_unlock_range(), clean_space_cache(), clear_free_space_cache(), close_file(), CmpUnlockHiveFlusher(), CmpUnlockRegistry(), CountAvailableClusters(), create_snapshot(), create_stream(), create_subvol(), CreateRedirectedFile(), delete_fileref(), delete_reparse_point(), disk_arrival(), dismount_volume(), do_create_snapshot(), do_flush(), do_read_job(), do_tree_writes(), do_write2(), DoQuery(), drive_letter_callback2(), duplicate_extents(), DxEngUnlockHdev(), Ex2ProcessUserPerfStat(), ExReleaseResourceAndLeaveCriticalRegion(), ExReleaseTimeRefreshLock(), Ext2AddEntry(), Ext2bhReaperThread(), Ext2CheckDismount(), Ext2Cleanup(), Ext2CleanupAllMcbs(), Ext2Close(), Ext2Create(), Ext2CreateFile(), Ext2DeleteFile(), Ext2DeleteReparsePoint(), Ext2DismountVolume(), Ext2DropBH(), Ext2ExceptionHandler(), Ext2FastIoQueryBasicInfo(), Ext2FastIoQueryNetworkOpenInfo(), Ext2FastIoQueryStandardInfo(), Ext2FastIoWrite(), Ext2FcbReaperThread(), Ext2FirstUnusedMcb(), Ext2FloppyFlush(), Ext2Flush(), Ext2FlushFiles(), Ext2FlushVcb(), Ext2FlushVolume(), Ext2FreeBlock(), Ext2FreeInode(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2InsertMcb(), Ext2InvalidateVolumes(), Ext2LinkHeadMcb(), Ext2LinkTailMcb(), Ext2LoadGroup(), Ext2LoadGroupBH(), Ext2LockControl(), Ext2LockVolume(), Ext2LookupFile(), Ext2McbReaperThread(), Ext2MediaEjectControl(), Ext2MountVolume(), Ext2NewBlock(), Ext2NewInode(), Ext2NotifyChangeDirectory(), Ext2OplockRequest(), Ext2ProcessGlobalProperty(), Ext2ProcessVolumeProperty(), Ext2PurgeFile(), Ext2PurgeVolume(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2QueryFileInformation(), Ext2QueryRetrievalPointers(), Ext2QueryUnusedBH(), Ext2QueryUnusedFcb(), Ext2QueryVolumeInformation(), Ext2ReadFile(), Ext2ReadVolume(), Ext2RecoverJournal(), Ext2ReleaseFcb(), Ext2ReleaseFileForCcFlush(), Ext2ReleaseFileForModWrite(), Ext2ReleaseForCreateSection(), Ext2ReleaseFromLazyWrite(), Ext2ReleaseFromReadAhead(), Ext2RemoveEntry(), Ext2RemoveMcb(), Ext2SearchMcb(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetFileType(), Ext2SetLinkInfo(), Ext2SetParentEntry(), Ext2SetRenameInfo(), Ext2SetReparsePoint(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2UnlinkFcb(), Ext2UnlinkMcb(), Ext2UnlockVolume(), Ext2UpdateGroupDirStat(), Ext2VerifyVolume(), Ext2WriteFile(), Ext2WriteVolume(), fast_io_release_for_create_section(), FatDeferredFlush(), file_create(), file_create2(), fill_in_file_stream_information(), fill_in_hard_link_full_id_information(), fill_in_hard_link_information(), find_device_from_uuid(), find_file_in_dir(), find_gid(), find_subvol(), finish_removing_device(), FltEnumerateVolumes(), FltUnregisterFilter(), flush_fcb(), fsctl_get_xattrs(), fsctl_oplock(), fsctl_set_xattr(), FsRtlAcquireFileForModWriteEx(), FsRtlCopyRead(), FsRtlCopyRead2(), FsRtlCopyWrite(), FsRtlCopyWrite2(), FsRtlMdlReadDev(), FsRtlPrepareMdlWriteDev(), FsRtlReleaseFile(), FsRtlReleaseFileForCcFlush(), FsRtlReleaseFileForModWrite(), get_block_bh_mdl(), get_block_bh_pin(), get_csum_info(), get_devices(), get_inode_info(), get_object_id(), get_reparse_point(), get_reparse_tag(), get_retrieval_pointers(), get_subvol_path(), get_tree_new_address(), get_usage(), GetDirtyStatus(), GetNextCluster(), GetNextClusterExtend(), IncreaseMftSize(), insert_extent_chunk(), invalidate_volumes(), IoEnumerateRegisteredFiltersList(), IopBootLog(), IopGetSetSecurityObject(), IopLoadDriver(), IopMountVolume(), IopParseDevice(), IopSaveBootLogToFile(), IopSetDeviceSecurityDescriptor(), IoRegisterFileSystem(), IoRegisterFsRegistrationChange(), IoUnregisterFileSystem(), IoUnregisterFsRegistrationChange(), is_device_part_of_mounted_btrfs_raid(), is_volume_mounted(), KspSynchronizedEventRoutine(), KsReleaseDeviceSecurityLock(), load_chunk_root(), lock_volume(), log_error(), log_file_checksum_error(), log_tree_checksum_error(), mark_fcb_dirty(), mark_fileref_dirty(), mark_subvol_dirty(), MiFindInitializationCode(), MiProcessLoaderEntry(), mknod(), MmGetSystemRoutineAddress(), MmInitSystem(), mount_vol(), mountmgr_process_drive(), move_across_subvols(), MupCheckForUnregisteredProvider(), MupCleanup(), MupCleanupFcb(), MupCleanupVcb(), MupCloseFcb(), MupCloseUncProvider(), MupCloseVcb(), MupDecodeFileObject(), MupDereferenceCcb(), MupDereferenceMasterQueryContext(), MupForwardIoRequest(), MupInvalidatePrefixTable(), notify_change_directory(), NpCommonFlushBuffers(), NpCommonRead(), NpCommonWrite(), NpDisconnect(), NpListen(), NpQueryClientProcess(), NpReleaseVcb(), NpSetClientProcess(), NpTransceive(), NtfsCleanup(), NtfsCleanupFile(), NtfsClose(), NtfsCreate(), NtfsCreateFile(), NtfsQueryDirectory(), NtfsQueryInformation(), NtfsQueryVolumeInformation(), NtfsSetInformation(), NtfsWrite(), NtQueryInformationJobObject(), ObpLeaveObjectTypeMutex(), ObpReleaseObjectLock(), open_file(), open_fileref_by_inode(), open_fileref_child(), OpenMupFileSystem(), oplock_complete(), pdo_device_usage_notification(), pnp_query_remove_device(), pnp_remove_device(), pnp_surprise_removal(), QSI_DEF(), query_directory(), query_filesystems(), query_info(), query_ranges(), query_scrub(), QueryPathCompletionRoutine(), read_data_raid5(), read_data_raid6(), read_registry(), read_send_buffer(), ReadVolumeLabel(), recvd_subvol(), RegisterUncProvider(), release_from_lazy_write(), release_from_read_ahead(), remove_balance_item(), remove_device(), remove_volume_child(), reset_stats(), resize_device(), RtlLeaveHeapLock(), RxAcquireFcbForLazyWrite(), RxAcquireFcbForReadAhead(), RxFindOrCreateFcb(), RxpReleasePrefixTableLock(), RxReleaseFcbFromLazyWrite(), RxReleaseFcbFromReadAhead(), RxStartMinirdr(), scrub_chunk(), send_notification_fcb(), send_subvol(), set_basic_information(), set_case_sensitive_information(), set_disposition_information(), set_end_of_file_information(), set_file_security(), set_inode_info(), set_label(), set_link_information(), set_rename_information(), set_reparse_point(), set_sparse(), set_valid_data_length_information(), set_zero_data(), SetDirtyStatus(), sid_to_uid(), TestResourceExclusiveAccess(), TestResourceSharedAccess(), try_consolidation(), uid_to_sid(), uninit(), update_changed_extent_ref(), update_chunk_caches(), update_chunk_caches_tree(), update_chunk_usage(), update_chunks(), update_root_root(), update_volumes(), UserLeave(), verify_device(), verify_vcb(), verify_volume(), VfatCheckForDismount(), VfatCleanup(), VfatCleanupFile(), VfatClose(), VfatCloseWorker(), VfatCreate(), VfatCreateFile(), VfatDismountVolume(), VfatFastIoQueryBasicInfo(), VfatFastIoQueryStandardInfo(), vfatFCBInitializeCacheFromVolume(), VfatFlush(), VfatFlushFile(), VfatFlushVolume(), VfatGetRetrievalPointers(), VfatMount(), VfatQueryInformation(), VfatQueryVolumeInformation(), VfatRead(), VfatReleaseForCcFlush(), VfatReleaseFromLazyWrite(), VfatSetInformation(), VfatSetVolumeInformation(), VfatShutdown(), VfatWrite(), vol_check_verify(), vol_close(), vol_get_device_number(), vol_get_disk_extents(), vol_get_drive_geometry(), vol_get_length(), vol_ioctl_passthrough(), vol_is_writable(), vol_read(), vol_write(), volume_arrival(), volume_removal(), wait_for_flush(), write_compressed(), write_metadata_items(), and WriteCluster().

◆ ExReleaseResourceLock()

◆ ExSetResourceOwnerPointer()

VOID NTAPI ExSetResourceOwnerPointer ( IN PERESOURCE  Resource,
IN PVOID  OwnerPointer 
)

Definition at line 2050 of file resource.c.

2052{
2055 POWNER_ENTRY Owner, ThisOwner;
2056
2057 /* Sanity check */
2058 ASSERT((OwnerPointer != 0) && (((ULONG_PTR)OwnerPointer & 3) == 3));
2059
2060 /* Get the thread */
2062
2063 /* Sanity check */
2065
2066 /* Lock the resource */
2068
2069 /* Check if it's exclusive */
2071 {
2072 /* If it's exclusive, set the first entry no matter what */
2073 ASSERT(Resource->OwnerEntry.OwnerThread == Thread);
2074 ASSERT(Resource->OwnerEntry.OwnerCount > 0);
2075 Resource->OwnerEntry.OwnerThread = (ULONG_PTR)OwnerPointer;
2076 }
2077 else
2078 {
2079 /* Set the thread in both entries */
2080 ThisOwner = ExpFindEntryForThread(Resource,
2082 0,
2083 FALSE);
2085 if (!Owner)
2086 {
2087 /* Nobody owns it, crash */
2088 KeBugCheckEx(RESOURCE_NOT_OWNED,
2090 Thread,
2091 (ULONG_PTR)Resource->OwnerTable,
2092 3);
2093 }
2094
2095 /* Set if we are the owner */
2096 if (ThisOwner)
2097 {
2098 /* Update data */
2099 ThisOwner->OwnerCount += Owner->OwnerCount;
2100 Owner->OwnerCount = 0;
2101 Owner->OwnerThread = 0;
2102 ASSERT(Resource->ActiveEntries >= 2);
2103 Resource->ActiveEntries--;
2104 }
2105 else
2106 {
2107 /* Update the owner entry instead */
2108 Owner->OwnerThread = (ERESOURCE_THREAD)OwnerPointer;
2109 }
2110 }
2111
2112 /* Release the resource */
2114}
#define ULONG_PTR
Definition: config.h:101
ULONG OwnerCount
Definition: extypes.h:216
_In_ PVOID OwnerPointer
Definition: exfuncs.h:1070

Referenced by CcSetBcbOwnerPointer(), FatMultipleAsync(), FatSingleAsync(), RxCommonRead(), RxCommonWrite(), and TestResourceWithOwner().

◆ ExTryToAcquireResourceExclusiveLite()

BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite ( IN PERESOURCE  Resource)

Definition at line 2134 of file resource.c.

2135{
2138 BOOLEAN Acquired = FALSE;
2139
2140 /* Sanity check */
2141 ASSERT((Resource->Flag & ResourceNeverExclusive) == 0);
2142
2143 /* Get the thread */
2145
2146 /* Sanity check and validation */
2149
2150 /* Acquire the lock */
2152
2153 /* Check if there is an owner */
2154 if (!Resource->ActiveCount)
2155 {
2156 /* No owner, give exclusive access */
2158 Resource->OwnerEntry.OwnerThread = Thread;
2159 Resource->OwnerEntry.OwnerCount = 1;
2160 Resource->ActiveCount = 1;
2161 Resource->ActiveEntries = 1;
2162 Acquired = TRUE;
2163 }
2164 else if ((IsOwnedExclusive(Resource)) &&
2165 (Resource->OwnerEntry.OwnerThread == Thread))
2166 {
2167 /* Do a recursive acquire */
2168 Resource->OwnerEntry.OwnerCount++;
2169 Acquired = TRUE;
2170 }
2171
2172 /* Release the resource */
2174 return Acquired;
2175}

Referenced by ApphelpCacheTryAcquireLock().

Variable Documentation

◆ ExpResourceSpinLock

KSPIN_LOCK ExpResourceSpinLock

◆ ExpResourceTimeoutCount

ULONG ExpResourceTimeoutCount = 90 * 3600 / 2

Definition at line 77 of file resource.c.

Referenced by ExpWaitForResource().

◆ ExpSystemResourcesList

LIST_ENTRY ExpSystemResourcesList

Definition at line 80 of file resource.c.

Referenced by ExInitializeResourceLite(), and ExpResourceInitialization().

◆ ExpTimeout

LARGE_INTEGER ExpTimeout

Definition at line 74 of file resource.c.

Referenced by ExpResourceInitialization(), and ExpWaitForResource().

◆ ExResourceStrict

BOOLEAN ExResourceStrict = TRUE

Definition at line 81 of file resource.c.

◆ ExShortTime

LARGE_INTEGER ExShortTime = {{-100000, -1}}

Definition at line 73 of file resource.c.

Referenced by ExpAllocateExclusiveWaiterEvent(), and ExpAllocateSharedWaiterSemaphore().