2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/io/pnpmgr/remlock.c
5 * PURPOSE: Remove Lock functions
6 * PROGRAMMER: Filip Navara (xnavara@volny.cz)
8 * 22/09/2003 FiN Created
11 /* INCLUDES ******************************************************************/
14 #include <internal/debug.h>
16 /* FUNCTIONS *****************************************************************/
23 IoInitializeRemoveLockEx(
24 IN PIO_REMOVE_LOCK RemoveLock
,
26 IN ULONG MaxLockedMinutes
,
27 IN ULONG HighWatermark
,
30 DPRINT("IoInitializeRemoveLockEx called");
31 RtlZeroMemory(RemoveLock
, RemlockSize
);
32 RemoveLock
->Common
.IoCount
= 1;
33 KeInitializeEvent(&RemoveLock
->Common
.RemoveEvent
, NotificationEvent
, FALSE
);
41 IoAcquireRemoveLockEx(
42 IN PIO_REMOVE_LOCK RemoveLock
,
43 IN OPTIONAL PVOID Tag
,
48 DPRINT("IoAcquireRemoveLockEx called");
49 InterlockedIncrement(&RemoveLock
->Common
.IoCount
);
50 if (RemoveLock
->Common
.Removed
)
52 if (InterlockedDecrement(&RemoveLock
->Common
.IoCount
) == 0)
54 KeSetEvent(&RemoveLock
->Common
.RemoveEvent
, IO_NO_INCREMENT
, FALSE
);
56 return STATUS_DELETE_PENDING
;
58 return STATUS_SUCCESS
;
66 IoReleaseRemoveLockEx(
67 IN PIO_REMOVE_LOCK RemoveLock
,
73 DPRINT("IoReleaseRemoveLockEx called");
74 IoCount
= InterlockedDecrement(&RemoveLock
->Common
.IoCount
);
77 KeSetEvent(&RemoveLock
->Common
.RemoveEvent
, IO_NO_INCREMENT
, FALSE
);
86 IoReleaseRemoveLockAndWaitEx(
87 IN PIO_REMOVE_LOCK RemoveLock
,
91 DPRINT("IoReleaseRemoveLockAndWaitEx called");
92 RemoveLock
->Common
.Removed
= TRUE
;
93 InterlockedDecrement(&RemoveLock
->Common
.IoCount
);
94 IoReleaseRemoveLockEx(RemoveLock
, Tag
, RemlockSize
);
95 KeWaitForSingleObject(&RemoveLock
->Common
.RemoveEvent
, Executive
, KernelMode
,