__switch_to(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __switch_to β€” switching tasks like the main character

okay so bestie, welcome to the Kernel API Manual ✨ this little page is all about __switch_to(9), and honestly? it's giving core scheduling energy 🫢


🌸 NAME 🌸

__switch_to β€” switch execution of a task πŸ’«

like, literally, it swaps one task out and another one in, no cap.


πŸŽ€ SYNOPSIS πŸŽ€

struct task_struct * __switch_to (struct task_struct *prev , struct
       task_struct *next , void *sched_ra , void *sched_cfa );

that's the whole signature, keeping it exactly as-is because we do not mess with the facts πŸ’…


✨ ARGUMENTS ✨

  • prev β€” the task that was previously executed, aka the one wrapping up its turn 😭
  • next β€” the task that's about to begin executing, the one stepping into the spotlight πŸ‘‘
  • sched_ra β€” the __schedule return address πŸ“
  • sched_cfa β€” the __schedule call frame address πŸ“

πŸ’– DESCRIPTION πŸ’–

so here's the vibe: this function is used whilst scheduling to save the context of prev & load the context of next πŸ”₯ it returns prev, fr fr.

that's it. that's the whole glow-up. saving the old context, loading the new one, handing prev back to you 🫢


πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./arch/loongarch/include/asm/switch_to.h β€” go read it, iykyk πŸ’œ

🌈 quick reminder bestie: sched_ra and sched_cfa are the __schedule return address and call frame address respectively β€” don't forget what they stand for, it's on the quiz πŸ’€

and that's a wrap, babe πŸŽ€ this page lives in ./arch/loongarch/include/asm, from the October 2026 era of the Kernel API Manual β€” slay, go schedule something iconic πŸ’…βœ¨

πŸ“¦ where this page comes from