[CM] Fwd: Linux/Midi Test

Kjetil S. Matheussen k.s.matheussen at notam02.no
Tue Aug 11 12:50:05 PDT 2009


To change the priority of a SCHED_OTHER program, you can use
setpriority instead. The last argument for setpriority selects
the nice priority, which goes from -20 to 19. -20 is highest
priority, 19 the lowest.

So to change the priority of the current process to
highest possible non-realtime, you call
setpriority(PRIO_PROCESS,0,-20)

I think you can change the priority of a different process by setting
the second argument of setpriority to a pid.



On Tue, 11 Aug 2009, lieven moors wrote:

> Ok I managed, apparently if you change to SCHED_OTHER, the only value you
> can use for the priority is 0, in order to set it. I thought I could use the 
> 'nice' value...
>
> I changed the realtime thread of CM to SCHED_OTHER because I thought it might 
> reveal a problem
> in Juce with realtime scheduling (I had terrible results when running the 
> test program with realtime scheduling).
> But still no luck. Even with SCHED_OTHER, and with the changes to 
> juce_amalgamated, CM doesn't sounds tight
> with a very simple process.
>
> Thanks for all your help today, and I'll have another stab at it later.
>
> Greetings
>
>
> Kjetil S. Matheussen wrote:
>> 
>> 
>> On Tue, 11 Aug 2009, lieven moors wrote:
>> 
>>> It's seems that the only way I got a good timing, was by running the 
>>> process
>>> in a normal, non realtime thread. I can change the realtime priority of 
>>> the CM thread
>>> to 1 (lowest), but I cannot change it into a normal priority thread (I 
>>> don't know how).
>>> Could you tell me what (and where) to change, so that the CM thread 
>>> wouldn't use realtime priority?
>>> 
>>> Or perhaps kjetil: do you know how to do that without recompiling CM?
>>> 
>> 
>> You can use the chrt command to get/set scheduling policy and priority.
>> 
>> 
>> For setting scheduling policy and priority in c, I use the following 
>> function in das_watchdog:
>> 
>> static int set_pid_priority(pid_t pid,int policy,int priority,char 
>> *message,char *name){
>>   struct sched_param par={0};
>>   par.sched_priority=priority;
>>   if((sched_setscheduler(pid,policy,&par)!=0)){
>>     print_error(stderr,message,pid,name,strerror(errno));
>>     return 0;
>>   }
>>   return 1;
>> }
>> 
>> 
>> 
>> To set normal priority for a process, it can be called like this:
>> 
>> set_pid_priority(pid,SCHED_OTHER,0,"Could not set pid %d (\"%s\") to 
>> SCHED_OTHER (%s).\n","no name"))
>> 
>> 
>
>



More information about the Cmdist mailing list