Index: subsys/win32k/ntuser/guicheck.c =================================================================== --- subsys/win32k/ntuser/guicheck.c (revision 13570) +++ subsys/win32k/ntuser/guicheck.c (working copy) @@ -41,7 +41,6 @@ /* GLOBALS *******************************************************************/ static LONG NrGuiAppsRunning = 0; -static FAST_MUTEX GuiSwitchLock; /* FUNCTIONS *****************************************************************/ @@ -53,9 +52,7 @@ { BOOL Initialized; - ExAcquireFastMutex(&GuiSwitchLock); Initialized = IntInitializeDesktopGraphics(); - ExReleaseFastMutex(&GuiSwitchLock); if (!Initialized) { @@ -73,9 +70,7 @@ W32Data->Flags &= ~W32PF_CREATEDWINORDC; if (InterlockedDecrement(&NrGuiAppsRunning) == 0) { - ExAcquireFastMutex(&GuiSwitchLock); IntEndDesktopGraphics(); - ExReleaseFastMutex(&GuiSwitchLock); } } @@ -132,7 +127,6 @@ NTSTATUS FASTCALL InitGuiCheckImpl (VOID) { - ExInitializeFastMutex(&GuiSwitchLock); return STATUS_SUCCESS; } Index: subsys/win32k/include/msgqueue.h =================================================================== --- subsys/win32k/include/msgqueue.h (revision 13570) +++ subsys/win32k/include/msgqueue.h (working copy) @@ -218,10 +218,10 @@ VOID STDCALL MsqRemoveWindowMessagesFromQueue(PVOID pWindow); /* F*(&$ headers, will be gone in the rewrite! */ #define IntLockMessageQueue(MsgQueue) \ - ExAcquireFastMutex(&(MsgQueue)->Lock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(MsgQueue)->Lock) #define IntUnLockMessageQueue(MsgQueue) \ - ExReleaseFastMutex(&(MsgQueue)->Lock) + ExReleaseFastMutexUnsafe(&(MsgQueue)->Lock), KeLeaveCriticalRegion() #define IntLockHardwareMessageQueue(MsgQueue) \ KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL) Index: subsys/win32k/include/hotkey.h =================================================================== --- subsys/win32k/include/hotkey.h (revision 13570) +++ subsys/win32k/include/hotkey.h (working copy) @@ -37,10 +37,10 @@ UnregisterThreadHotKeys(struct _ETHREAD *Thread); #define IntLockHotKeys(WinStaObject) \ - ExAcquireFastMutex(&WinStaObject->HotKeyListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&WinStaObject->HotKeyListLock) #define IntUnLockHotKeys(WinStaObject) \ - ExReleaseFastMutex(&WinStaObject->HotKeyListLock) + ExReleaseFastMutexUnsafe(&WinStaObject->HotKeyListLock), KeLeaveCriticalRegion() #endif /* _WIN32K_HOTKEY_H */ Index: subsys/win32k/include/class.h =================================================================== --- subsys/win32k/include/class.h (revision 13570) +++ subsys/win32k/include/class.h (working copy) @@ -40,16 +40,16 @@ CleanupClassImpl(VOID); #define IntLockProcessClasses(W32Process) \ - ExAcquireFastMutex(&(W32Process)->ClassListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(W32Process)->ClassListLock) #define IntUnLockProcessClasses(W32Process) \ - ExReleaseFastMutex(&(W32Process)->ClassListLock) + ExReleaseFastMutexUnsafe(&(W32Process)->ClassListLock), KeLeaveCriticalRegion() #define IntLockClassWindows(ClassObj) \ - ExAcquireFastMutex(&(ClassObj)->ClassWindowsListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(ClassObj)->ClassWindowsListLock) #define IntUnLockClassWindows(ClassObj) \ - ExReleaseFastMutex(&(ClassObj)->ClassWindowsListLock) + ExReleaseFastMutexUnsafe(&(ClassObj)->ClassWindowsListLock), KeLeaveCriticalRegion() #define ClassDereferenceObject(ClassObj) \ ObmDereferenceObject(ClassObj) Index: subsys/win32k/include/object.h =================================================================== --- subsys/win32k/include/object.h (revision 13570) +++ subsys/win32k/include/object.h (working copy) @@ -49,10 +49,10 @@ #define ObmpLockHandleTable(HandleTable) \ - ExAcquireFastMutex(&HandleTable->ListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&HandleTable->ListLock) #define ObmpUnlockHandleTable(HandleTable) \ - ExReleaseFastMutex(&HandleTable->ListLock) + ExReleaseFastMutexUnsafe(&HandleTable->ListLock), KeLeaveCriticalRegion() ULONG FASTCALL ObmGetReferenceCount( Index: subsys/win32k/include/painting.h =================================================================== --- subsys/win32k/include/painting.h (revision 13570) +++ subsys/win32k/include/painting.h (working copy) @@ -18,9 +18,9 @@ NtUserValidateRgn(HWND hWnd, HRGN hRgn); #define IntLockWindowUpdate(Window) \ - ExAcquireFastMutex(&Window->UpdateLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&Window->UpdateLock) #define IntUnLockWindowUpdate(Window) \ - ExReleaseFastMutex(&Window->UpdateLock) + ExReleaseFastMutexUnsafe(&Window->UpdateLock), KeLeaveCriticalRegion() #endif /* _WIN32K_PAINTING_H */ Index: subsys/win32k/include/text.h =================================================================== --- subsys/win32k/include/text.h (revision 13570) +++ subsys/win32k/include/text.h (working copy) @@ -8,21 +8,21 @@ INT FASTCALL FontGetObject(PTEXTOBJ TextObj, INT Count, PVOID Buffer); #define IntLockProcessPrivateFonts(W32Process) \ - ExAcquireFastMutex(&W32Process->PrivateFontListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock) #define IntUnLockProcessPrivateFonts(W32Process) \ - ExReleaseFastMutex(&W32Process->PrivateFontListLock) + ExReleaseFastMutexUnsafe(&W32Process->PrivateFontListLock), KeLeaveCriticalRegion() #define IntLockGlobalFonts \ - ExAcquireFastMutex(&FontListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&FontListLock) #define IntUnLockGlobalFonts \ - ExReleaseFastMutex(&FontListLock) + ExReleaseFastMutexUnsafe(&FontListLock), KeLeaveCriticalRegion() #define IntLockFreeType \ - ExAcquireFastMutex(&FreeTypeLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&FreeTypeLock) #define IntUnLockFreeType \ - ExReleaseFastMutex(&FreeTypeLock) + ExReleaseFastMutexUnsafe(&FreeTypeLock), KeLeaveCriticalRegion() #endif /* _WIN32K_TEXT_H */ Index: subsys/win32k/include/cursoricon.h =================================================================== --- subsys/win32k/include/cursoricon.h (revision 13570) +++ subsys/win32k/include/cursoricon.h (working copy) @@ -65,10 +65,10 @@ ObmDereferenceObject(CurIconObj) #define IntLockProcessCursorIcons(W32Process) \ - ExAcquireFastMutex(&W32Process->CursorIconListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&W32Process->CursorIconListLock) #define IntUnLockProcessCursorIcons(W32Process) \ - ExReleaseFastMutex(&W32Process->CursorIconListLock) + ExReleaseFastMutexUnsafe(&W32Process->CursorIconListLock), KeLeaveCriticalRegion() #endif /* _WIN32K_CURSORICON_H */ Index: subsys/win32k/include/hook.h =================================================================== --- subsys/win32k/include/hook.h (revision 13570) +++ subsys/win32k/include/hook.h (working copy) @@ -31,10 +31,10 @@ VOID FASTCALL HOOK_DestroyThreadHooks(PETHREAD Thread); #define IntLockHookTable(HookTable) \ - ExAcquireFastMutex(&HookTable->Lock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&HookTable->Lock) #define IntUnLockHookTable(HookTable) \ - ExReleaseFastMutex(&HookTable->Lock) + ExReleaseFastMutexUnsafe(&HookTable->Lock), KeLeaveCriticalRegion() #endif /* _WIN32K_HOOK_H */ Index: subsys/win32k/include/menu.h =================================================================== --- subsys/win32k/include/menu.h (revision 13570) +++ subsys/win32k/include/menu.h (working copy) @@ -45,16 +45,16 @@ IntGetMenuObject(HMENU hMenu); #define IntLockMenuItems(MenuObj) \ - ExAcquireFastMutex(&(MenuObj)->MenuItemsLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(MenuObj)->MenuItemsLock) #define IntUnLockMenuItems(MenuObj) \ - ExReleaseFastMutex(&(MenuObj)->MenuItemsLock) + ExReleaseFastMutexUnsafe(&(MenuObj)->MenuItemsLock), KeLeaveCriticalRegion() #define IntLockProcessMenus(W32Process) \ - ExAcquireFastMutex(&(W32Process)->MenuListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(W32Process)->MenuListLock) #define IntUnLockProcessMenus(W32Process) \ - ExReleaseFastMutex(&(W32Process)->MenuListLock) + ExReleaseFastMutexUnsafe(&(W32Process)->MenuListLock), KeLeaveCriticalRegion() #define IntReleaseMenuObject(MenuObj) \ ObmDereferenceObject(MenuObj) Index: subsys/win32k/include/window.h =================================================================== --- subsys/win32k/include/window.h (revision 13570) +++ subsys/win32k/include/window.h (working copy) @@ -148,16 +148,16 @@ WndObj->OwnerThread->ThreadsProcess->UniqueProcessId #define IntLockRelatives(WndObj) \ - ExAcquireFastMutex(&WndObj->RelativesLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&WndObj->RelativesLock) #define IntUnLockRelatives(WndObj) \ - ExReleaseFastMutex(&WndObj->RelativesLock) + ExReleaseFastMutexUnsafe(&WndObj->RelativesLock), KeLeaveCriticalRegion() #define IntLockThreadWindows(Thread) \ - ExAcquireFastMutex(&Thread->WindowListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&Thread->WindowListLock) #define IntUnLockThreadWindows(Thread) \ - ExReleaseFastMutex(&Thread->WindowListLock) + ExReleaseFastMutexUnsafe(&Thread->WindowListLock), KeLeaveCriticalRegion() PWINDOW_OBJECT FASTCALL Index: subsys/win32k/include/prop.h =================================================================== --- subsys/win32k/include/prop.h (revision 13570) +++ subsys/win32k/include/prop.h (working copy) @@ -15,10 +15,10 @@ IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom); #define IntLockWindowProperties(Window) \ - ExAcquireFastMutex(&Window->PropListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&Window->PropListLock) #define IntUnLockWindowProperties(Window) \ - ExReleaseFastMutex(&Window->PropListLock) + ExReleaseFastMutexUnsafe(&Window->PropListLock), KeLeaveCriticalRegion() #endif /* _WIN32K_PROP_H */ Index: subsys/win32k/include/inteng.h =================================================================== --- subsys/win32k/include/inteng.h (revision 13570) +++ subsys/win32k/include/inteng.h (working copy) @@ -33,10 +33,10 @@ /* Definitions of IntEngXxx functions */ #define IntEngLockProcessDriverObjs(W32Process) \ - ExAcquireFastMutex(&(W32Process)->DriverObjListLock) + KeEnterCriticalRegion(), ExAcquireFastMutexUnsafe(&(W32Process)->DriverObjListLock) #define IntEngUnLockProcessDriverObjs(W32Process) \ - ExReleaseFastMutex(&(W32Process)->DriverObjListLock) + ExReleaseFastMutexUnsafe(&(W32Process)->DriverObjListLock), KeLeaveCriticalRegion() VOID FASTCALL IntEngCleanupDriverObjs(struct _EPROCESS *Process, Index: hal/halx86/generic/fmutex.c =================================================================== --- hal/halx86/generic/fmutex.c (revision 13570) +++ hal/halx86/generic/fmutex.c (working copy) @@ -21,33 +21,33 @@ VOID FASTCALL ExAcquireFastMutex (PFAST_MUTEX FastMutex) { - KeEnterCriticalRegion(); + KIRQL OldIrql = KfRaiseIrql(APC_LEVEL); ExAcquireFastMutexUnsafe(FastMutex); + FastMutex->OldIrql = OldIrql; } VOID FASTCALL ExReleaseFastMutex (PFAST_MUTEX FastMutex) { - ExReleaseFastMutexUnsafe(FastMutex); - KeLeaveCriticalRegion(); + KIRQL OldIrql = FastMutex->OldIrql; + ExReleaseFastMutexUnsafe(FastMutex); + KfLowerIrql(OldIrql); } BOOLEAN FASTCALL ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex) { - KeEnterCriticalRegion(); - if (InterlockedExchange(&FastMutex->Count, 0) == 1) - { + KIRQL OldIrql = KfRaiseIrql(APC_LEVEL); + if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1) + { FastMutex->Owner = KeGetCurrentThread(); - return(TRUE); - } - else - { - KeLeaveCriticalRegion(); - return(FALSE); - } + FastMutex->OldIrql = OldIrql; + return TRUE; + } + KfLowerIrql(OldIrql); + return FALSE; } /* EOF */ Index: hal/halx86/generic/adapter.c =================================================================== --- hal/halx86/generic/adapter.c (revision 13570) +++ hal/halx86/generic/adapter.c (working copy) @@ -85,6 +85,7 @@ * buffer transfers. See a comment in IoMapTransfer about common buffer * support. */ +#if 0 AdapterObject->MapRegisterBase = MmAllocateContiguousAlignedMemory( NumberOfMapRegisters * PAGE_SIZE, MinAddress, @@ -92,6 +93,7 @@ BoundryAddressMultiple, MmCached, 0x10000 ); +#endif if(!AdapterObject->MapRegisterBase) return STATUS_INSUFFICIENT_RESOURCES; Index: ntoskrnl/ps/create.c =================================================================== --- ntoskrnl/ps/create.c (revision 13570) +++ ntoskrnl/ps/create.c (working copy) @@ -524,7 +524,8 @@ else { Process = Thread->ThreadsProcess; - ExAcquireFastMutex(&Process->TebLock); + KeEnterCriticalRegion(); + ExAcquireFastMutexUnsafe(&Process->TebLock); if (NULL == Process->TebBlock || Process->TebBlock == Process->TebLastAllocated) { @@ -538,7 +539,8 @@ PAGE_READWRITE); if (! NT_SUCCESS(Status)) { - ExReleaseFastMutex(&Process->TebLock); + ExReleaseFastMutexUnsafe(&Process->TebLock); + KeLeaveCriticalRegion(); DPRINT1("Failed to reserve virtual memory for TEB\n"); return Status; } @@ -557,7 +559,8 @@ return Status; } Process->TebLastAllocated = TebBase; - ExReleaseFastMutex(&Process->TebLock); + ExReleaseFastMutexUnsafe(&Process->TebLock); + KeLeaveCriticalRegion(); } DPRINT ("TebBase %p TebSize %lu\n", TebBase, TebSize); Index: ntoskrnl/ps/kill.c =================================================================== --- ntoskrnl/ps/kill.c (revision 13570) +++ ntoskrnl/ps/kill.c (working copy) @@ -157,7 +157,8 @@ if(CurrentThread->Tcb.Teb) { DPRINT("Decommit teb at %p\n", CurrentThread->Tcb.Teb); - ExAcquireFastMutex(&CurrentProcess->TebLock); + KeEnterCriticalRegion(); + ExAcquireFastMutexUnsafe(&CurrentProcess->TebLock); TebBlock = MM_ROUND_DOWN(CurrentThread->Tcb.Teb, MM_VIRTMEM_GRANULARITY); ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *)&CurrentThread->Tcb.Teb, @@ -172,7 +173,8 @@ MmUnlockAddressSpace(&CurrentProcess->AddressSpace); } CurrentThread->Tcb.Teb = NULL; - ExReleaseFastMutex(&CurrentProcess->TebLock); + ExReleaseFastMutexUnsafe(&CurrentProcess->TebLock); + KeLeaveCriticalRegion(); } /* abandon all owned mutants */ Index: ntoskrnl/ex/fmutex.c =================================================================== --- ntoskrnl/ex/fmutex.c (revision 13570) +++ ntoskrnl/ex/fmutex.c (working copy) @@ -21,18 +21,14 @@ VOID FASTCALL ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex) { - ASSERT(FastMutex->Owner != KeGetCurrentThread()); - InterlockedIncrementUL(&FastMutex->Contention); - while (InterlockedExchange(&FastMutex->Count, 0) == 0) - { - KeWaitForSingleObject(&FastMutex->Event, - Executive, - KernelMode, - FALSE, - NULL); - } - InterlockedDecrementUL(&FastMutex->Contention); - FastMutex->Owner = KeGetCurrentThread(); + ASSERT(FastMutex->Owner != KeGetCurrentThread()); + if (InterlockedDecrement(&FastMutex->Count) != 0) + { + FastMutex->Contention++; + KeWaitForSingleObject(&FastMutex->Event, Executive, KernelMode, + FALSE, NULL); + } + FastMutex->Owner = KeGetCurrentThread(); } /* @@ -41,13 +37,10 @@ VOID FASTCALL ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex) { - ASSERT(FastMutex->Owner == KeGetCurrentThread()); - FastMutex->Owner = NULL; - InterlockedExchange(&FastMutex->Count, 1); - if (FastMutex->Contention > 0) - { + ASSERT(FastMutex->Owner == KeGetCurrentThread()); + FastMutex->Owner = NULL; + if (InterlockedIncrement(&FastMutex->Count) <= 0) KeSetEvent(&FastMutex->Event, 0, FALSE); - } } /* EOF */