eina_sched: fix rt priority drop

Thanks to cedric for noticing this bug. Priority in userspace are in the
opposite order as in kernel space.




SVN revision: 67776
This commit is contained in:
Lucas De Marchi 2012-02-09 00:06:14 +00:00
parent 3be93385bf
commit 4c184eff2f
1 changed files with 13 additions and 6 deletions

View File

@ -41,7 +41,7 @@
#include "eina_sched.h"
#include "eina_log.h"
#define RTNICENESS 5
#define RTNICENESS 1
#define NICENESS 5
EAPI void
@ -62,10 +62,14 @@ eina_sched_prio_drop(void)
if (EINA_UNLIKELY(pol == SCHED_RR || pol == SCHED_FIFO))
{
prio = sched_get_priority_max(pol);
param.sched_priority += RTNICENESS;
if (prio > 0 && param.sched_priority > prio)
param.sched_priority = prio;
param.sched_priority -= RTNICENESS;
/* We don't change the policy */
if (param.sched_priority < 1)
{
EINA_LOG_INFO("RT prio < 1, setting to 1 instead");
param.sched_priority = 1;
}
pthread_setschedparam(pthread_id, pol, &param);
}
@ -78,7 +82,10 @@ eina_sched_prio_drop(void)
{
prio += NICENESS;
if (prio > 19)
prio = 19;
{
EINA_LOG_INFO("Max niceness reached; keeping max (19)");
prio = 19;
}
setpriority(PRIO_PROCESS, 0, prio);
}