4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongGi Jang <dg0402.jang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include <sys/types.h>
30 #include "sysman_managed.h"
33 #define DEPRECATED __attribute__((deprecated))
38 * @ingroup libsysman System Manager library
39 * @brief This library provides APIs related with memory, performance, processes, and so on.
46 * @defgroup libsysman System Manager library
47 * @ingroup SYSTEM_FRAMEWORK
48 * @brief System manager library
50 * This library provides APIs related with memory, performance, processes, and so on.
51 * <br> Please use libslp-sysman-dev debian package and sysman.pc file for development.
52 * <br> And include sysman.h file at your source codes as following.
53 * @addtogroup libsysman System Manager library
62 * @breif Policy for low memory
65 OOM_LIKELY, /**< For miscellaneous applications */
66 OOM_IGNORE /**< For daemons */
72 * @fn int sysman_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
73 * @brief This API is used to get the file name of command line of the process from the proc fs.
74 * Caller process MUST allocate enough memory for the cmdline parameter. \n
75 * Its size should be assigned to cmdline_size. \n
76 * Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline.
77 * @param[in] pid pid of the process that you want to get the file name of command line
78 * @param[out] cmdline command line of the process that you want to get the file name <br>
79 * Callers should allocate memory to this parameter before calling this function.
80 * The allocated memory size must be large enough to store the file name.
81 * The result will include the terminating null byte('\0') at the end of the string.
82 * @return 0 on success, -1 if failed. If the size of cmdline is smaller than the result,
83 * it will return -1 and errno will be set as EOVERFLOW.
85 int sysman_get_cmdline_name(pid_t pid, char *cmdline,
89 * @fn char *sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size)
90 * @brief This API is used to get the execution path of the process specified by the pid parameter.\n
91 * Caller process MUST allocate enough memory for the app_path parameter. \n
92 * Its size should be assigned to app_path_size. \n
93 * Internally it reads a link of /proc/{pid}/exe and copies the path to app_path.
94 * @param[in] pid pid of the process that you want to get the executed path
95 * @param[out] app_path the executed file path of the process <br>
96 * Callers should allocate memory to this parameter before calling this function.
97 * The allocated memory size must be large enough to store the executed file path.
98 * The result will include the terminating null byte('\0') at the end of the string.
99 * @param[in] app_path_size allocated memory size of char *app_path
100 * @return 0 on success, -1 if failed. If the size of app_path is smaller than the result,
101 * it will return -1 and errno will be set as EOVERFLOW.
103 int sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size);
108 * @fn int sysconf_set_mempolicy(enum mem_policy mempol)
109 * @brief This API is used to set the policy of the caller process when the phone has low available memory.
110 * @param[in] mempol oom adjust value which you want to set
111 * @return 0 on success, -1 if failed.
112 * @see sysconf_set_mempolicy_bypid()
114 int sysconf_set_mempolicy(enum mem_policy mempol);
117 * @fn int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol)
118 * @brief This API is used to set the policy of the process when the phone has low available memory.
119 * @param[in] pid process id which you want to set
120 * @param[in] mempol oom adjust value which you want to set
121 * @return 0 on success, -1 if failed.
123 int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol);
126 * @fn int sysconf_set_permanent(void)
127 * @brief This API is used to set itself as a permanent process.\n
128 * If the permanent process is dead, system server will relaunch the process automatically.
129 * @return 0 on success, -1 if failed.
130 * @see sysconf_set_permanent_bypid()
134 * ret = sysconf_set_permanent();
136 * printf("Fail to set a process as permanent\n");
140 int sysconf_set_permanent(void);
143 * @fn int sysconf_set_permanent_bypid(pid_t pid)
144 * @brief This API is used to set a process which has pid as a permanent process.\n
145 * If the permanent process is dead, system server will relaunch the process automatically.
146 * @return 0 on success, -1 if failed.
147 * @see sysconf_set_permanent()
151 * ret = sysconf_set_permanent_bypid(pid);
153 * printf("Fail to set a process(%d) as permanent\n",pid);
157 int sysconf_set_permanent_bypid(pid_t pid);
160 * @fn int sysconf_set_vip(pid_t pid)
161 * @brief This API is used to set a process which has pid as Very Important Process(VIP) .\n
162 * If the VIP process is dead, restarter program will be run. \n
163 * Restarter program may kill almost processes and run rc.local scripts again.
164 * @param[in] pid process id to be vip
165 * @return 0 on success, -1 if failed.
166 * @see sysconf_is_vip
170 * ret = sysconf_set_vip(pid);
172 * printf("Fail to set a process(%d) as VIP\n",pid);
176 int sysconf_set_vip(pid_t pid);
179 * @fn int sysconf_is_vip(pid_t pid)
180 * @brief This API is used to verify that process which has pid is Very Important Process(VIP) or not.
181 * @param[in] pid process id to be vip
182 * @return 1 on success, 0 if failed.
183 * @see sysconf_set_vip
187 * ret = sysconf_is_vip(pid);
189 * printf("process(%d) is Very Important Process\n",pid);
193 int sysconf_is_vip(pid_t pid);
195 int sysman_set_timezone(char *tzpath_str);
197 int sysman_call_predef_action(const char *type, int num, ...);
199 int sysman_inform_foregrd(void);
200 int sysman_inform_backgrd(void);
201 int sysman_inform_active(pid_t pid);
202 int sysman_inform_inactive(pid_t pid);
204 int sysman_request_poweroff(void);
205 int sysman_request_entersleep(void);
206 int sysman_request_leavesleep(void);
207 int sysman_request_reboot(void);
209 struct mmc_contents {
210 void (*mmc_cb) (int result, void* data);
214 int sysman_request_mount_mmc(struct mmc_contents *mmc_data);
215 int sysman_request_unmount_mmc(struct mmc_contents *mmc_data, int option);
216 int sysman_request_format_mmc(struct mmc_contents *mmc_data);
218 int sysman_request_set_cpu_max_frequency(int val);
219 int sysman_request_set_cpu_min_frequency(int val);
221 int sysman_release_cpu_max_frequency(void);
222 int sysman_release_cpu_min_frequency(void);
231 #endif /* ___SYSMAN___ */