/* * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Flora License, Version 1.1 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __PROCESS_H #define __PROCESS_H #include /** * @brief The process structure. * * @note Do not read fields directly, the struct * is only available publicly to allow easy copy semantic */ struct process { int pid; char *appid; char *exe; unsigned long long total_ticks_used; unsigned long long frame_ticks_used; int memory_used; float update_time; float frame_time_inverted; }; /** * @brief Initialize process module. */ int process_init(); /** * @brief Gets last read process memory usage * * @param[in]: proc process * @param[out]: used the memory usage in KiB * * @return 0 on success, other value on error. */ int process_get_memory_usage(struct process *proc, int *used); /** * @brief Gets last read process CPU usage * * @param[in]: proc process * @param[out]: usage CPU usage in clock ticks * * @return 0 on success, other value on error. */ int process_get_cpu_usage(struct process *proc, unsigned long long *usage); /** * @brief Updates process memory & CPU usage data. * * @param[in]: proc process * * @return 0 on success, other value on error. */ int process_update(struct process *proc); /** * @brief Initializes process structure * * @param[in]: pid * @param[in]: proc process * * @return 0 on success, other value on error. */ void process_init_process(int pid, struct process *proc); /** * @brief Shutdown process structure * * @param[in]: proc process * * @return 0 on success, other value on error. * * @note the structure should be initialized with @process_init, @process_move */ void process_shutdown(struct process *proc); /** * @brief Get process pid * * @param[in]: proc process * * @return: pid */ int process_get_pid(const struct process *proc); /** * @brief Get process application id. * * @param[in]: proc process * * @return: appid or NULL if process is not an Tizen Application. */ const char *process_get_appid(struct process *proc); /** * @brief Pathname of executed command. * * @param[in]: proc process * * @return: exe file path or NULL in case of error. */ const char *process_get_exe(struct process *proc); /** * @brief Moves process data from one struct to another. * * @param[in]: dst destination process * @param[in]: src source process */ void process_move(struct process *dst, struct process *src); /** * @brief Gets average CPU usage percentage since last update. * * @param[in]: proc process * @param[out]: usage the cpu usage percentage * * @return 0 on success, other value on error. */ int process_get_cpu_usage_percentage(struct process *proc, float *usage); /** * @brief Gets average memory usage percentage on last update. * * @param[in]: proc process * @param[out]: usage the memory usage percentage * * @return 0 on success, other value on error. */ int process_get_memory_usage_percentage(struct process *dst, float *usage); /** * @brief Serializes process object as json * * @param[in]: proc process * @param[in/out]: the json builder object. */ void process_serialize(struct process *dst, JsonBuilder *builer); #endif