From 161693e4f9e3deb7a6a0dedd63ecc2afff526dff Mon Sep 17 00:00:00 2001 From: James Abbatiello Date: Sun, 7 Nov 1999 19:22:46 +0000 Subject: [PATCH] Addresses issues with multiple processes accessing non-global critical sections. --- memory/heap.c | 6 ++++-- scheduler/critsection.c | 15 +++++++-------- windows/queue.c | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/memory/heap.c b/memory/heap.c index dd74be1c810..4ce0ded99e2 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -519,8 +519,10 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags, /* Initialize critical section */ InitializeCriticalSection( &heap->critSection ); - if (!SystemHeap) /* System heap critical section has to be global */ - MakeCriticalSectionGlobal( &heap->critSection ); + /* FIXME: once separate address spaces are implemented, only */ + /* the SystemHeap critical section should be global */ + /* if (!SystemHeap) */ + MakeCriticalSectionGlobal( &heap->critSection ); } /* Create the first free block */ diff --git a/scheduler/critsection.c b/scheduler/critsection.c index 0349aeafb30..71af68ab99b 100644 --- a/scheduler/critsection.c +++ b/scheduler/critsection.c @@ -64,6 +64,12 @@ void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit ) FIXME_(win32)("entering uninitialized section(%p)?\n",crit); InitializeCriticalSection(crit); } + if ( crit->Reserved && crit->Reserved != GetCurrentProcessId() ) + { + FIXME_(win32)("Crst %p belongs to process %ld, current is %ld!\n", + crit, crit->Reserved, GetCurrentProcessId() ); + return; + } if (InterlockedIncrement( &crit->LockCount )) { if (crit->OwningThread == GetCurrentThreadId()) @@ -71,15 +77,8 @@ void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit ) crit->RecursionCount++; return; } + /* Now wait for it */ - - if ( crit->Reserved && crit->Reserved != GetCurrentProcessId() ) - { - FIXME_(win32)("Crst %p belongs to process %ld, current is %ld!\n", - crit, crit->Reserved, GetCurrentProcessId() ); - return; - } - res = WaitForSingleObject( crit->LockSemaphore, 5000L ); if ( res == WAIT_TIMEOUT ) { diff --git a/windows/queue.c b/windows/queue.c index 57dc8bd90bd..291b20c93e1 100644 --- a/windows/queue.c +++ b/windows/queue.c @@ -85,6 +85,8 @@ PERQUEUEDATA * PERQDATA_CreateInstance( ) * since this may be shared by different threads. see AttachThreadInput() */ InitializeCriticalSection( &pQData->cSection ); + /* FIXME: not all per queue data critical sections should be global */ + MakeCriticalSectionGlobal( &pQData->cSection ); /* Save perQData globally for 16 bit tasks */ if ( bIsWin16 )