int detection_method, int timeout_val);
static int __remove_slot(int type, int loader_id);
static int __add_default_slots(void);
+static gboolean __handle_idle_checker(gpointer data);
static int __make_loader_id(void)
{
if (cpt == NULL)
return -1;
- _D("prepare candidate process");
+ _D("prepare candidate process / type:%d", type);
memset(argbuf, ' ', LOADER_ARG_LEN);
argbuf[LOADER_ARG_LEN - 1] = '\0';
argv[LOADER_ARG_DUMMY] = argbuf;
return 0;
}
-static gboolean __handle_preparing_candidate_process(gpointer user_data)
+static gboolean __handle_timeout_event(gpointer user_data)
{
candidate_process_context_t *cpc;
+ unsigned long long total = 0;
+ unsigned long long idle = 0;
cpc = (candidate_process_context_t *)user_data;
- __prepare_candidate_process(cpc->type, cpc->loader_id);
- _D("Prepare another candidate process");
cpc->timer = 0;
+
+ if (cpc->idle_checker > 0)
+ return G_SOURCE_REMOVE;
+
+ _get_cpu_idle(&total, &idle);
+ cpc->cpu_idle_time = idle;
+ cpc->cpu_total_time = total;
+ _D("Add idle checker");
+ cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
+ __handle_idle_checker, cpc);
+
return G_SOURCE_REMOVE;
}
if (cpc->detection_method & METHOD_TIMEOUT) {
cpc->timer = g_timeout_add(cpc->timeout_val,
- __handle_preparing_candidate_process, cpc);
+ __handle_timeout_event, cpc);
}
}
if (cpc->idle_checker > 0)
g_source_remove(cpc->idle_checker);
cpc->idle_checker = 0;
-
__prepare_candidate_process(cpc->type, cpc->loader_id);
return G_SOURCE_REMOVE;
cpc->timer = 0;
}
- if (cpc->idle_checker > 0) {
- g_source_remove(cpc->idle_checker);
- cpc->idle_checker = 0;
+ if (cpc->idle_checker == 0) {
+ _get_cpu_idle(&total, &idle);
+ cpc->cpu_idle_time = idle;
+ cpc->cpu_total_time = total;
+ cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
+ __handle_idle_checker, cpc);
}
-
- _get_cpu_idle(&total, &idle);
- cpc->cpu_idle_time = idle;
- cpc->cpu_total_time = total;
- cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
- __handle_idle_checker, cpc);
}
iter = g_list_next(iter);