ad6aa37e9e4fa6f3d304fa3a5b9fdb6d3450fec7
[platform/core/api/resource.git] / include / cpu-boosting.h
1 /* MIT License
2  *
3  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4  *
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:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
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
21  * THE SOFTWARE. */
22
23 #ifndef __TIZEN_SYSTEM_CPU_BOOSTING_H__
24 #define __TIZEN_SYSTEM_CPU_BOOSTING_H__
25
26 #include "cpu-boosting-type.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * @brief Set cpu boosting for the target process (pid/tids).
34  *
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
42  *
43  * @return 0 on success, otherwise a negative error value.
44  */
45 int resource_set_cpu_boosting (resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec);
46
47 /**
48  * @brief Clear cpu boosting for the target process (pid/tids).
49  *
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.
55  *
56  * @return 0 on success, otherwise a negative error value.
57  */
58 int resource_clear_cpu_boosting (resource_pid_t pid);
59
60 /**
61  * @brief Get the cpu boosting level for the target process (pid/tids).
62  *
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.
71  *
72  * @return 0 on success, otherwise a negative error value.
73  */
74 int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info_t *level);
75
76 /**
77  * @brief Set cpu resource inheritance from the source tid to the destination process (pid/tids).
78  *
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
82  *
83  * @return 0 on success, otherwise a negative error value.
84  */
85 int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec);
86
87 /**
88  * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
89  *
90  * @param[in] source_tid The caller thread's tid
91  * @param[in] dest_process The name of destination process
92  *
93  * @return 0 on success, otherwise a negative error value.
94  */
95 int resource_clear_cpu_inheritance (int source_tid, const char *dest_process);
96
97 /**
98  * @brief Register a destination process (pid/tids) for cpu resource inheritance.
99  *
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.
106  *
107  * @return 0 on success, otherwise a negative error value.
108  */
109 int resource_register_cpu_inheritance_destination (const char *dest_process, resource_pid_t pid);
110
111 /**
112  * @brief Unregister a destination process for cpu resource inheritance.
113  *
114  * @param[in] dest_process The name of destination process
115  *
116  * @return 0 on success, otherwise a negative error value.
117  */
118 int resource_unregister_cpu_inheritance_destination (const char *dest_process);
119
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif  // __TIZEN_SYSTEM_CPU_BOOSTING_H__