2 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <sys/types.h>
25 #include "sysman_managed.h"
28 #define DEPRECATED __attribute__((deprecated))
33 * @ingroup libsysman System Manager library
34 * @brief This library provides APIs related with memory, performance, processes, and so on.
41 * @defgroup libsysman System Manager library
42 * @ingroup SYSTEM_FRAMEWORK
43 * @brief System manager library
45 * This library provides APIs related with memory, performance, processes, and so on.
46 * <br> Please use libslp-sysman-dev debian package and sysman.pc file for development.
47 * <br> And include sysman.h file at your source codes as following.
48 * @addtogroup libsysman System Manager library
57 * @breif Policy for low memory
60 OOM_LIKELY, /**< For miscellaneous applications */
61 OOM_IGNORE /**< For daemons */
67 * @fn int sysman_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
68 * @brief This API is used to get the file name of command line of the process from the proc fs.
69 * Caller process MUST allocate enough memory for the cmdline parameter. \n
70 * Its size should be assigned to cmdline_size. \n
71 * Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline.
72 * @param[in] pid pid of the process that you want to get the file name of command line
73 * @param[out] cmdline command line of the process that you want to get the file name <br>
74 * Callers should allocate memory to this parameter before calling this function.
75 * The allocated memory size must be large enough to store the file name.
76 * The result will include the terminating null byte('\0') at the end of the string.
77 * @return 0 on success, -1 if failed. If the size of cmdline is smaller than the result,
78 * it will return -1 and errno will be set as EOVERFLOW.
80 int sysman_get_cmdline_name(pid_t pid, char *cmdline,
84 * @fn char *sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size)
85 * @brief This API is used to get the execution path of the process specified by the pid parameter.\n
86 * Caller process MUST allocate enough memory for the app_path parameter. \n
87 * Its size should be assigned to app_path_size. \n
88 * Internally it reads a link of /proc/{pid}/exe and copies the path to app_path.
89 * @param[in] pid pid of the process that you want to get the executed path
90 * @param[out] app_path the executed file path of the process <br>
91 * Callers should allocate memory to this parameter before calling this function.
92 * The allocated memory size must be large enough to store the executed file path.
93 * The result will include the terminating null byte('\0') at the end of the string.
94 * @param[in] app_path_size allocated memory size of char *app_path
95 * @return 0 on success, -1 if failed. If the size of app_path is smaller than the result,
96 * it will return -1 and errno will be set as EOVERFLOW.
98 int sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size);
103 * @fn int sysconf_set_mempolicy(enum mem_policy mempol)
104 * @brief This API is used to set the policy of the caller process when the phone has low available memory.
105 * @param[in] mempol oom adjust value which you want to set
106 * @return 0 on success, -1 if failed.
107 * @see sysconf_set_mempolicy_bypid()
109 int sysconf_set_mempolicy(enum mem_policy mempol);
112 * @fn int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol)
113 * @brief This API is used to set the policy of the process when the phone has low available memory.
114 * @param[in] pid process id which you want to set
115 * @param[in] mempol oom adjust value which you want to set
116 * @return 0 on success, -1 if failed.
118 int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol);
121 * @fn int sysconf_set_permanent(void)
122 * @brief This API is used to set itself as a permanent process.\n
123 * If the permanent process is dead, system server will relaunch the process automatically.
124 * @return 0 on success, -1 if failed.
125 * @see sysconf_set_permanent_bypid()
129 * ret = sysconf_set_permanent();
131 * printf("Fail to set a process as permanent\n");
135 int sysconf_set_permanent(void);
138 * @fn int sysconf_set_permanent_bypid(pid_t pid)
139 * @brief This API is used to set a process which has pid as a permanent process.\n
140 * If the permanent process is dead, system server will relaunch the process automatically.
141 * @return 0 on success, -1 if failed.
142 * @see sysconf_set_permanent()
146 * ret = sysconf_set_permanent_bypid(pid);
148 * printf("Fail to set a process(%d) as permanent\n",pid);
152 int sysconf_set_permanent_bypid(pid_t pid);
155 * @fn int sysconf_set_vip(pid_t pid)
156 * @brief This API is used to set a process which has pid as Very Important Process(VIP) .\n
157 * If the VIP process is dead, restarter program will be run. \n
158 * Restarter program may kill almost processes and run rc.local scripts again.
159 * @param[in] pid process id to be vip
160 * @return 0 on success, -1 if failed.
161 * @see sysconf_is_vip
165 * ret = sysconf_set_vip(pid);
167 * printf("Fail to set a process(%d) as VIP\n",pid);
171 int sysconf_set_vip(pid_t pid);
174 * @fn int sysconf_is_vip(pid_t pid)
175 * @brief This API is used to verify that process which has pid is Very Important Process(VIP) or not.
176 * @param[in] pid process id to be vip
177 * @return 1 on success, 0 if failed.
178 * @see sysconf_set_vip
182 * ret = sysconf_is_vip(pid);
184 * printf("process(%d) is Very Important Process\n",pid);
188 int sysconf_is_vip(pid_t pid);
190 int sysman_set_timezone(char *tzpath_str);
192 int sysman_call_predef_action(const char *type, int num, ...);
194 int sysman_inform_foregrd(void);
195 int sysman_inform_backgrd(void);
196 int sysman_inform_active(pid_t pid);
197 int sysman_inform_inactive(pid_t pid);
199 int sysman_request_poweroff(void);
200 int sysman_request_entersleep(void);
201 int sysman_request_leavesleep(void);
202 int sysman_request_reboot(void);
204 int sysman_request_set_cpu_max_frequency(int val);
205 int sysman_request_set_cpu_min_frequency(int val);
207 int sysman_release_cpu_max_frequency(void);
208 int sysman_release_cpu_min_frequency(void);
217 #endif /* ___SYSMAN___ */