ptos: thread: Add PsExitThread()
Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
@@ -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
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user