Skip to content

Commit 6e95a13

Browse files
authored
[WIN32SS:ENG/NTUSER] Use shared locks for display list lookups (reactos#9090)
- Use shared locks for the display device and PDEV lookup paths. These functions only walk existing lists and take references, while list updates and mode-switch paths still use exclusive locking. This avoids serializing read-only display queries unnecessarily. - Use shared locks for other read-only NtUser calls.
1 parent a45e91c commit 6e95a13

6 files changed

Lines changed: 34 additions & 8 deletions

File tree

win32ss/gdi/eng/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ EngpFindGraphicsDevice(
803803
pustrDevice, iDevNum);
804804

805805
/* Lock list */
806-
EngAcquireSemaphore(ghsemGraphicsDeviceList);
806+
EngAcquireSemaphoreShared(ghsemGraphicsDeviceList);
807807

808808
if (pustrDevice && pustrDevice->Buffer)
809809
{

win32ss/gdi/eng/pdevobj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ EngpGetPDEV(
805805
ULONG i;
806806

807807
/* Acquire PDEV lock */
808-
EngAcquireSemaphore(ghsemPDEV);
808+
EngAcquireSemaphoreShared(ghsemPDEV);
809809

810810
/* Did the caller pass a device name? */
811811
if (pustrDeviceName)

win32ss/user/ntuser/menu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6315,7 +6315,7 @@ NtUserMenuItemFromPoint(
63156315
int Ret = -1;
63166316

63176317
TRACE("Enter NtUserMenuItemFromPoint\n");
6318-
UserEnterExclusive();
6318+
UserEnterShared();
63196319

63206320
if (!(Menu = UserGetMenuObject(hMenu)))
63216321
{

win32ss/user/ntuser/simplecall.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,19 @@ NtUserCallNoParam(DWORD Routine)
6161
DWORD_PTR Result = 0;
6262

6363
TRACE("Enter NtUserCallNoParam\n");
64-
UserEnterExclusive();
64+
65+
/* Read-only routines only need a shared lock; the rest stay exclusive */
66+
switch (Routine)
67+
{
68+
case NOPARAM_ROUTINE_GETMSESSAGEPOS:
69+
case NOPARAM_ROUTINE_GETIMESHOWSTATUS:
70+
case NOPARAM_ROUTINE_ISCONSOLEMODE:
71+
UserEnterShared();
72+
break;
73+
default:
74+
UserEnterExclusive();
75+
break;
76+
}
6577

6678
switch (Routine)
6779
{
@@ -158,7 +170,22 @@ NtUserCallOneParam(
158170

159171
TRACE("Enter NtUserCallOneParam\n");
160172

161-
UserEnterExclusive();
173+
/* Read-only routines only need a shared lock; the rest stay exclusive */
174+
switch (Routine)
175+
{
176+
case ONEPARAM_ROUTINE_GETDESKTOPMAPPING:
177+
case ONEPARAM_ROUTINE_WINDOWFROMDC:
178+
case ONEPARAM_ROUTINE_GETKEYBOARDTYPE:
179+
case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT:
180+
case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
181+
case ONEPARAM_ROUTINE_GETCURSORPOS:
182+
case ONEPARAM_ROUTINE_GETPROCDEFLAYOUT:
183+
UserEnterShared();
184+
break;
185+
default:
186+
UserEnterExclusive();
187+
break;
188+
}
162189

163190
switch (Routine)
164191
{
@@ -319,7 +346,6 @@ NtUserCallOneParam(
319346
}
320347

321348
case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
322-
/* FIXME: Should use UserEnterShared */
323349
Result = UserEnumClipboardFormats(Param);
324350
break;
325351

win32ss/user/ntuser/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ NtUserBuildHwndList(
15271527
if (pcHwndNeeded == NULL)
15281528
return STATUS_INVALID_PARAMETER;
15291529

1530-
UserEnterExclusive();
1530+
UserEnterShared();
15311531

15321532
if (hwndParent || !dwThreadId)
15331533
{

win32ss/user/ntuser/winpos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3283,7 +3283,7 @@ NtUserChildWindowFromPointEx(HWND hwndParent,
32833283
{
32843284
PWND pwndParent;
32853285
TRACE("Enter NtUserChildWindowFromPointEx\n");
3286-
UserEnterExclusive();
3286+
UserEnterShared();
32873287
if ((pwndParent = UserGetWindowObject(hwndParent)))
32883288
{
32893289
pwndParent = IntChildWindowFromPointEx(pwndParent, x, y, uiFlags);

0 commit comments

Comments
 (0)