Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2000
  3. Module Name:
  4. lock.c
  5. Abstract:
  6. This file contains code iSCSI Port driver
  7. Environment:
  8. kernel mode only
  9. Revision History:
  10. --*/
  11. #include "port.h"
  12. ULONG
  13. iSpAcquireRemoveLock(
  14. IN PDEVICE_OBJECT DeviceObject,
  15. IN OPTIONAL PVOID Tag
  16. )
  17. {
  18. PCOMMON_EXTENSION commonExtension = DeviceObject->DeviceExtension;
  19. LONG lockValue;
  20. lockValue = InterlockedIncrement(&(commonExtension->RemoveLock));
  21. ASSERTMSG("iSpAcquireRemoveLock : lock value was negative ",
  22. (lockValue > 0));
  23. return (commonExtension->IsRemoved);
  24. }
  25. VOID
  26. iSpReleaseRemoveLock(
  27. IN PDEVICE_OBJECT DeviceObject,
  28. IN OPTIONAL PVOID Tag
  29. )
  30. {
  31. PCOMMON_EXTENSION commonExtension = DeviceObject->DeviceExtension;
  32. LONG lockValue;
  33. lockValue = InterlockedDecrement(&(commonExtension->RemoveLock));
  34. if (lockValue < 0) {
  35. ASSERTMSG("iSpReleaseRemoveLock : lock value was negative ",
  36. (lockValue >= 0));
  37. }
  38. if (lockValue == 0) {
  39. DebugPrint((3, "Releaselock for device object %x\n",
  40. DeviceObject));
  41. KeSetEvent(&(commonExtension->RemoveEvent),
  42. IO_NO_INCREMENT,
  43. FALSE);
  44. }
  45. return;
  46. }