3 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is furnished
10 * to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 #ifndef __TIZEN_SYSTEM_CPU_BOOSTING_H__
24 #define __TIZEN_SYSTEM_CPU_BOOSTING_H__
26 #include "cpu-boosting-type.h"
33 * @brief Set cpu boosting for the target process (pid/tids).
35 * @param[in] pid The target process pid/tids \n
36 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored. \n
37 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
38 * If pid.pid is zero and pid.tid is NULL, pid of the calling thread is used. \n
39 * The caller must (de)allocate the buffer in the pid.tid pointer.
40 * @param[in] level The cpu boosting level
41 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply boosting permanently
43 * @return 0 on success, otherwise a negative error value.
45 int resource_set_cpu_boosting (resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec);
48 * @brief Clear cpu boosting for the target process (pid/tids).
50 * @param[in] pid The target process pid/tids \n
51 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored. \n
52 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
53 * If pid.pid is zero and pid.tid is NULL, pid of the calling thread is used. \n
54 * The caller must (de)allocate the buffer in the pid.tid pointer.
56 * @return 0 on success, otherwise a negative error value.
58 int resource_clear_cpu_boosting (resource_pid_t pid);
61 * @brief Get the cpu boosting level for the target process (pid/tids).
63 * @param[in] pid The target process pid/tids \n
64 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored. \n
65 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
66 * If pid.pid is zero and pid.tid is NULL, pid of the calling thread is used. \n
67 * The caller must (de)allocate the buffer in the pid.tid pointer.
68 * @param[out] level The boosting level for the target process (pid/tids) \n
69 * The level argument will be filled with the level value corresponding to the pid argument. \n
70 * The caller must (de)allocate the buffer in the level.tid_level pointer.
72 * @return 0 on success, otherwise a negative error value.
74 int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info_t *level);
77 * @brief Set cpu resource inheritance from the source tid to the destination process (pid/tids).
79 * @param[in] source_tid The caller thread tid
80 * @param[in] dest_process The name of destination process
81 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply inheritance permanently
83 * @return 0 on success, otherwise a negative error value.
85 int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec);
88 * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
90 * @param[in] source_tid The caller thread's tid
91 * @param[in] dest_process The name of destination process
93 * @return 0 on success, otherwise a negative error value.
95 int resource_clear_cpu_inheritance (int source_tid, const char *dest_process);
98 * @brief Register a destination process (pid/tids) for cpu resource inheritance.
100 * @param[in] dest_process The name of destination process
101 * @param[in] pid The destination process pid/tids \n
102 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored. \n
103 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
104 * If pid.pid is zero and pid.tid is NULL, pid of the calling thread is used. \n
105 * The caller must (de)allocate the buffer in the pid.tid pointer.
107 * @return 0 on success, otherwise a negative error value.
109 int resource_register_cpu_inheritance_destination (const char *dest_process, resource_pid_t pid);
112 * @brief Unregister a destination process for cpu resource inheritance.
114 * @param[in] dest_process The name of destination process
116 * @return 0 on success, otherwise a negative error value.
118 int resource_unregister_cpu_inheritance_destination (const char *dest_process);
125 #endif // __TIZEN_SYSTEM_CPU_BOOSTING_H__