task_call_func(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 be current. 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 to func. 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:


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