Modified the input thread to inherit the priority of the main thread 21/320321/1
authorInhong Han <inhong1.han@samsung.com>
Wed, 13 Nov 2024 05:54:35 +0000 (14:54 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 13 Nov 2024 06:34:47 +0000 (15:34 +0900)
When calling the ecore_thread_feedback_run() API with try_no_queue set to false, it will be executed with a default priority.
And the booster can't apply boosting.

Change-Id: Iea4fcaee9eafb2aba5cbc15f9c0d152fcc5f1fbc

src/bin/inputmgr/e_input_backend.c

index 98f9f8a2f715264647ed4b9948fe0388078c6eab..4ed036d077a7daec9d914ebaa461742a47fa62d7 100644 (file)
@@ -1162,6 +1162,25 @@ _pipe_recv_handler(GIOChannel *source, GIOCondition condition, gpointer user_dat
    return TRUE;
 }
 
+static void
+_lower_priority()
+{
+   pthread_t self = pthread_self();
+   struct sched_param params;
+   int pol;
+   int err = pthread_getschedparam(self, &pol, &params);
+   if (err != 0)
+     {
+        ERR("fail to get pthread param");
+        return;
+     }
+
+   // lower the priority that was raised by 5 in ecore_thread_feedback_run
+   params.sched_priority -= 5;
+   pthread_setschedparam(self, pol, &params);
+   LOGI("lower priority %d", params.sched_priority);
+}
+
 static void
 input_thread_start(void *data, Ecore_Thread *th)
 {
@@ -1175,6 +1194,7 @@ input_thread_start(void *data, Ecore_Thread *th)
    if (!(input = data)) return;
 
    eina_thread_name_set(eina_thread_self(), "input-thread");
+   _lower_priority();
 
    e_input_backend_libinput_context_create(input);
 
@@ -1390,7 +1410,7 @@ EINTERN void e_input_backend_thread_start()
 {
    EINA_SAFETY_ON_NULL_RETURN(g_input_backend);
 
-   g_input_backend->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, g_input_backend, EINA_FALSE);
+   g_input_backend->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, g_input_backend, EINA_TRUE);
 }
 
 EINTERN void e_input_backend_thread_init()