Mac Thread Priority

Does anyone know if SDL running on MacOS X registers
the program as a real-time process or just as a regular
application.

I know the order of priority goes
Application Processes
Kernel Processes
Real-time Processes

Where does an SDL app fit? If it doesn’t fall into the
real-time section is there any way to access the data
structures and functions (OS X Native) to change the
app over to real-time priority so that it will get more
processor time?

-Randall

Does anyone know if SDL running on MacOS X registers
the program as a real-time process or just as a regular
application.

I know the order of priority goes
Application Processes
Kernel Processes
Real-time Processes

Where does an SDL app fit? If it doesn’t fall into the
real-time section is there any way to access the data
structures and functions (OS X Native) to change the
app over to real-time priority so that it will get more
processor time?

So glad you asked :wink:

Currently, SDL runs as a normal process and doesn’t change the priority
etc. Changing this could be dangerous in some respects because we might
override the priority of the window server and stop getting events from
it in a timely fashion.

You can tweak the thread priority and scheduling using pthread_*
functions:

#include <pthread.h>

// enable realtime scheduling to get more CPU time.
if (realtime ) {
int policy;
struct sched_param param;

     pthread_t thread = pthread_self ();
     pthread_getschedparam (thread, &policy, &param);

     policy = 

SCHED_RR; //
round-robin, AKA real-time scheduling
param.sched_priority =
47; // you’ll have to play
with this to see what it does

     pthread_setschedparam (thread, policy, &param);
 }

This doesn’t really improve speeds in most situations. Rather it tends
to smooth out animation that seemed chunky before.

Cheers,
DarrellOn Saturday, December 15, 2001, at 03:29 PM, Randall Leeds wrote: