raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a555fbf7693338d8b545d89f87a45852958a2166

commit a555fbf7693338d8b545d89f87a45852958a2166
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu May 21 18:00:47 2020 +0100

    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 05ab26cdea..f38c7880c1 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 c1a1ef0d22..c2bb041f24 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, &params);
+     }
+   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, &params);
+     }
+// 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, &params);
+        max = sched_get_priority_max(pol);
+        params.sched_priority += 5;
+        if (params.sched_priority > max) params.sched_priority = max;
+        pthread_setschedparam(self, pol, &params);
+     }
+
    _eina_debug_thread_add(&self);
    EINA_THREAD_CLEANUP_PUSH(_eina_debug_thread_del, &self);
    r = c->func((void*) c->data, eina_thread_self());

-- 


Reply via email to