+++ /dev/null
-/*\r
- * COPYRIGHT: See COPYING in the top level directory\r
- * PROJECT: ReactOS kernel\r
- * FILE: ntoskrnl/cc/ccmutex.c\r
- * PURPOSE: Implements the Broken Mutex Implementation for the broken Cc\r
- * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)\r
- */\r
-\r
-/* INCLUDES *****************************************************************/\r
-\r
-#include <ntoskrnl.h>\r
-#include <internal/debug.h>\r
-\r
-/* FUNCTIONS *****************************************************************/\r
-\r
-VOID\r
-FASTCALL\r
-CcAcquireBrokenMutexUnsafe(PFAST_MUTEX FastMutex)\r
-{\r
- ASSERT(KeGetCurrentThread() == NULL ||\r
- FastMutex->Owner != KeGetCurrentThread());\r
- ASSERT(KeGetCurrentIrql() == APC_LEVEL || \r
- KeGetCurrentThread() == NULL || \r
- KeGetCurrentThread()->KernelApcDisable);\r
- \r
- InterlockedIncrementUL(&FastMutex->Contention);\r
- while (InterlockedExchange(&FastMutex->Count, 0) == 0)\r
- {\r
- KeWaitForSingleObject(&FastMutex->Gate,\r
- Executive,\r
- KernelMode,\r
- FALSE,\r
- NULL);\r
- }\r
- InterlockedDecrementUL(&FastMutex->Contention);\r
- FastMutex->Owner = KeGetCurrentThread();\r
-}\r
-\r
-VOID\r
-FASTCALL\r
-CcReleaseBrokenMutexUnsafe(PFAST_MUTEX FastMutex)\r
-{\r
- ASSERT(KeGetCurrentThread() == NULL ||\r
- FastMutex->Owner == KeGetCurrentThread());\r
- ASSERT(KeGetCurrentIrql() == APC_LEVEL || \r
- KeGetCurrentThread() == NULL || \r
- KeGetCurrentThread()->KernelApcDisable);\r
- \r
- FastMutex->Owner = NULL;\r
- InterlockedExchange(&FastMutex->Count, 1);\r
- if (FastMutex->Contention > 0)\r
- {\r
- KeSetEvent(&FastMutex->Gate, 0, FALSE);\r
- }\r
-}\r
-\r
-VOID \r
-FASTCALL\r
-CcAcquireBrokenMutex(PFAST_MUTEX FastMutex)\r
-{\r
- KeEnterCriticalRegion();\r
- CcAcquireBrokenMutexUnsafe(FastMutex);\r
-}\r
-\r
-\r
-VOID\r
-FASTCALL\r
-CcReleaseBrokenMutex(PFAST_MUTEX FastMutex)\r
-{\r
- CcReleaseBrokenMutexUnsafe(FastMutex);\r
- KeLeaveCriticalRegion();\r
-}\r
-\r
-BOOLEAN\r
-FASTCALL\r
-CcTryToAcquireBrokenMutex(PFAST_MUTEX FastMutex)\r
-{\r
- KeEnterCriticalRegion();\r
- if (InterlockedExchange(&FastMutex->Count, 0) == 1)\r
- {\r
- FastMutex->Owner = KeGetCurrentThread();\r
- return(TRUE);\r
- }\r
- else\r
- {\r
- KeLeaveCriticalRegion();\r
- return(FALSE);\r
- }\r
-}\r