Author: mjmartin
Date: Mon May 31 14:36:40 2010
New Revision: 47486
URL:
http://svn.reactos.org/svn/reactos?rev=47486&view=rev
Log:
[win32k]
- When processing and deleting timers use a seperate timer lock instead of using the
global user lock.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Mon May 31 14:36:40
2010
@@ -31,12 +31,26 @@
static PVOID WindowLessTimersBitMapBuffer;
static ULONG HintIndex = 0;
+ERESOURCE TimerLock;
#define IntLockWindowlessTimerBitmap() \
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&Mutex)
#define IntUnlockWindowlessTimerBitmap() \
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&Mutex)
+
+#define TimerEnterExclusive() \
+{ \
+ KeEnterCriticalRegion(); \
+ ExAcquireResourceExclusiveLite(&TimerLock, TRUE); \
+}
+
+#define TimerLeave() \
+{ \
+ ExReleaseResourceLite(&TimerLock); \
+ KeLeaveCriticalRegion(); \
+}
+
/* FUNCTIONS *****************************************************************/
static
@@ -49,6 +63,7 @@
if (!FirstpTmr)
{
+ ExInitializeResourceLite(&TimerLock);
FirstpTmr = UserCreateObject(gHandleTable, NULL, &Handle, otTimer,
sizeof(TIMER));
if (FirstpTmr)
{
@@ -96,7 +111,7 @@
{
PLIST_ENTRY pLE;
PTIMER pTmr = FirstpTmr, RetTmr = NULL;
- KeEnterCriticalRegion();
+ TimerEnterExclusive();
do
{
if (!pTmr) break;
@@ -116,7 +131,7 @@
pLE = pTmr->ptmrList.Flink;
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- KeLeaveCriticalRegion();
+ TimerLeave();
return RetTmr;
}
@@ -127,7 +142,7 @@
{
PLIST_ENTRY pLE;
PTIMER pTmr = FirstpTmr;
- KeEnterCriticalRegion();
+ TimerEnterExclusive();
do
{
if (!pTmr) break;
@@ -139,7 +154,7 @@
pLE = pTmr->ptmrList.Flink;
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- KeLeaveCriticalRegion();
+ TimerLeave();
return pTmr;
}
@@ -156,7 +171,7 @@
if (!pTmr) return FALSE;
- KeEnterCriticalRegion();
+ TimerEnterExclusive();
do
{
if ( (lParam == (LPARAM)pTmr->pfn) &&
@@ -167,7 +182,7 @@
pLE = pTmr->ptmrList.Flink;
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- KeLeaveCriticalRegion();
+ TimerLeave();
if (!pTmr) return FALSE;
@@ -320,7 +335,7 @@
pti = PsGetCurrentThreadWin32Thread();
ThreadQueue = pti->MessageQueue;
- UserEnterExclusive();
+ TimerEnterExclusive();
do
{
@@ -343,7 +358,7 @@
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- UserLeave();
+ TimerLeave();
return Hit;
}
@@ -360,7 +375,7 @@
if (!pTmr) return;
- UserEnterExclusive();
+ TimerEnterExclusive();
KeQueryTickCount(&TickCount);
Time = MsqCalculateMessageTime(&TickCount);
@@ -423,7 +438,7 @@
TimeLast = Time;
- UserLeave();
+ TimerLeave();
DPRINT("TimerCount = %d\n", TimerCount);
}
@@ -533,7 +548,7 @@
if ((FirstpTmr == NULL) || (Window == NULL))
return FALSE;
- UserEnterExclusive();
+ TimerEnterExclusive();
do
{
@@ -545,7 +560,7 @@
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- UserLeave();
+ TimerLeave();
return TimersRemoved;
}
@@ -560,7 +575,7 @@
if (FirstpTmr == NULL)
return FALSE;
- UserEnterExclusive();
+ TimerEnterExclusive();
do
{
@@ -572,7 +587,7 @@
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr);
- UserLeave();
+ TimerLeave();
return TimersRemoved;
}
@@ -683,16 +698,19 @@
TIMERPROC lpTimerFunc
)
{
+ PWINDOW_OBJECT Window;
DECLARE_RETURN(UINT_PTR);
DPRINT("Enter NtUserSetTimer\n");
UserEnterExclusive();
-
- RETURN(IntSetTimer(UserGetWindowObject(hWnd), nIDEvent, uElapse, lpTimerFunc,
TMRF_TIFROMWND));
+ Window = UserGetWindowObject(hWnd);
+ UserLeave();
+
+ RETURN(IntSetTimer(Window, nIDEvent, uElapse, lpTimerFunc, TMRF_TIFROMWND));
CLEANUP:
DPRINT("Leave NtUserSetTimer, ret=%i\n", _ret_);
- UserLeave();
+
END_CLEANUP;
}
@@ -710,14 +728,13 @@
DPRINT("Enter NtUserKillTimer\n");
UserEnterExclusive();
-
Window = UserGetWindowObject(hWnd);
+ UserLeave();
RETURN(IntKillTimer(Window, uIDEvent, FALSE));
CLEANUP:
DPRINT("Leave NtUserKillTimer, ret=%i\n", _ret_);
- UserLeave();
END_CLEANUP;
}
@@ -734,14 +751,12 @@
DECLARE_RETURN(UINT_PTR);
DPRINT("Enter NtUserSetSystemTimer\n");
- UserEnterExclusive();
// This is wrong, lpTimerFunc is NULL!
RETURN(IntSetTimer(UserGetWindowObject(hWnd), nIDEvent, uElapse, lpTimerFunc,
TMRF_SYSTEM));
CLEANUP:
DPRINT("Leave NtUserSetSystemTimer, ret=%i\n", _ret_);
- UserLeave();
END_CLEANUP;
}