task_call_func(9)
π task_call_func β like, the Kernel API Manual, section 9, bestie
okay so real talk: this is task_call_func(9) from the Kernel API Manual (yes, section 9, the ~spicy~ section) and it's genuinely one of the most "let me just freeze time for a sec" functions in the scheduler. iykyk. π§
β¨ NAME β¨
task_call_func β invoke a function on a task in a fixed state π
like... you pin the task down, you call your little function on it, and the state literally cannot move. slay.
πΈ SYNOPSIS πΈ
int task_call_func (struct task_struct *p , task_call_f func , void *arg
);
(the weird line break is not a typo, that's just how the manpage wrote it, don't come for me π β it's all one call fr fr)
π¦ ARGUMENTS π¦
pβ the process you want the function invoked on. and yes bestie, it can becurrent. main character energy, honestly πfuncβ the function you're invoking. this is your moment, your callback, your time to shine β¨argβ the argument you're handing tofunc. it's giving "here, hold this" π«Ά
π DESCRIPTION π
so the whole vibe here: task_call_func fixes the task in its current state by avoiding wakeups and/or rq operations, and then calls func(arg) on it. that's it. that's the whole thing. periodt. π
and like β this function can use task_is_runnable and task_curr to work out what the state actually is, if you need that. handy, right? π
β οΈ okay but listen: given that func can be invoked with a runqueue lock held, it had better be quite lightweight. like. quite lightweight. no cap. if your callback is doing a whole side quest in there, that's on you and it's not gonna be iconic, it's gonna be a problem ππ₯
β RETURN β
whatever func returns. that's it. you get back what your baby function gives back π (no extra wrapping, no surprises, we're not like that)
π SEE ALSO π
kernel file ./kernel/sched/core.c β go read it, it's right there:
wake_q_add(9)wake_q_add_safe(9)task_curr(9)try_to_wake_up(9)cpu_curr_snapshot(9)wake_up_process(9)preempt_notifier_register(9)preempt_notifier_unregister(9)prepare_task_switch(9)finish_task_switch(9)schedule_tail(9)schedule_preempt_disabled(9)preempt_schedule_notrace(9)init_idle(9)curr_task(9)
anyway that's the page!! π it lives in ./kernel/sched, it's dated October 2026, and it came to you straight from the Kernel API Manual task_call_func(9). go be lightweight with your callbacks and stay hydrated, bestie ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms