proc.types¶
Type definitions for the Asuro preemptive process management system.
Overview¶
proc.types is a pure type-definition unit that declares all records, enumerations, and constants shared between proc.mgr and arch.x86.proc.sched. It has no implementation code.
The central type is TProcessContext, which holds everything the scheduler and process manager need to track a single process: identity, state, I/O buffers, saved register state for context switching, scheduling parameters, pending system messages, resource bindings, file descriptor table pointer, working directory, and an arbitrary user data pointer.
Dependencies¶
io.stdio
Constants¶
PROCESS_STACK_SIZE¶
8192 — Per-process kernel stack size in bytes (8 KiB).
BASE_QUANTUM¶
5 — Base quantum multiplier. A process's time slice in timer ticks is Priority * BASE_QUANTUM.
Types¶
TProcessState¶
TProcessState = (
psCreated, { Allocated, stack prepared, not yet scheduled }
psRunning, { Currently executing on the main thread }
psReady, { Runnable but not the current process }
psSuspended, { Paused - will not be scheduled }
psAwaiting, { Blocked on I/O or event - will not be scheduled }
psFinished, { Terminal state - safe to reap }
psError { Unrecoverable error - safe to reap }
);
Lifecycle state of a process. psFinished and psError are terminal states; the scheduler's reaper will free the process context on the next scheduling cycle.
TProcessSysMsg¶
TProcessSysMsg = (
smNone, { No message }
smTerminate, { Graceful shutdown requested }
smKill, { Immediate forced shutdown }
smSuspend, { Pause execution }
smResume, { Resume from suspended }
smInput, { New data available on stdin }
smChildExited, { A child process has exited }
smCustom { User-defined message (payload in MsgData) }
);
System message delivered to a process via proc.mgr.sendMessage. The process reads PendingMsg in its own execution context; no asynchronous delivery mechanism is used.
TProcessEntryPoint¶
Entry point signature. When the procedure returns, process_trampoline in proc.mgr transitions the process to psFinished.
TResourceKind¶
TResourceKind = (
rkSocket, { TCP/UDP socket }
rkTimer, { A timer hook }
rkFileHandle, { VFS file descriptor }
rkCustom { Arbitrary pointer }
);
Classification tag for resources bound to a process via proc.mgr.bindResource.
TResourceCleanup¶
Callback invoked by proc.mgr.unbindAllResources (called during process reaping) to free a bound resource. The handle is the same void pointer passed to bindResource.
TResourceBinding / PResourceBinding¶
Entry in a process's resource list. Stored in the Resources DList inside TProcessContext.
TProcessContext / PProcessContext¶
TProcessContext = record
ProcessID : uint32;
Name : array[0..31] of char;
ParentID : uint32;
State : TProcessState;
ExitCode : uint32;
StdIn : POutBuf;
StdOut : POutBuf;
StdErr : POutBuf;
EntryPoint : TProcessEntryPoint;
SavedESP : uint32;
StackBase : void;
StackTop : uint32;
Priority : uint8;
Quantum : uint16;
TicksUsed : uint16;
PendingMsg : TProcessSysMsg;
MsgData : void;
Resources : void;
FDTable : void;
Cwd : pchar;
Local : void;
end;
| Field | Description |
|---|---|
ProcessID |
Unique 32-bit process ID (randomly generated by rand32) |
Name |
Null-terminated process name, maximum 31 characters |
ParentID |
PID of the creating process; 0 if created from the kernel |
State |
Current lifecycle state |
ExitCode |
Set by proc_exit or the WASI proc_exit hook; $FFFFFFFF for killed processes |
StdIn/StdOut/StdErr |
Per-process I/O buffers; may be shared with a terminal instance |
EntryPoint |
Procedure called when the process is first scheduled |
SavedESP |
Stack pointer saved by the context switch ISR |
StackBase |
Base of the heap-allocated kernel stack |
StackTop |
Top (high address) of the kernel stack |
Priority |
Scheduling priority (1–255); determines quantum length |
Quantum |
Total ticks allocated per time slice (Priority * BASE_QUANTUM) |
TicksUsed |
Ticks consumed in the current time slice |
PendingMsg |
Most recently delivered system message |
MsgData |
Optional payload associated with PendingMsg |
Resources |
Opaque pointer to a PDList of TResourceBinding records |
FDTable |
Opaque pointer to a PFDTable per-process file descriptor table |
Cwd |
Heap-allocated current working directory string; defaults to '/' |
Local |
Arbitrary user data pointer; used by WASM runner to store PProcessWASMShim |
Notes¶
TProcessContext uses void (untyped pointer) for Resources, FDTable, MsgData, and Local to avoid circular unit dependencies with core.ds.lists and driver.storage.fdtable. Callers cast these fields to their concrete types.