ecore thread - feedback threads should not be background threads...
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 21 May 2020 17:00:47 +0000 (18:00 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 24 May 2020 21:32:20 +0000 (06:32 +0900)
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
src/lib/eina/eina_thread.c

index 05ab26cdead44094b74ec1f61a05f39db2a55a1d..f38c7880c166d400155ae379376d908a3404b701 100644 (file)
@@ -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++;
index c1a1ef0d22856a4e19b965c3e3587d0c9c699938..c2bb041f2441c13c8c45b2abefa1bb3845bcc5b4 100644 (file)
@@ -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());