• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup QoS
18  * @{
19  *
20  * @brief QoS provides APIs.
21  *
22  * @since 12
23  */
24 
25 /**
26  * @file qos.h
27  *
28  * @brief Declares the QoS interfaces in C.
29  *
30  * Quality-of-service (QoS) refers to the priority scheduling attribute of tasks
31  * in OpenHarmony. Developers can use QoS to categorize tasks to be executed to
32  * indicate the degree of their relevance to user interactions, the system can
33  * schedule the time and running order of tasks according to the QoS set by the tasks.
34  *
35  * @library libqos.so
36  * @kit KernelEnhanceKit
37  * @syscap SystemCapability.Resourceschedule.QoS.Core
38  * @since 12
39  */
40 
41 #ifndef QOS_H
42 #define QOS_H
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Describes the level of QoS.
50  *
51  * @since 12
52  */
53 typedef enum QoS_Level {
54     /**
55      * @brief Means the QoS level is background.
56      */
57     QOS_BACKGROUND = 0,
58 
59     /**
60      * @brief Means the QoS level is utility.
61      */
62     QOS_UTILITY,
63 
64     /**
65      * @brief Means the QoS level is default.
66      */
67     QOS_DEFAULT,
68 
69     /**
70      * @brief Means the QoS level is user-initiated.
71      */
72     QOS_USER_INITIATED,
73 
74     /**
75      * @brief Means the QoS level is user-request.
76      */
77     QOS_DEADLINE_REQUEST,
78 
79     /**
80      * @brief Means the QoS level is user-interactive.
81      */
82     QOS_USER_INTERACTIVE,
83 } QoS_Level;
84 
85 /**
86  * @brief Set the QoS level of the current thread.
87  *
88  * @param level Indicates the level to set. Specific level can be referenced {@link QoS_Level}.
89  * @return Returns 0 if the operation is successful; returns -1 if level is out of range or
90  *         internal error failed.
91  * @see QoS_Level
92  * @since 12
93  */
94 int OH_QoS_SetThreadQoS(QoS_Level level);
95 
96 /**
97  * @brief Cancel the QoS level of the current thread.
98  *
99  * @return Returns 0 if the operation is successful; returns -1 if not set QoS for current thread
100  *        or internal error failed.
101  * @see QoS_Level
102  * @since 12
103  */
104 int OH_QoS_ResetThreadQoS();
105 
106 /**
107  * @brief Obtains the QoS level of the current thread.
108  *
109  * @param level This parameter is the output parameter,
110  * and the QoS level of the thread as a {@link QoS_Level} is written to this variable.
111  * @return Returns 0 if the operation is successful; returns -1 if level is null, not
112  *         set QoS for current thread or internal error failed.
113  * @see QoS_Level
114  * @since 12
115  */
116 int OH_QoS_GetThreadQoS(QoS_Level *level);
117 #ifdef __cplusplus
118 };
119 #endif
120 #endif // QOS_H
121 /** @} */
122