2002-08-16 David Welch <welch@computer2.darkstar.org>

* ntoskrnl/mm/npool.c (ExAllocateWholePageBlock): Converted
	to use PHYSICAL_ADDRESS type for page address.

2002-08-16  David Welch  <welch@computer2.darkstar.org>

	* subsys/win32k/ntuser/class.c (W32kCreateClass): Corrected
	typo when calculating the offset into the class object to
	put the class name string.

2002-08-16  David Welch  <welch@computer2.darkstar.org>

	* ntoskrnl/ps/thread.c (PsDispatchThreadNoLock): Don't call
	the reaper function directly; set an event to wake up a seperate
	reaper thread.
	* ntoskrnl/ps/thread.c (PsReaperThreadMain): New function that
	waits for a notification and then calls PsReapThreads.
	* ntoskrnl/ps/thread.c (PsInitThreadManagement): Create the
	reaper thread.

svn path=/trunk/; revision=3333
This commit is contained in:
David Welch 2002-08-16 01:39:17 +00:00
parent a4e3a21cfa
commit 99c4e70f22
7 changed files with 91 additions and 21 deletions

View file

@ -1,3 +1,24 @@
2002-08-16 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/npool.c (ExAllocateWholePageBlock): Converted
to use PHYSICAL_ADDRESS type for page address.
2002-08-16 David Welch <welch@computer2.darkstar.org>
* subsys/win32k/ntuser/class.c (W32kCreateClass): Corrected
typo when calculating the offset into the class object to
put the class name string.
2002-08-16 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/ps/thread.c (PsDispatchThreadNoLock): Don't call
the reaper function directly; set an event to wake up a seperate
reaper thread.
* ntoskrnl/ps/thread.c (PsReaperThreadMain): New function that
waits for a notification and then calls PsReapThreads.
* ntoskrnl/ps/thread.c (PsInitThreadManagement): Create the
reaper thread.
2002-08-15 David Welch <welch@computer2.darkstar.org>
* lib/advapi32/misc/dllmain.c (DllMain): Removed debug message.

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: ps.h,v 1.39 2002/08/14 20:58:34 dwelch Exp $
/* $Id: ps.h,v 1.40 2002/08/16 01:39:16 dwelch Exp $
*
* FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions
@ -502,6 +502,8 @@ PsDispatchThread(ULONG NewThreadStatus);
VOID
PsInitialiseSuspendImplementation(VOID);
extern ULONG PiNrThreadsAwaitingReaping;
#endif /* ASSEMBLER */
#endif /* __INCLUDE_INTERNAL_PS_H */

View file

@ -1,4 +1,4 @@
/* $Id: npool.c,v 1.58 2002/06/04 15:26:57 dwelch Exp $
/* $Id: npool.c,v 1.59 2002/08/16 01:39:16 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -1007,7 +1007,7 @@ PVOID STDCALL
ExAllocateWholePageBlock(ULONG UserSize)
{
PVOID Address;
PVOID Page;
PHYSICAL_ADDRESS Page;
ULONG i;
ULONG Size;
ULONG NrPages;
@ -1020,14 +1020,14 @@ ExAllocateWholePageBlock(ULONG UserSize)
for (i = 0; i < NrPages; i++)
{
Page = MmAllocPage(MC_NPPOOL, 0);
if (Page == NULL)
if (Page.QuadPart == 0LL)
{
KeBugCheck(0);
}
MmCreateVirtualMapping(NULL,
Address + (i * PAGESIZE),
PAGE_READWRITE | PAGE_SYSTEM,
(ULONG)Page,
Page,
TRUE);
}

View file

@ -1,4 +1,4 @@
/* $Id: kill.c,v 1.54 2002/06/10 21:37:45 hbirr Exp $
/* $Id: kill.c,v 1.55 2002/08/16 01:39:16 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -81,8 +81,6 @@ PsReapThreads(VOID)
PETHREAD current;
KIRQL oldIrql;
// DPRINT1("PsReapThreads()\n");
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
current_entry = PiThreadListHead.Flink;
@ -99,19 +97,15 @@ PsReapThreads(VOID)
PEPROCESS Process = current->ThreadsProcess;
NTSTATUS Status = current->ExitStatus;
DPRINT("PsProcessType %x\n", PsProcessType);
DPRINT("Reaping thread %x\n", current);
DPRINT("Pointer count %d\n", ObGetObjectPointerCount(Process));
PiNrThreadsAwaitingReaping--;
current->Tcb.State = THREAD_STATE_TERMINATED_2;
RemoveEntryList(&current->Tcb.ProcessThreadListEntry);
if (IsListEmpty(&Process->ThreadListHead))
{
DPRINT("Last thread terminated, terminating process\n");
KeReleaseSpinLock( &PiThreadListLock, oldIrql );
PiTerminateProcess(Process, Status);
KeAcquireSpinLock( &PiThreadListLock, &oldIrql );
}
DPRINT("Pointer count %d\n", ObGetObjectPointerCount(Process));
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
ObDereferenceObject(current);
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
@ -161,7 +155,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
KeReleaseDispatcherDatabaseLock(FALSE);
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
KeBugCheck(0);
}

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.101 2002/08/14 20:58:38 dwelch Exp $
/* $Id: thread.c,v 1.102 2002/08/16 01:39:16 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -49,6 +49,10 @@ static BOOLEAN DoneInitYet = FALSE;
static PETHREAD IdleThreads[MAXIMUM_PROCESSORS];
ULONG PiNrThreads = 0;
ULONG PiNrReadyThreads = 0;
static HANDLE PiReaperThreadHandle;
static KEVENT PiReaperThreadEvent;
static BOOL PiReaperThreadShouldTerminate = FALSE;
ULONG PiNrThreadsAwaitingReaping = 0;
static GENERIC_MAPPING PiThreadMapping = {THREAD_READ,
THREAD_WRITE,
@ -164,6 +168,30 @@ static PETHREAD PsScanThreadList (KPRIORITY Priority, ULONG Affinity)
return(NULL);
}
VOID STDCALL
PiWakeupReaperThread(VOID)
{
KeSetEvent(&PiReaperThreadEvent, 0, FALSE);
}
NTSTATUS STDCALL
PiReaperThreadMain(PVOID Ignored)
{
while (1)
{
KeWaitForSingleObject(&PiReaperThreadEvent,
Executive,
KernelMode,
FALSE,
NULL);
if (PiReaperThreadShouldTerminate)
{
PsTerminateSystemThread(0);
}
PsReapThreads();
}
}
VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
{
KPRIORITY CurrentPriority;
@ -182,6 +210,10 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
PsInsertIntoThreadList(CurrentThread->Tcb.Priority,
CurrentThread);
}
if (CurrentThread->Tcb.State == THREAD_STATE_TERMINATED_1)
{
PiNrThreadsAwaitingReaping++;
}
Affinity = 1 << KeGetCurrentProcessorNumber();
for (CurrentPriority = HIGH_PRIORITY;
@ -206,8 +238,11 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
CurrentThread = Candidate;
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
if (PiNrThreadsAwaitingReaping > 0)
{
PiWakeupReaperThread();
}
KiArchContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
PsReapThreads();
return;
}
}
@ -229,7 +264,7 @@ PsDispatchThread(ULONG NewThreadStatus)
/*
* Save wait IRQL
*/
KeGetCurrentKPCR()->CurrentThread->WaitIrql = oldIrql;
KeGetCurrentKPCR()->CurrentThread->WaitIrql = oldIrql;
PsDispatchThreadNoLock(NewThreadStatus);
KeLowerIrql(oldIrql);
}
@ -367,6 +402,7 @@ PsInitThreadManagment(VOID)
PETHREAD FirstThread;
ULONG i;
HANDLE FirstThreadHandle;
NTSTATUS Status;
KeInitializeSpinLock(&PiThreadListLock);
for (i=0; i < MAXIMUM_PRIORITY; i++)
@ -409,6 +445,23 @@ PsInitThreadManagment(VOID)
DPRINT("FirstThread %x\n",FirstThread);
DoneInitYet = TRUE;
/*
* Create the reaper thread
*/
KeInitializeEvent(&PiReaperThreadEvent, SynchronizationEvent, FALSE);
Status = PsCreateSystemThread(&PiReaperThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
PiReaperThreadMain,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("PS: Failed to create reaper thread.\n");
KeBugCheck(0);
}
}
LONG STDCALL

View file

@ -1,4 +1,4 @@
/* $Id: class.c,v 1.9 2002/07/17 21:04:57 dwelch Exp $
/* $Id: class.c,v 1.10 2002/08/16 01:39:17 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -188,7 +188,7 @@ W32kCreateClass(LPWNDCLASSEX lpwcx,
{
ClassObject->Class.lpszMenuName = namePtr;
wcscpy (namePtr, lpwcx->lpszMenuName);
namePtr += wcslen (lpwcx->lpszMenuName + 1);
namePtr += wcslen (lpwcx->lpszMenuName) + 1;
}
ClassObject->Class.lpszClassName = namePtr;
wcscpy (namePtr, lpwcx->lpszClassName);

View file

@ -1,4 +1,4 @@
/* $Id: winsta.c,v 1.5 2002/07/17 21:04:57 dwelch Exp $
/* $Id: winsta.c,v 1.6 2002/08/16 01:39:17 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -26,7 +26,7 @@
#include <include/class.h>
#include <include/window.h>
//#define NDEBUG
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/