-call thread notify routines below DISPATCH_LVL

svn path=/trunk/; revision=4846
This commit is contained in:
Gunnar Dalsnes 2003-06-05 22:45:38 +00:00
parent 1f8cbb88a0
commit 9b53ffc03a

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.58 2003/04/30 15:11:31 gvg Exp $ /* $Id: create.c,v 1.59 2003/06/05 22:45:38 gdalsnes Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -278,6 +278,9 @@ PiDeleteThread(PVOID ObjectBody)
KIRQL oldIrql; KIRQL oldIrql;
PETHREAD Thread; PETHREAD Thread;
ULONG i; ULONG i;
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
ULONG NotifyRoutineCount;
Thread = (PETHREAD)ObjectBody; Thread = (PETHREAD)ObjectBody;
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody); DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
@ -286,16 +289,23 @@ PiDeleteThread(PVOID ObjectBody)
Thread->ThreadsProcess = NULL; Thread->ThreadsProcess = NULL;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql); KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
for (i = 0; i < PiThreadNotifyRoutineCount; i++) for (i = 0; i < PiThreadNotifyRoutineCount; i++)
{ {
PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess, NotifyRoutine[i] = PiThreadNotifyRoutine[i];
Thread->Cid.UniqueThread, }
FALSE); NotifyRoutineCount = PiThreadNotifyRoutineCount;
}
PiNrThreads--; PiNrThreads--;
RemoveEntryList(&Thread->Tcb.ThreadListEntry); RemoveEntryList(&Thread->Tcb.ThreadListEntry);
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
for (i = 0; i < NotifyRoutineCount; i++)
{
//must be called below DISPATCH_LVL
NotifyRoutine[i](Thread->Cid.UniqueProcess,
Thread->Cid.UniqueThread,
FALSE);
}
KeReleaseThread(Thread); KeReleaseThread(Thread);
DPRINT("PiDeleteThread() finished\n"); DPRINT("PiDeleteThread() finished\n");
} }
@ -313,7 +323,9 @@ PsInitializeThread(HANDLE ProcessHandle,
KIRQL oldIrql; KIRQL oldIrql;
PEPROCESS Process; PEPROCESS Process;
ULONG i; ULONG i;
ULONG NotifyRoutineCount;
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
/* /*
* Reference process * Reference process
*/ */
@ -379,17 +391,23 @@ PsInitializeThread(HANDLE ProcessHandle,
KeAcquireSpinLock(&PiThreadListLock, &oldIrql); KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry); InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry);
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
{
NotifyRoutine[i] = PiThreadNotifyRoutine[i];
}
NotifyRoutineCount = PiThreadNotifyRoutineCount;
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority; Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority;
Thread->Tcb.Priority = Thread->Tcb.BasePriority; Thread->Tcb.Priority = Thread->Tcb.BasePriority;
for (i = 0; i < PiThreadNotifyRoutineCount; i++) for (i = 0; i < NotifyRoutineCount; i++)
{ {
PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess, //must be called below DISPATCH_LVL
NotifyRoutine[i](Thread->Cid.UniqueProcess,
Thread->Cid.UniqueThread, Thread->Cid.UniqueThread,
TRUE); TRUE);
} }
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -688,11 +706,18 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
NTSTATUS STDCALL NTSTATUS STDCALL
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine) PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
{ {
KIRQL oldIrql;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT) if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
{
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_INSUFFICIENT_RESOURCES); return(STATUS_INSUFFICIENT_RESOURCES);
}
PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine; PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine;
PiThreadNotifyRoutineCount++; PiThreadNotifyRoutineCount++;
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }