SDL_SetLinux...rityAndPolicy(3)

πŸ’– NAME πŸ’–

SDL_SetLinuxThreadPriorityAndPolicy β€” bestie, this one sets the priority (not nice level, okay, don't get it twisted) and the scheduling policy for a thread. It's giving "I'm the main character of the CPU scheduler" energy. πŸ‘‘

This page lives in the SDL3 FUNCTIONS section of the manual, just so you know where you are. πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_system.h>

bool SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);

That's the whole vibe. Three args, one bool back, no cap. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So like, what this actually does? It uses setpriority() if possible, and RealtimeKit if it's available. That's it, that's the tea. πŸ“

Basically it's out here trying the normal route first, and if that doesn't work out it'll go hang with RealtimeKit instead. Very resourceful of it, honestly. Obsessed. ✨


🌸 FUNCTION PARAMETERS 🌸

  • threadID β€” the Unix thread ID you wanna change the priority of. Like, the actual thread, not a vibe, a real one. 🧡
  • sdlPriority β€” the new SDL_ThreadPriority value. This is the SDL-flavoured priority, iykyk. 🌈
  • schedPolicy β€” the new scheduling policy, and the options are SCHED_FIFO, SCHED_RR, SCHED_OTHER, etc... β€” yes it really says etc, pick your fighter. πŸ”₯

πŸ’€ RETURN VALUE πŸ’€

Returns true on success or false on failure. And if it fails, don't just sit there spiraling β€” call SDL_GetError() for more information, she will tell you what went wrong. 😭

Lowkey important: false means something broke. SDL_GetError() is your bestie in that moment, fr fr.

🫢 THREAD SAFETY 🫢

It is safe to call this function from any thread. Any. Thread. Go off, you multitasking icon. πŸ‘‘


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. So if you're on something older... girl, update. πŸ’…


Simple Directmedia Layer β€’ SDL 3.4.18 β€” that's the source and version and date situation, mwah, thanks for coming to my TED talk, ily, go set some priorities bestie πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from