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 * @remarks The original cpu schedule configuration of the target process is backed up if it is currently not boosted. \n
36 * @param[in] pid The target process pid/tids \n
37 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
38 * and cpu boosting is applied for all the threads of pid.pid. \n
39 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
40 * If pid.pid is zero and pid.tid is NULL, tid of the calling thread is used. \n
41 * The caller must (de)allocate the buffer in the pid.tid pointer.
42 * @param[in] level The cpu boosting level
43 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply boosting permanently
45 * @return 0 on success, otherwise a negative error value.
47 int resource_set_cpu_boosting (resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec);
50 * @brief Clear cpu boosting for the target process (pid/tids).
52 * @remarks The backed-up cpu schedule configuration of the target process is restored. \n
53 * Without the backed-up configuration, the default non-boosting configuration (SCHED_OTHER and nice=0) is applied. \n
54 * @param[in] pid The target process pid/tids \n
55 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
56 * and cpu boosting is cleared for all the threads of pid.pid. \n
57 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
58 * If pid.pid is zero and pid.tid is NULL, tid of the calling thread is used. \n
59 * The caller must (de)allocate the buffer in the pid.tid pointer.
61 * @return 0 on success, otherwise a negative error value.
63 int resource_clear_cpu_boosting (resource_pid_t pid);
66 * @brief Get the cpu boosting level for the target process (pid/tids).
68 * @param[in] pid The target process pid/tids \n
69 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored, \n
70 * and all the threads of pid.pid are checked. \n
71 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are checked. \n
72 * If pid.pid is zero and pid.tid is NULL, the calling thread is checked. \n
73 * The caller must (de)allocate the buffer in the pid.tid pointer.
74 * @param[out] level The boosting level for the target process (pid/tids) \n
75 * The level->tid_level array will be filled with cpu_boosting_level_e for tids requested by the pid argument. \n
76 * The caller must (de)allocate the buffer in the level.tid_level pointer.
78 * @return 0 on success, otherwise a negative error value.
80 int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info_t *level);
83 * @brief Set cpu resource inheritance from the source tid to the destination process (pid/tids).
85 * @param[in] source_tid The caller thread tid
86 * @param[in] dest_process The name of destination process
87 * @param[in] timeout_msec The timeout in milliseconds, -1 to apply inheritance permanently
89 * @return 0 on success, otherwise a negative error value.
91 int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec);
94 * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
96 * @param[in] source_tid The caller thread's tid
97 * @param[in] dest_process The name of destination process
99 * @return 0 on success, otherwise a negative error value.
101 int resource_clear_cpu_inheritance (int source_tid, const char *dest_process);
104 * @brief Register a destination process (pid/tids) for cpu resource inheritance.
106 * @param[in] dest_process The name of destination process
107 * @param[in] pid The destination process pid/tids \n
108 * If pid.pid is nonzero, pid.tid and pid.tid_count are ignored. \n
109 * and all the threads of pid.pid are registered. \n
110 * If pid.pid is zero and pid.tid is not NULL, all tids in the list are used \n
111 * If pid.pid is zero and pid.tid is NULL, pid of the calling thread is used. \n
112 * The caller must (de)allocate the buffer in the pid.tid pointer.
114 * @return 0 on success, otherwise a negative error value.
116 int resource_register_cpu_inheritance_destination (const char *dest_process, resource_pid_t pid);
119 * @brief Unregister a destination process for cpu resource inheritance.
121 * @param[in] dest_process The name of destination process
123 * @return 0 on success, otherwise a negative error value.
125 int resource_unregister_cpu_inheritance_destination (const char *dest_process);
132 #endif // __TIZEN_SYSTEM_CPU_BOOSTING_H__