Add functions to transition threads to deferred ready or transition states
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 32s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 39s
Builds / ExectOS (i686, release) (push) Successful in 38s

This commit is contained in:
2026-06-17 16:30:28 +02:00
parent ea1ad3c6b1
commit 1fca2400a4
2 changed files with 62 additions and 0 deletions

View File

@@ -75,6 +75,44 @@ KE::KThread::AttachThread(IN OUT PKTHREAD Thread)
}
}
/**
* Transitions a thread to the ready state and queues it for execution within the dispatcher database.
*
* @param Thread
* Supplies a pointer to the thread to be dispatched.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::KThread::DispatchReadyThread(IN PKTHREAD Thread)
{
PKPROCESS Process;
/* Extract the process from the thread's APC state */
Process = Thread->ApcState.Process;
/* Verify if the process and thread are resident in physical memory */
if(Process->State != ProcessInMemory)
{
/* Process is swapped out, place the thread in a transition state */
Thread->State = Transition;
}
else if(!Thread->KernelStackResident)
{
/* Increment the active stack count and transition the thread */
Process->StackCount++;
Thread->State = Transition;
}
else
{
/* Both process and thread's stack are fully resident, queue the thread for execution */
KE::Scheduler::InsertDeferredReadyList(Thread);
}
}
/**
* Retrieves a pointer to the system's initial executive thread object.
*
@@ -346,6 +384,28 @@ KE::KThread::InitializeThread(IN PKPROCESS Process,
return STATUS_SUCCESS;
}
/**
* Prepares a thread for execution by safely acquiring the dispatcher database lock.
*
* @param Thread
* Supplies a pointer to the thread to be readied.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::KThread::ReadyThread(IN PKTHREAD Thread)
{
/* Raise runlevel to SYNC level and acquire the dispatcher database lock */
KE::RaiseRunLevel RunLevel(SYNC_LEVEL);
KE::QueuedSpinLockGuard DispatcherGuard(DispatcherLock);
/* Evaluate residency and queue the thread */
DispatchReadyThread(Thread);
}
/**
* Suspend APC-built thread NOP routine. It takes no actions.
*