From 21b08bcf6999fd042281439f156f308df2bd27f7 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Mon, 19 Jun 2017 14:56:05 +0900 Subject: [PATCH] Separate threshold value for each slot - A threshold value should not affect other slots Change-Id: I3ed88b7866009515b7c5afb7110649bd7b4017f6 Signed-off-by: Junghoon Park --- src/launchpad.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index 7dbf9d5..fde83a9 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -81,6 +81,7 @@ typedef struct { unsigned long long cpu_total_time; unsigned long long cpu_idle_time; guint idle_checker; + int threshold; } candidate_process_context_t; typedef struct { @@ -107,7 +108,6 @@ static int user_slot_offset; static GList *candidate_slot_list; static app_labels_monitor *label_monitor; static GList *launcher_info_list; -static int __threshold = DEFAULT_THRESHOLD; static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *extra, @@ -1103,7 +1103,7 @@ static float __interpolator(float input) return ret; } -static void __update_threshold(float delta) +static void __update_threshold(candidate_process_context_t *cpc, float delta) { static float pos = 0.0f; @@ -1114,8 +1114,9 @@ static void __update_threshold(float delta) if (pos > 1.0f) pos = 1.0f; - __threshold = (int)(__interpolator(pos) * 100); - _D("[CPU] delta:%f / input cursor : %f / threshold : %d", delta, pos, __threshold); + cpc->threshold = (int)(__interpolator(pos) * 100); + _D("[CPU] type:%d / delta:%f / input cursor : %f / threshold : %d", + cpc->type, delta, pos, cpc->threshold); } static gboolean __handle_idle_checker(gpointer data) @@ -1132,8 +1133,8 @@ static gboolean __handle_idle_checker(gpointer data) per = (idle - cpc->cpu_idle_time) * 100 / (total - cpc->cpu_total_time); _D("[CPU] Idle : %d / type : %d", per, cpc->type); - if (per >= __threshold) { - __update_threshold(-0.02f * (per - __threshold)); + if (per >= cpc->threshold) { + __update_threshold(cpc, -0.02f * (per - cpc->threshold)); __prepare_candidate_process(cpc->type, cpc->loader_id); cpc->idle_checker = 0; return G_SOURCE_REMOVE; @@ -1141,7 +1142,7 @@ static gboolean __handle_idle_checker(gpointer data) cpc->cpu_idle_time = idle; cpc->cpu_total_time = total; - __update_threshold(0.05f); + __update_threshold(cpc, 0.05f); return G_SOURCE_CONTINUE; } @@ -1484,6 +1485,7 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, cpc->cpu_total_time = 0; cpc->cpu_idle_time = 0; cpc->idle_checker = 0; + cpc->threshold = DEFAULT_THRESHOLD; fd = __listen_candidate_process(cpc->type, cpc->loader_id); if (fd == -1) { -- 2.7.4