A process owns an address space, descriptors, working directory and executable metadata. Its process ID equals its main task’s ID. Each task is one schedulable thread with its own stack, TLS and saved CPU/FPU state.
Task API
g_create_task starts a thread in the current process; _d variants pass user
data and _a variants select CPU affinity. g_get_tid returns the thread ID,
g_get_pid the process ID, and g_join waits for a task to finish.
#include <ghost.h>
void worker();
auto id = g_create_task(reinterpret_cast<void*>(worker));
if(id != G_TID_NONE)
g_join(id);
Returning from a thread entry or calling g_exit_task ends that thread.
g_exit ends the process; ending the main task also terminates its siblings.
g_kill requests process termination, subject to privilege checks.
G_KERNQUERY_TASK_GET_BY_ID reports scheduled CPU nanoseconds for a thread and
resident user memory for its process. G_KERNQUERY_PROCESS_GET_BY_ID accepts a
process ID and uses the same response layout, aggregating CPU time across all
threads, including exited threads. CPU time includes kernel work while scheduled;
without HPET its resolution is one timer tick. Resident memory includes shared
RAM mappings and excludes MMIO, uncommitted pages and shared kernel mappings.
Security levels
| Level | Execution and permissions |
|---|---|
|
Ring 3; ordinary application APIs. |
|
Ring 3 with port-I/O access and driver-only system operations. |
|
Ring 0; internal kernel tasks. |
A spawn cannot request greater privilege than its caller. Driver and kernel processes cannot be killed by application tasks. See Resource ownership for kernel lifetime rules and Process spawning for launch context.