Skip to main content

Module kthread

Module kthread 

Source
Expand description

Kernel thread API (kthread).

Ergonomic wrapper over Task::new_kernel_task + add_task for spawning closure-based kernel threads. Kernel threads stay internal: they never go through /thread/* because SYS_THREAD_CREATE / /thread/create refuse kernel parents by design.

ⓘ
let tid = kthread::spawn("gc-worker", || {
    loop { /* ... */ kthread::yield_now(); }
})?;

Functions§

current_task
Convenience: clone of the current task’s Arc<Task>, if any.
current_tid
TaskId of the calling kernel thread, if one is current.
kthread_trampoline 🔒
Trampoline for closure-based kernel threads.
spawn
Spawn a kernel thread running f.
yield_now
Cooperative yield for kernel threads.