1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef QOS_H
17 #define QOS_H
18 /**
19  * @addtogroup QoS
20  * @{
21  *
22  * @brief QoS provides APIs.
23  *
24  * @since 12
25  */
26 
27 /**
28  * @file qos.h
29  *
30  * @brief Declares the QoS interfaces in C.
31  *
32  * Quality-of-service (QoS) refers to the priority scheduling attribute of tasks
33  * in OpenHarmony. Developers can use QoS to categorize tasks to be executed to
34  * indicate the degree of their relevance to user interactions, the system can
35  * schedule the time and running order of tasks according to the QoS set by the tasks.
36  *
37  * @library libqos.so
38  * @syscap SystemCapability.Resourceschedule.QoS.Core
39  * @since 12
40  */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Describes the level of QoS.
47  *
48  * @since 12
49  */
50 typedef enum QoS_Level {
51     /**
52      * @brief Means the QoS level is background.
53      */
54     QOS_BACKGROUND = 0,
55 
56     /**
57      * @brief Means the QoS level is utility.
58      */
59     QOS_UTILITY,
60 
61     /**
62      * @brief Means the QoS level is default.
63      */
64     QOS_DEFAULT,
65 
66     /**
67      * @brief Means the QoS level is user-initiated.
68      */
69     QOS_USER_INITIATED,
70 
71     /**
72      * @brief Means the QoS level is user-request.
73      */
74     QOS_DEADLINE_REQUEST,
75 
76     /**
77      * @brief Means the QoS level is user-interactive.
78      */
79     QOS_USER_INTERACTIVE,
80 } QoS_Level;
81 
82 /**
83  * @brief Set the QoS level of the current thread.
84  *
85  * @param level Indicates the level to set. Specific level can be referenced {@link QoS_Level}.
86  * @return Returns 0 if the operation is successful; returns -1 if level is out of range or
87  *         internal error failed.
88  * @see QoS_Level
89  * @since 12
90  */
91 int OH_QoS_SetThreadQoS(QoS_Level level);
92 
93 /**
94  * @brief Cancel the QoS level of the current thread.
95  *
96  * @return Returns 0 if the operation is successful; returns -1 if not set QoS for current thread
97  *        or internal error failed.
98  * @see QoS_Level
99  * @since 12
100  */
101 int OH_QoS_ResetThreadQoS();
102 
103 /**
104  * @brief Obtains the QoS level of the current thread.
105  *
106  * @param level This parameter is the output parameter,
107  * and the QoS level of the thread as a {@link QoS_Level} is written to this variable.
108  * @return Returns 0 if the operation is successful; returns -1 if level is null, not
109  *         set QoS for current thread or internal error failed.
110  * @see QoS_Level
111  * @since 12
112  */
113 int OH_QoS_GetThreadQoS(QoS_Level *level);
114 #ifdef __cplusplus
115 };
116 #endif
117 #endif //QOS_H
118