ptos: thread: Add PsExitThread()

Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
2026-07-15 05:26:15 -04:00
parent edde0119fb
commit e65a6dc799
2 changed files with 25 additions and 0 deletions
+7
View File
@@ -36,6 +36,13 @@ typedef struct _THREAD {
TAILQ_ENTRY(_THREAD) ThreadLink; TAILQ_ENTRY(_THREAD) ThreadLink;
} THREAD; } THREAD;
/*
* Exit the current thread
*
* @ExitCode: Exit code to terminate with
*/
NO_RETURN VOID PsExitThread(ULONG ExitCode);
/* /*
* Create a new thread * Create a new thread
* *
+18
View File
@@ -9,11 +9,14 @@
#include <ps/thread.h> #include <ps/thread.h>
#include <ps/process.h> #include <ps/process.h>
#include <hal/thread.h> #include <hal/thread.h>
#include <hal/prim.h>
#include <hal/kpcr.h>
#include <ex/pool.h> #include <ex/pool.h>
#include <atomic.h> #include <atomic.h>
/* Globals */ /* Globals */
static UQUAD NextThreadTid = 0; static UQUAD NextThreadTid = 0;
static SCHED_QUEUE ReaperQueue;
PT_STATUS PT_STATUS
PsCreateThread(struct _PROCESS *Parent, ULONG Flags, UPTR Ip, THREAD **Result) PsCreateThread(struct _PROCESS *Parent, ULONG Flags, UPTR Ip, THREAD **Result)
@@ -46,3 +49,18 @@ PsCreateThread(struct _PROCESS *Parent, ULONG Flags, UPTR Ip, THREAD **Result)
*Result = Thread; *Result = Thread;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NO_RETURN VOID
PsExitThread(ULONG ExitCode)
{
KPCR *Kpcr;
Kpcr = HalKpcrCurrent();
KeSchedEnqueue(&ReaperQueue, Kpcr->CurrentThread);
Kpcr->CurrentThread = NULL;
HalThreadYield();
for (;;) {
HalCpuSuspend();
}
}