Set Prio ProcessLock Error sched_setscheduler: Operation not permitted

Hi everybody,

I used Beaglebone since 4 years with a custom Ubuntu kernel without problems.

We decided to migrate system on the last debian release, but we have a probleme with priority changed procedure. (Linux beaglebone 4.9.105-ti-r113 #1 SMP PREEMPT Sat Jun 16 01:46:52 UTC 2018 armv7l GNU/Linux)

All process who ask special priority answer : Set Prio ProcessLock Error sched_setscheduler: Operation not permitted, all process are launched with root privileges, Idon’t understand what’s append with debian:/

Here is the code who set priority : Environment variable PRIORITY is set to “YES”

`
if(getenv(“PRIORITY”)){
if(strcmp((char *)getenv(“PRIORITY”),“YES”)==0L){

min=sched_get_priority_min(SCHED_RR);
max=sched_get_priority_max(SCHED_RR);
if(*prioprocess > max) *prioprocess=max;
if(*prioprocess < min) *prioprocess=min;
getrlimit(RLIMIT_RTPRIO,&r);
printf(“Prio Min=%d Prio Max=%d rlimit=%d/%d\n”,min,max,r.rlim_cur,r.rlim_max);
r.rlim_cur=99;
r.rlim_max=99;
setrlimit(RLIMIT_RTPRIO,&r);
getrlimit(RLIMIT_RTPRIO,&r);
printf(“Prio Min=%d Prio Max=%d rlimit=%d/%d\n”,min,max,r.rlim_cur,r.rlim_max);
perror(“setrlimit:”);
if(*prioprocess > 98) *prioprocess=98;
if(*prioprocess < 1) *prioprocess=1;
p.sched_priority=100-*prioprocess;
printf(“Set priority : %d pid=%d\n”,p.sched_priority,getpid());
ret=sched_setscheduler(0,SCHED_RR,&p);
if(ret) perror(“Set Prio ProcessLock Error sched_setscheduler”);

} else if (strcmp((char *)getenv(“PRIORITY”),“SCHED_FIFO”)==0L){
if(*prioprocess > 98) *prioprocess=98;
if(*prioprocess < 1) *prioprocess=1;
p.sched_priority=100-*prioprocess;
printf(“Set priority : %d \n”,p.sched_priority);
ret=sched_setscheduler(0,SCHED_FIFO,&p);
if(ret) perror(“Set Prio ProcessLock Error sched_setscheduler”);

} else if (strcmp((char *)getenv(“PRIORITY”),“DAN”)==0L){
if(*prioprocess > 40 ) *prioprocess =20;
else *prioprocess -= 20;
ret = setpriority(PRIO_PROCESS,(int)getpid(),*prioprocess);
if(ret) perror(“Set Prio ProcessLock Error setpriority”);

}else{
printf(“PRIORITY ENV not set to YES :%s\n”,getenv(“PRIORITY”));
}
}else
{
printf(“PRIORITY NOT SET\n”);
}

`

Please have you an idea of what is the problem ?

Many thanks for any help.