Expand description
ThreadsScheme : Plan 9 style /thread control files.
Exposes the userspace thread API as filesystem operations. All lifecycle
work is forwarded to crate::process::thread_ops, the exact same
internals as SYS_THREAD_CREATE/JOIN/EXIT, so both entry points share one
implementation (single reap loop, single validation rules).
ยงFile layout
/thread/ directory: TIDs of the calling process' threads
create write 32-byte ThreadCreateRequest -> read back TID (u32 LE)
join/<tid>read blocks until <tid> exits -> exit code (i32 LE)
EINVAL self-join, ENOENT absent/already-joined
(=> a second open of join/<tid> fails; documented)
exit write exit code (i32 LE); kills current thread, no return
current read caller's TID (u32 LE), resolved at read time
yield read sched_yield; fd shareable across threads
kill/<tid>open terminates <tid>; ESRCH absent, EPERM cross-process
stats read kernel-owned stack counters ("allocated N", "active M")Structsยง
Enumsยง
- Op ๐
- Operation encoded in the high bits of a file_id.
- OpState ๐
- Per-fd state retained between open/write/read.
Constantsยง
- THREAD_
CREATE_ ๐REQ_ LEN - Binary protocol for
/thread/createwrites.
Functionsยง
- init_
threads_ scheme - Convenience constructor matching the other scheme registration sites.
- itoa_
u32 ๐ - Minimal decimal formatter (no formatting machinery in hot paths).
- op_of ๐
- serve_
string ๐ - Serve string content honoring read offsets (procfs pattern).