#define PAD_ERR_INVALID_PATH -4
#define CPU_CHECKER_TIMEOUT 1000
#define PI 3.14159265
+#define EVENT_BOOTING -1
typedef struct {
int type;
int threshold;
int threshold_max;
int threshold_min;
+ int cur_event;
} candidate_process_context_t;
typedef struct {
static int __remove_slot(int type, int loader_id);
static int __add_default_slots(void);
static gboolean __handle_idle_checker(gpointer data);
+static int __add_idle_checker(int detection_method, GList *cur);
static int __make_loader_id(void)
{
cpc->cpu_total_time = total;
_D("Add idle checker");
cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
- __handle_idle_checker, cpc);
+ __handle_idle_checker,
+ g_list_find(candidate_slot_list, cpc));
return G_SOURCE_REMOVE;
}
unsigned long long total = 0;
unsigned long long idle = 0;
int per;
- candidate_process_context_t *cpc = data;
+ GList *list = data;
+ candidate_process_context_t *cpc;
+
+ if (!data)
+ return G_SOURCE_REMOVE;
+ cpc = list->data;
_get_cpu_idle(&total, &idle);
if (total == cpc->cpu_total_time)
total++;
__update_threshold(cpc, -0.02f * (per - cpc->threshold));
__prepare_candidate_process(cpc->type, cpc->loader_id);
cpc->idle_checker = 0;
+ __add_idle_checker(cpc->cur_event, g_list_next(list));
return G_SOURCE_REMOVE;
}
return G_SOURCE_CONTINUE;
}
-static int __dispatch_cmd_hint(bundle *kb, int detection_method)
+static int __add_idle_checker(int detection_method, GList *cur)
{
candidate_process_context_t *cpc;
- GList *iter = candidate_slot_list;
+ GList *iter = cur;
unsigned long long total = 0;
unsigned long long idle = 0;
- _W("cmd hint %d", detection_method);
while (iter) {
cpc = (candidate_process_context_t *)iter->data;
+
+ if (strcmp("null", cpc->loader_path) == 0) {
+ iter = g_list_next(iter);
+ continue;
+ }
+
if (cpc->pid == CANDIDATE_NONE &&
- (cpc->detection_method & detection_method)) {
+ (detection_method == EVENT_BOOTING ||
+ (cpc->detection_method & detection_method))) {
if (cpc->timer > 0) {
g_source_remove(cpc->timer);
cpc->timer = 0;
_get_cpu_idle(&total, &idle);
cpc->cpu_idle_time = idle;
cpc->cpu_total_time = total;
+ cpc->cur_event = detection_method;
cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
- __handle_idle_checker, cpc);
+ __handle_idle_checker, iter);
+ _D("Add Idler checker");
+ return 0;
}
}
iter = g_list_next(iter);
}
+ return -1;
+}
+
+static int __dispatch_cmd_hint(bundle *kb, int detection_method)
+{
+ _W("cmd hint %d", detection_method);
+ __add_idle_checker(detection_method, candidate_slot_list);
+
return 0;
}
candidate_process_context_t *cpc;
bundle_raw *extra = NULL;
int len;
- unsigned long long total = 0;
- unsigned long long idle = 0;
if (!strcmp(info->exe, "null")) {
cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset,
if (cpc == NULL)
return;
- _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);
-
info->type = LAUNCHPAD_TYPE_USER + user_slot_offset;
user_slot_offset++;
}
user_slot_offset = 0;
g_list_foreach(loader_info_list, __add_slot_from_info, NULL);
+ __add_idle_checker(EVENT_BOOTING, candidate_slot_list);
return 0;
}