tmake

Number0x09
Signature(entry, sp, arg) -> tid or -err
Grouptask
Since1.0

Create a thread in the calling process, sharing its address space and handle table. The thread starts at entry(arg) on the stack you provide.

The caller owns the stack. tmake does not allocate one so pass the top of a region you mapped yourself, and size it for the thread’s needs.

The new thread gets its own TCB slot in the process’s TCB page, so its lmsg buffer and tid are reachable via the frozen TPIDRURO -> tdata_t path. A process is capped at TCB_MAX_SLOTS (7) threads by that page.

Arguments

RegisterNameDescription
r0entryThread entry point (user VA)
r1spTop of the thread's user stack (caller-allocated)
r2argSingle argument passed to the entry function

Returns

The new thread's tid.

Errors

CodeCondition
ERR_BADPTRentry or sp is not a valid user address
ERR_NOMEMNo free thread, or no free TCB slot in the process

See also