Expand description
Thread lifecycle operations shared by the syscall layer and /thread VFS scheme.
Extracted from syscall/process.rs so that both SYS_THREAD_CREATE/JOIN/EXIT
and the Plan 9 style /thread/* scheme forward to the exact same internal
implementation (no duplicated WaitQueue, no duplicated validation).
Also owns the kernel-owned user stack bookkeeping: threads created via
/thread/create get their user stack allocated and mapped by the kernel,
which reclaims it deterministically when the thread dies. Threads created
through raw SYS_THREAD_CREATE keep providing their own stack and leave
the field untouched.
StructsΒ§
- Thread
User πContext - User
Entry Context - Callerβs userspace segment/flag state used to seed the child iret frame.
ConstantsΒ§
- THREAD_
DEFAULT_ STACK_ BYTES - Default size when the caller passes
stack_size == 0. - THREAD_
MAX_ STACK_ BYTES - THREAD_
MIN_ STACK_ BYTES - Bounds of a kernel-owned user stack request.
- THREAD_
OFF_ πARG0 - THREAD_
OFF_ πENTRY - THREAD_
OFF_ πSTACK_ TOP - THREAD_
OFF_ πUSER_ CS - THREAD_
OFF_ πUSER_ RFLAGS - THREAD_
OFF_ πUSER_ SS - USER_
TOP_ πEXCLUSIVE
StaticsΒ§
- KERNEL_
USER_ πSTACKS_ ACTIVE - Number of kernel-owned user stacks currently alive (allocated - reclaimed).
- KERNEL_
USER_ πSTACKS_ ALLOCATED - Total number of kernel-owned user stacks ever allocated.
FunctionsΒ§
- alloc_
kernel_ πuser_ stack - Allocate and lazily map a user stack in the parent process address space.
- build_
user_ πthread_ task - Performs the build user thread task operation.
- create_
user_ thread - Core of
SYS_THREAD_CREATEand/thread/create. - create_
user_ πthread_ inner - create_
user_ thread_ with_ kernel_ stack /thread/createvariant: the kernel allocates and owns the user stack.- current_
thread_ tid - Current TID of the calling task (scheme
/thread/currentfast path). - exit_
current_ thread - Core of
SYS_THREAD_EXITand/thread/exit. - join_
task - Core of
SYS_THREAD_JOINand/thread/join/<tid>. - kernel_
user_ stack_ stats - Snapshot of kernel-owned user stack counters
(allocated_total, active). - kill_
thread - Kill a thread by TID, restricted to threads of the callerβs own process.
- page_
align_ πup - reclaim_
kernel_ user_ stack - Reclaim the kernel-owned user stack of
task, if any. - thread_
child_ πstart - Performs the thread child start operation.
- thread_
iret_ π βfrom_ ctx - Performs the thread iret from ctx operation.