diff --git a/resourceschedule/qos_manager/BUILD.gn b/resourceschedule/qos_manager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4ee07328187de2d088afa231c7d4dec0f8c1e0c1 --- /dev/null +++ b/resourceschedule/qos_manager/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("qos_header") { + dest_dir = "$ndk_headers_out_dir/qos" + sources = [ "./c/qos.h" ] +} + +ohos_ndk_library("libqos_ndk") { + output_name = "qos" + output_extension = "so" + ndk_description_file = "./libqos.ndk.json" + system_capability = "SystemCapability.Resourceschedule.QoS.Core" + system_capability_headers = [ "qos/qos.h" ] +} diff --git a/resourceschedule/qos_manager/c/qos.h b/resourceschedule/qos_manager/c/qos.h new file mode 100644 index 0000000000000000000000000000000000000000..c92ab5b8622578b0b086fb042b15bda961c48c97 --- /dev/null +++ b/resourceschedule/qos_manager/c/qos.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef QOS_H +#define QOS_H +/** + * @addtogroup QoS + * @{ + * + * @brief QoS provides APIs. + * + * @since 12 + */ + +/** + * @file qos.h + * + * @brief Declares the QoS interfaces in C. + * + * Quality-of-service (QoS) refers to the priority scheduling attribute of tasks + * in OpenHarmony. Developers can use QoS to categorize tasks to be executed to + * indicate the degree of their relevance to user interactions, the system can + * schedule the time and running order of tasks according to the QoS set by the tasks. + * + * @library libqos.so + * @syscap SystemCapability.Resourceschedule.QoS.Core + * @since 12 + */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Describes the level of QoS. + * + * @since 12 + */ +typedef enum QoS_Level { + /** + * @brief Means the QoS level is background. + */ + QOS_BACKGROUND = 0, + + /** + * @brief Means the QoS level is utility. + */ + QOS_UTILITY, + + /** + * @brief Means the QoS level is default. + */ + QOS_DEFAULT, + + /** + * @brief Means the QoS level is user-initiated. + */ + QOS_USER_INITIATED, + + /** + * @brief Means the QoS level is user-request. + */ + QOS_DEADLINE_REQUEST, + + /** + * @brief Means the QoS level is user-interactive. + */ + QOS_USER_INTERACTIVE, +} QoS_Level; + +/** + * @brief Set the QoS level of the current thread. + * + * @param level Indicates the level to set. Specific level can be referenced {@link QoS_Level}. + * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed. + * @see QoS_Level + * @since 12 + */ +int OH_QoS_SetThreadQoS(QoS_Level level); + +/** + * @brief Cancel the QoS level of the current thread. + * + * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed. + * @see QoS_Level + * @since 12 + */ +int OH_QoS_ResetThreadQoS(); + +/** + * @brief Obtains the QoS level of the current thread. + * + * @param level This parameter is the output parameter, + * and the QoS level of the thread as a {@link QoS_Level} is written to this variable. + * @return Returns int32_t, return value == 0, success, otherwise value == -1, failed. + * @see QoS_Level + * @since 12 + */ +int OH_QoS_GetThreadQoS(QoS_Level *level); +#ifdef __cplusplus +}; +#endif +#endif //QOS_H diff --git a/resourceschedule/qos_manager/libqos.ndk.json b/resourceschedule/qos_manager/libqos.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..6c21f98392fa5e1206ed70bd5a6c47e075e6aa6a --- /dev/null +++ b/resourceschedule/qos_manager/libqos.ndk.json @@ -0,0 +1,14 @@ +[ + { + "first_introduced": "12", + "name": "OH_QoS_SetThreadQoS" + }, + { + "first_introduced": "12", + "name": "OH_QoS_ResetThreadQoS" + }, + { + "first_introduced": "12", + "name": "OH_QoS_GetThreadQoS" + } +] \ No newline at end of file