[PD-dev] Re: [PD] pthread_setschedparam problem on OSX + fix
Miller Puckette
mpuckett at man104-1.ucsd.edu
Sat Jan 17 23:33:24 CET 2004
OK.. I've added an "nrt" flag so that on Mac the default ("rt") acts
as it did before... When I get started on 0.38 I can make linux
choose "rt" automatically if it's setuid.
cheers
Miller
On Sun, Nov 23, 2003 at 03:18:21PM -0600, 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, ¶m);
> if (err)
> post("warning: high priority scheduling failed\n");
> }
> #endif /* MACOSX */
>
>
>
More information about the Pd-dev
mailing list