From 2565cc72d30f101363a27d6d01fc5b22518cdb86 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Thu, 21 May 2020 18:00:47 +0100 Subject: [PATCH] ecore thread - feedback threads should not be background threads... if try_no_queue is used - its a thread that clearly wantt to be out of the queue to run on its own so probably wants to wake up accurately and thus not be a backgroun rpriority task but and urgent one. ensure we set up priority accordingly as we didn't before. this should fix scheduling when under load for vsync @fix --- src/lib/ecore/ecore_thread.c | 3 ++- src/lib/eina/eina_thread.c | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c index 05ab26c..f38c788 100644 --- a/src/lib/ecore/ecore_thread.c +++ b/src/lib/ecore/ecore_thread.c @@ -40,6 +40,7 @@ # define PHE(x, y) eina_thread_equal(x, y) # define PHS() eina_thread_self() # define PHC(x, f, d) eina_thread_create(&(x), EINA_THREAD_BACKGROUND, -1, (void *)f, d) +# define PHC2(x, f, d)eina_thread_create(&(x), EINA_THREAD_URGENT, -1, (void *)f, d) # define PHJ(x) eina_thread_join(x) typedef struct _Ecore_Pthread_Worker Ecore_Pthread_Worker; @@ -953,7 +954,7 @@ ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy, eina_threads_init(); retry_direct: - if (PHC(t, _ecore_direct_worker, worker)) + if (PHC2(t, _ecore_direct_worker, worker)) { SLKL(_ecore_pending_job_threads_mutex); _ecore_thread_count_no_queue++; diff --git a/src/lib/eina/eina_thread.c b/src/lib/eina/eina_thread.c index c1a1ef0..c2bb041 100644 --- a/src/lib/eina/eina_thread.c +++ b/src/lib/eina/eina_thread.c @@ -141,11 +141,43 @@ _eina_internal_call(void *context) EINA_THREAD_CLEANUP_PUSH(free, c); - if (c->prio == EINA_THREAD_BACKGROUND || - c->prio == EINA_THREAD_IDLE) - eina_sched_prio_drop(); - self = pthread_self(); + + if (c->prio == EINA_THREAD_IDLE) + { + struct sched_param params; + int min; + + min = sched_get_priority_min(SCHED_IDLE); + params.sched_priority = min; + pthread_setschedparam(self, SCHED_IDLE, ¶ms); + } + else if (c->prio == EINA_THREAD_BACKGROUND) + { + struct sched_param params; + int min, max; + + min = sched_get_priority_min(SCHED_BATCH); + max = sched_get_priority_max(SCHED_BATCH); + params.sched_priority = (max - min) / 2; + pthread_setschedparam(self, SCHED_BATCH, ¶ms); + } +// do nothing for normal +// else if (c->prio == EINA_THREAD_NORMAL) +// { +// } + else if (c->prio == EINA_THREAD_URGENT) + { + struct sched_param params; + int max, pol; + + pthread_getschedparam(self, &pol, ¶ms); + max = sched_get_priority_max(pol); + params.sched_priority += 5; + if (params.sched_priority > max) params.sched_priority = max; + pthread_setschedparam(self, pol, ¶ms); + } + _eina_debug_thread_add(&self); EINA_THREAD_CLEANUP_PUSH(_eina_debug_thread_del, &self); r = c->func((void*) c->data, eina_thread_self()); -- 2.7.4