1 /* EINA - EFL data type library
2 * Copyright (C) 2010 ProFUSION embedded systems
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
23 #ifdef EFL_HAVE_POSIX_THREADS
27 # include <sys/time.h>
28 # include <sys/resource.h>
33 #ifdef EFL_HAVE_WIN32_THREADS
34 # ifndef WIN32_LEAN_AND_MEAN
35 # define WIN32_LEAN_AND_MEAN
38 # undef WIN32_LEAN_AND_MEAN
41 #include "eina_sched.h"
48 eina_sched_prio_drop(void)
50 #ifdef EFL_HAVE_POSIX_THREADS
51 struct sched_param param;
55 pthread_id = pthread_self();
56 ret = pthread_getschedparam(pthread_id, &pol, ¶m);
59 EINA_LOG_ERR("Unable to query sched parameters");
63 if (EINA_UNLIKELY(pol == SCHED_RR || pol == SCHED_FIFO))
65 param.sched_priority -= RTNICENESS;
67 /* We don't change the policy */
68 if (param.sched_priority < 1)
70 EINA_LOG_INFO("RT prio < 1, setting to 1 instead");
71 param.sched_priority = 1;
74 pthread_setschedparam(pthread_id, pol, ¶m);
80 prio = getpriority(PRIO_PROCESS, 0);
86 EINA_LOG_INFO("Max niceness reached; keeping max (19)");
90 setpriority(PRIO_PROCESS, 0, prio);
94 #elif defined EFL_HAVE_WIN32_THREADS
95 if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL))
96 EINA_LOG_ERR("Can not set thread priority");
98 EINA_LOG_ERR("Eina does not have support for threads enabled"
99 "or it doesn't support setting scheduler priorities");