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 * @details The original cpu schedule configuration of the target process is backed up if it is currently not boosted.
38 * @privilege http://tizen.org/privilege/internal/default/partner
40 * @param[in] pid The target process pid/tids \n
41 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
42 * and cpu boosting is applied for all the threads of pid.pid. \n
43 * If pid.pid is zero and pid.tid is not NULL, all tids in pid.tid are used. \n
44 * If pid.pid is zero and pid.tid is NULL, tid of the calling thread is used. \n
45 * The caller must (de)allocate the buffer in the pid.tid pointer.
46 * @param[in] level The cpu boosting level
47 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply boosting permanently
49 * @return 0 on success, otherwise a negative error value.
51 int resource_set_cpu_boosting (resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec);
54 * @brief Clear cpu boosting for the target process (pid/tids).
56 * @details The backed-up cpu schedule configuration of the target process is restored. \n
57 * Without the backed-up configuration, the default non-boosting configuration (SCHED_OTHER and nice=0) is applied. \n
60 * @privilege http://tizen.org/privilege/internal/default/partner
62 * @param[in] pid The target process pid/tids \n
63 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
64 * and cpu boosting is cleared for all the threads of pid.pid. \n
65 * If pid.pid is zero and pid.tid is not NULL, all tids in pid.tid are used. \n
66 * If pid.pid is zero and pid.tid is NULL, tid of the calling thread is used. \n
67 * The caller must (de)allocate the buffer in the pid.tid pointer.
69 * @return 0 on success, otherwise a negative error value.
71 int resource_clear_cpu_boosting (resource_pid_t pid);
74 * @brief Get the cpu boosting level for the target process (pid/tids).
76 * @param[in] pid The target process pid/tids \n
77 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
78 * and all the threads of pid.pid are checked. \n
79 * If pid.pid is zero and pid.tid is not NULL, all tids in pid.tid are checked. \n
80 * If pid.pid is zero and pid.tid is NULL, the calling thread is checked. \n
81 * The caller must (de)allocate the buffer in the pid.tid pointer.
82 * @param[out] level The boosting level for the target process (pid/tids) \n
83 * level->tid_level will be allocated and filled with cpu_boosting_level_e for tids requested by the pid argument. \n
84 * The caller must deallocate the buffer in the level->tid_level pointer after using it.
86 * @return 0 on success, otherwise a negative error value.
88 int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info_t *level);
91 * @brief Set cpu resource inheritance from the source tid to the destination process (pid/tids).
94 * @privilege http://tizen.org/privilege/internal/default/partner
96 * @param[in] source_tid The caller thread tid
97 * @param[in] dest_process The name of destination process
98 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply inheritance permanently
100 * @return 0 on success, otherwise a negative error value.
102 int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec);
105 * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
108 * @privilege http://tizen.org/privilege/internal/default/partner
110 * @param[in] source_tid The caller thread's tid
111 * @param[in] dest_process The name of destination process
113 * @return 0 on success, otherwise a negative error value.
115 int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process);
118 * @brief Register a destination process (pid/tids) for cpu resource inheritance.
121 * @privilege http://tizen.org/privilege/internal/default/partner
123 * @param[in] dest_process The name of destination process
124 * @param[in] pid The destination process pid/tids \n
125 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
126 * and all the threads of pid.pid are registered. \n
127 * If pid.pid is zero and pid.tid is not NULL, all tids in pid.tid are registered. \n
128 * If pid.pid is zero and pid.tid is NULL, tid of the calling thread is registered. \n
129 * The caller must (de)allocate the buffer in the pid.tid pointer.
131 * @return 0 on success, otherwise a negative error value.
133 int resource_register_cpu_inheritance_destination (const char *dest_process, resource_pid_t pid);
136 * @brief Unregister a destination process for cpu resource inheritance.
139 * @privilege http://tizen.org/privilege/internal/default/partner
141 * @param[in] dest_process The name of destination process
143 * @return 0 on success, otherwise a negative error value.
145 int resource_unregister_cpu_inheritance_destination (const char *dest_process);
152 #endif // __TIZEN_SYSTEM_CPU_BOOSTING_H__