io_channel_h hydra_channel;
unsigned int score;
unsigned int pss;
+ int cpu_check_count;
} candidate_process_context_t;
typedef struct {
static sequencer __sequencer;
static int MEMORY_STATUS_LOW;
static int MEMORY_STATUS_NORMAL;
+static int MAX_CPU_CHECK_COUNT;
static io_channel_h __logger_channel;
static io_channel_h __label_monitor_channel;
_get_cpu_idle(&total, &idle);
cpc->cpu_idle_time = idle;
cpc->cpu_total_time = total;
+ cpc->cpu_check_count = 0;
__sequencer.idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT,
__handle_idle_checker, cpc);
cpc = (candidate_process_context_t *)data;
if (cpc->app_check && !cpc->app_exists) {
- _W("The application is not installed. Type(%d)", cpc->type);
+ _W("The application is not installed. loader(%s:%d)",
+ cpc->loader_name, cpc->type);
__sequencer.idle_checker = 0;
__sequencer.running_cpc = NULL;
return G_SOURCE_REMOVE;
}
if (cpc->state != CANDIDATE_PROCESS_STATE_RUNNING) {
- _W("Slot state is not running. Type(%d)", cpc->type);
+ _W("Slot state is not running. loader(%s:%d)",
+ cpc->loader_name, cpc->type);
__sequencer.idle_checker = 0;
__sequencer.running_cpc = NULL;
return G_SOURCE_REMOVE;
total++;
per = (idle - cpc->cpu_idle_time) * 100 / (total - cpc->cpu_total_time);
- _D("[CPU] Idle : %d / type : %d", per, cpc->type);
+ _D("[CPU] Idle : %d / loader(%s:%d)", per, cpc->loader_name, cpc->type);
if (per >= cpc->threshold) {
__update_threshold(cpc, -0.02f * (per - cpc->threshold));
cpc->cpu_total_time = total;
__update_threshold(cpc, 0.05f);
+ cpc->cpu_check_count++;
+ if (cpc->cpu_check_count == MAX_CPU_CHECK_COUNT) {
+ _W("CPU check count has exceeded %d times. loader(%s:%d)",
+ cpc->cpu_check_count,
+ cpc->loader_name,
+ cpc->type);
+ __sequencer.idle_checker = 0;
+ __sequencer.running_cpc = NULL;
+ __sequencer_add_slot(cpc);
+ return G_SOURCE_REMOVE;
+ }
+
return G_SOURCE_CONTINUE;
}
cpc->app_check = app_check;
cpc->score = WIN_SCORE;
cpc->pss = 0;
+ cpc->cpu_check_count = 0;
if ((cpc->deactivation_method & METHOD_OUT_OF_MEMORY) &&
__is_low_memory())
else
cpc->state = CANDIDATE_PROCESS_STATE_RUNNING;
+ _W("loader(%s), type(%d), state(%d)",
+ cpc->loader_name, cpc->type, cpc->state);
return cpc;
}
{
candidate_process_context_t *cpc;
- _W("low memory(%s)", low_memory ? "true" : "false");
cpc = __get_running_slot(false);
if (!cpc && low_memory)
return -1;
if (low_memory) {
+ _W("Low memory");
__update_slots_pss();
candidate_slot_list = g_list_sort(candidate_slot_list,
_inotify_init();
+ MAX_CPU_CHECK_COUNT = _config_get_int_value(
+ CONFIG_TYPE_CPU_CHECKER_MAX_COUNT);
__add_default_slots();
launcher_info_list = _launcher_info_load(LAUNCHER_INFO_PATH);
#define KEY_MEMORY_MONITOR_THRESHOLD "Threshold"
#define KEY_MEMORY_MONITOR_INTERVAL "Interval"
+#define TAG_CPU_CHECKER "CpuChecker"
+#define KEY_CPU_CHECKER_MAX_COUNT "MaxCount"
+
struct memory_status_s {
char *low_key;
int low_value;
int interval;
};
+struct cpu_checker_s {
+ int max_count;
+};
+
static struct memory_status_s __memory_status;
static struct memory_monitor_s __memory_monitor;
+static struct cpu_checker_s __cpu_checker;
const char *_config_get_string_value(config_type_e type)
{
case CONFIG_TYPE_MEMORY_MONITOR_INTERVAL:
value = __memory_monitor.interval;
break;
+ case CONFIG_TYPE_CPU_CHECKER_MAX_COUNT:
+ value = __cpu_checker.max_count;
+ break;
default:
_E("Unknown type");
value = INT_MIN;
__memory_monitor.interval);
}
+static void __cpu_checker_init(void)
+{
+ __cpu_checker.max_count = 10;
+}
+
+static void __cpu_checker_fini(void)
+{
+ __cpu_checker.max_count = 0;
+}
+
+static void __cpu_checker_set(dictionary *d)
+{
+ int ret;
+
+ ret = __get_int_value(d, TAG_CPU_CHECKER,
+ KEY_CPU_CHECKER_MAX_COUNT);
+ if (ret != INT_MAX)
+ __cpu_checker.max_count = ret;
+
+ _W("CPU Checker MaxCount(%d)", __cpu_checker.max_count);
+}
+
int _config_init(void)
{
dictionary *d;
__memory_status_init();
__memory_monitor_init();
+ __cpu_checker_init();
ret = access(PATH_LAUNCHPAD_CONF, F_OK);
if (ret != 0) {
__memory_status_set(d);
__memory_monitor_set(d);
+ __cpu_checker_set(d);
iniparser_freedict(d);
{
_D("config fini");
+ __cpu_checker_fini();
__memory_monitor_fini();
__memory_status_fini();
}