int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage_s **usage);
/**
- * @}
+ * @brief Gets the number of processors
+ * @since_tizen 3.0
+ *
+ * @param[out] num_core The number of whole processors
+ *
+ * @retval #RUNTIME_INFO_ERROR_NONE Successful
+ * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RUNTIME_INFO_ERROR_IO_ERROR An I/O error occurred (during file open operation)
+ */
+int runtime_info_get_processor_count(int *num_core);
+
+/**
+ * @brief Gets the current frequency of processor
+ * @since_tizen 3.0
+ *
+ * @param[in] core_idx The index (from 0) of CPU core that you want to know the frequency
+ * @param[out] cpu_freq The current frequency(MHz) of processor
+ *
+ * @retval #RUNTIME_INFO_ERROR_NONE Successful
+ * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RUNTIME_INFO_ERROR_IO_ERROR An I/O error occurred (during file open operation)
+ */
+int runtime_info_get_processor_current_frequency(int core_idx, int *cpu_freq);
+
+/**
+ * @brief Gets the max frequency of processor
+ * @since_tizen 3.0
+ *
+ * @param[in] core_idx The index (from 0) of CPU core that you want to know the frequency
+ * @param[out] cpu_freq The max frequency(MHz) of processor
+ *
+ * @retval #RUNTIME_INFO_ERROR_NONE Successful
+ * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RUNTIME_INFO_ERROR_IO_ERROR An I/O error occurred (during file open operation)
*/
+int runtime_info_get_processor_max_frequency(int core_idx, int *cpu_freq);
#ifdef __cplusplus
}
dbus_message_unref(replymsg);
return RUNTIME_INFO_ERROR_NONE;
}
+
+API int runtime_info_get_processor_count(int *num_core)
+{
+ FILE *cpuinfo_fp;
+ int buf;
+ int result;
+
+ if (!num_core) {
+ _E("INVALID_PARAMETER(0x%08x) : invalid output parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ cpuinfo_fp = fopen("/sys/devices/system/cpu/possible", "r");
+ if(cpuinfo_fp == NULL) {
+ _E("IO_ERROR(0x%08x) : failed to open file to read cpu information",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ if(!fscanf(cpuinfo_fp, "%d-%d", &buf, &result)) {
+ _E("IO_ERROR(0x%08x) : there is no information in the system file",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ *num_core = result + 1;
+
+ return RUNTIME_INFO_ERROR_NONE;
+}
+
+API int runtime_info_get_processor_current_frequency(int core_idx, int *cpu_freq)
+{
+ int num_core;
+ char path[256];
+ FILE *cpuinfo_fp;
+ int result;
+
+ if(runtime_info_get_processor_count(&num_core)) {
+ _E("runtime_info_get_processor_count is failed");
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ if(core_idx < 0 || core_idx >= num_core) {
+ _E("INVALID_PARAMETER(0x%08x) : invalid input parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cpu_freq) {
+ _E("INVALID_PARAMETER(0x%08x) : invalid output parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq",
+ core_idx);
+ cpuinfo_fp = fopen(path, "r");
+ if(cpuinfo_fp == NULL) {
+ _I("Fail to get the information about core%d. Get the core0's instead.",
+ core_idx);
+
+ cpuinfo_fp = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");
+ if(cpuinfo_fp == NULL) {
+ _E("IO_ERROR(0x%08x) : failed to open file to read cpu information",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+ }
+
+ if(!fscanf(cpuinfo_fp, "%d", &result)) {
+ _E("IO_ERROR(0x%08x) : there is no information in the system file",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ *cpu_freq = result / 1000;
+
+ return RUNTIME_INFO_ERROR_NONE;
+}
+
+API int runtime_info_get_processor_max_frequency(int core_idx, int *cpu_freq)
+{
+ int num_core;
+ char path[256];
+ FILE *cpuinfo_fp;
+ int result;
+
+ if(runtime_info_get_processor_count(&num_core)) {
+ _E("runtime_info_get_processor_count is failed");
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ if(core_idx < 0 || core_idx >= num_core) {
+ _E("INVALID_PARAMETER(0x%08x) : invalid input parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cpu_freq) {
+ _E("INVALID_PARAMETER(0x%08x) : invalid output parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq",
+ core_idx);
+ cpuinfo_fp = fopen(path, "r");
+ if(cpuinfo_fp == NULL) {
+ _I("Fail to get the information about core%d. Get the core0's instead.",
+ core_idx);
+
+ cpuinfo_fp = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
+ if(cpuinfo_fp == NULL) {
+ _E("IO_ERROR(0x%08x) : failed to open file to read cpu information",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+ }
+
+ if(!fscanf(cpuinfo_fp, "%d", &result)) {
+ _E("IO_ERROR(0x%08x) : there is no information in the system file",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ *cpu_freq = result / 1000;
+
+ return RUNTIME_INFO_ERROR_NONE;
+}