Author: tretiakov
Date: Wed Feb 28 16:21:48 2007
New Revision: 25922
URL:
http://svn.reactos.org/svn/reactos?rev=25922&view=rev
Log:
Make ntuser locks use eresource instead of mutex.
Fix corresponding FIXME in class.c
Modified:
trunk/reactos/subsystems/win32/win32k/include/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/class.c
trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
Modified: trunk/reactos/subsystems/win32/win32k/include/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/ntuser.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/ntuser.h Wed Feb 28 16:21:48 2007
@@ -1,12 +1,5 @@
#ifndef _WIN32K_NTUSER_H
#define _WIN32K_NTUSER_H
-
-
-extern char* _file;
-extern DWORD _line;
-extern DWORD _locked;
-
-extern FAST_MUTEX UserLock;
#define DECLARE_RETURN(type) type _ret_
#define RETURN(value) { _ret_ = value; goto _cleanup_; }
@@ -14,45 +7,17 @@
#define END_CLEANUP return _ret_;
-#define UserEnterCo() UserEnterExclusive()
-#define UserLeaveCo() UserLeave()
-
-#define UserEnterShared() UserEnterExclusive()
-
-#define UserEnterExclusive() \
-{ \
- /* DPRINT1("try xlock, %s, %i (%i)\n",__FILE__,__LINE__, _locked);*/ \
- if (UserLock.Owner == KeGetCurrentThread()){ \
- DPRINT1("file %s, line %i\n",_file, _line); \
- ASSERT(FALSE); \
- } \
- UUserEnterExclusive(); \
- ASSERT(InterlockedIncrement((PLONG)(&_locked)) == 1 /*> 0*/); \
- _file = __FILE__; _line = __LINE__; \
- /* DPRINT("got lock, %s, %i (%i)\n",__FILE__,__LINE__, _locked);*/ \
-}
-
-#define UserLeave() \
-{ \
- ASSERT(InterlockedDecrement((PLONG)(&_locked)) == 0/*>= 0*/); \
- /*DPRINT("unlock, %s, %i (%i)\n",__FILE__,__LINE__, _locked);*/ \
- if (UserLock.Owner != KeGetCurrentThread()) { \
- DPRINT1("file %s, line %i\n",_file, _line); \
- ASSERT(FALSE); \
- } \
- _file = __FILE__; _line = __LINE__; \
- UUserLeave(); \
-}
-
+#define UserEnterCo UserEnterExclusive
+#define UserLeaveCo UserLeave
NTSTATUS FASTCALL InitUserImpl(VOID);
-VOID FASTCALL UninitUser(VOID);
-VOID FASTCALL UUserEnterShared(VOID);
-VOID FASTCALL UUserEnterExclusive(VOID);
-VOID FASTCALL UUserLeave(VOID);
+VOID FASTCALL CleanupUserImpl(VOID);
+VOID FASTCALL UserEnterShared(VOID);
+VOID FASTCALL UserEnterExclusive(VOID);
+VOID FASTCALL UserLeave(VOID);
BOOL FASTCALL UserIsEntered();
-
+BOOL FASTCALL UserIsEnteredExclusive();
#endif /* _WIN32K_NTUSER_H */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c Wed Feb 28 16:21:48 2007
@@ -220,8 +220,8 @@
IN BOOL Ansi,
IN BOOL UseCallProc2)
{
- /* FIXME - assert for exclusive lock! */
-
+ ASSERT(UserIsEnteredExclusive() == TRUE);
+
if (Class->System)
{
return (Ansi ? Class->WndProcExtra : Class->WndProc);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c Wed Feb 28 16:21:48 2007
@@ -33,25 +33,16 @@
#define NDEBUG
#include <debug.h>
-
-FAST_MUTEX UserLock;
-
-char* _file;
-DWORD _line;
-DWORD _locked=0;
+ERESOURCE UserLock;
/* FUNCTIONS **********************************************************/
NTSTATUS FASTCALL InitUserImpl(VOID)
{
- //PVOID mem;
NTSTATUS Status;
- // DPRINT("Enter InitUserImpl\n");
- // ExInitializeResourceLite(&UserLock);
-
- ExInitializeFastMutex(&UserLock);
+ ExInitializeResourceLite(&UserLock);
if (!ObmCreateHandleTable())
{
@@ -75,41 +66,31 @@
*/
BOOL FASTCALL UserIsEntered()
{
- return (UserLock.Owner == KeGetCurrentThread());
+ return ExIsResourceAcquiredExclusiveLite(&UserLock)
+ || ExIsResourceAcquiredSharedLite(&UserLock);
}
-
-VOID FASTCALL CleanupUser(VOID)
+BOOL FASTCALL UserIsEnteredExclusive()
{
- // ExDeleteResourceLite(&UserLock);
+ return ExIsResourceAcquiredExclusiveLite(&UserLock);
}
-VOID FASTCALL UUserEnterShared(VOID)
+VOID FASTCALL CleanupUserImpl(VOID)
{
- // DPRINT("Enter IntLockUserShared\n");
- // KeDumpStackFrames((PULONG)__builtin_frame_address(0));
- //DPRINT("%x\n",__builtin_return_address(0));
- // KeEnterCriticalRegion();
- // ExAcquireResourceSharedLite(&UserLock, TRUE);
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&UserLock);
+ ExDeleteResourceLite(&UserLock);
}
-VOID FASTCALL UUserEnterExclusive(VOID)
+VOID FASTCALL UserEnterShared(VOID)
{
- // DPRINT("Enter UserEnterExclusive\n");
- // KeDumpStackFrames((PULONG)__builtin_frame_address(0));
- //DPRINT("%x\n",__builtin_return_address(0));
- // KeEnterCriticalRegion();
- // ExAcquireResourceExclusiveLite(&UserLock, TRUE);
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&UserLock);
+ ExAcquireResourceSharedLite(&UserLock, TRUE);
}
-VOID FASTCALL UUserLeave(VOID)
+VOID FASTCALL UserEnterExclusive(VOID)
{
- // DPRINT("Enter UserLeave\n");
- // KeDumpStackFrames((PULONG)__builtin_frame_address(0));
- //DPRINT("%x\n",__builtin_return_address(0));
- // ExReleaseResourceLite(&UserLock);
- // KeLeaveCriticalRegion();
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&UserLock);
+ ExAcquireResourceExclusiveLite(&UserLock, TRUE);
}
+
+VOID FASTCALL UserLeave(VOID)
+{
+ ExReleaseResourceLite(&UserLock);
+}