[PD-dev] pthread_setschedparam problem on OSX + fix

guenter geiger geiger at xdv.org
Mon Nov 24 12:43:09 CET 2003


Hi,

I was just about applying this to the CVS version, together with
Yves threading patch, but I think it would be better to leave
this decision up to you.

Guenter

On Sun, 23 Nov 2003, cgc wrote:

> I've been meaning to post this change for a long time, and have been
> negligent about it.
>
> The pthread_setschedparam() hack that helps pd's audio not drop on OSX
> is absolutely fatal when used with GEM.  The reason for this is that
> OSX uses OpenGL for the entire UI and GL requires context switches to
> handle multiple applications sharing the hardware.  When Pd sets it's
> pthread priority higher than the UI, this context switch can be blocked
> resulting in a complete lockout of UI events as GEM grabs all the CPU
> resources and refuses to relinquish the context.
>
> The fix is to add the -rt option as prerequisite and not make this the
> default action (a check to make sure GEM is not loaded would be good to
> have as well):
>
> #ifdef MACOSX
>
>      if (sys_hipriority)
>      {
> 	struct sched_param param;
> 	int policy = SCHED_RR;
> 	int err;
> 	param.sched_priority = 80; // adjust 0 : 100
>          post("pd: real-time mode - using pthread_setschedparam\n");
> 	err = pthread_setschedparam(pthread_self(), policy, &param);
> 	if (err)
> 	    post("warning: high priority scheduling failed\n");
>      }
> #endif /* MACOSX */
>
>





More information about the Pd-dev mailing list