1484543d1Sopenharmony_ci/* 2484543d1Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3484543d1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4484543d1Sopenharmony_ci * you may not use this file except in compliance with the License. 5484543d1Sopenharmony_ci * You may obtain a copy of the License at 6484543d1Sopenharmony_ci * 7484543d1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8484543d1Sopenharmony_ci * 9484543d1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10484543d1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11484543d1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12484543d1Sopenharmony_ci * See the License for the specific language governing permissions and 13484543d1Sopenharmony_ci * limitations under the License. 14484543d1Sopenharmony_ci */ 15484543d1Sopenharmony_ci 16484543d1Sopenharmony_ci#ifndef FFRT_INNER_API_C_TASK_H 17484543d1Sopenharmony_ci#define FFRT_INNER_API_C_TASK_H 18484543d1Sopenharmony_ci#include <stdint.h> 19484543d1Sopenharmony_ci#include <stdbool.h> 20484543d1Sopenharmony_ci#include "type_def_ext.h" 21484543d1Sopenharmony_ci 22484543d1Sopenharmony_ci/** 23484543d1Sopenharmony_ci * @brief Skips a task. 24484543d1Sopenharmony_ci * 25484543d1Sopenharmony_ci * @param handle Indicates a task handle. 26484543d1Sopenharmony_ci * @return Returns <b>0</b> if the task is skipped; 27484543d1Sopenharmony_ci returns <b>-1</b> otherwise. 28484543d1Sopenharmony_ci * @since 10 29484543d1Sopenharmony_ci * @version 1.0 30484543d1Sopenharmony_ci */ 31484543d1Sopenharmony_ciFFRT_C_API int ffrt_skip(ffrt_task_handle_t handle); 32484543d1Sopenharmony_ci 33484543d1Sopenharmony_ci// config 34484543d1Sopenharmony_ciFFRT_C_API int ffrt_set_cgroup_attr(ffrt_qos_t qos, ffrt_os_sched_attr* attr); 35484543d1Sopenharmony_ciFFRT_C_API void ffrt_restore_qos_config(void); 36484543d1Sopenharmony_ci 37484543d1Sopenharmony_ci/** 38484543d1Sopenharmony_ci * @brief worker num setting. 39484543d1Sopenharmony_ci * 40484543d1Sopenharmony_ci * @param qosData param is default when value equal 0xffffffff. 41484543d1Sopenharmony_ci * totalNum = lowQosReserveWorkerNum + highQosReserveWorkerNum + sum of all reserveNum 42484543d1Sopenharmony_ci * totalNum is valid in (0,256]. 43484543d1Sopenharmony_ci * lowQosReserveWorkerNum is a low partition qos public resource.{[min, max], default} is {[0,256],12}. 44484543d1Sopenharmony_ci * highQosReserveWorkerNum is a hight partition qos public resource.{[min, max], default} is {[0,256],12}. 45484543d1Sopenharmony_ci * lowQosReserveWorkerNum is a global qos public resource.{[min, max], default} is {[0,256],24}. 46484543d1Sopenharmony_ci * qosConfigArray is an array of ffrt_qos_config. 47484543d1Sopenharmony_ci * effectLen: param setting will success when qosConfigArray index less than effectLen. 48484543d1Sopenharmony_ci * qos valid in [0,5]. 49484543d1Sopenharmony_ci * reserveNum: mininum number which qos can create worker.{[min, max], default} is {[0,256],8}. 50484543d1Sopenharmony_ci * maxConcurrency is amx concurrency num of the qos.{[min, max], default} is {[0,12],8}. 51484543d1Sopenharmony_ci * hardLimit: max number which qos can create worker.{[min, max], default} is {[0,256],44}. 52484543d1Sopenharmony_ci * @return return ture when setting success.return false when setting fail, and param is default. 53484543d1Sopenharmony_ci * @version 1.0 54484543d1Sopenharmony_ci */ 55484543d1Sopenharmony_ciFFRT_C_API int ffrt_set_qos_worker_num(ffrt_worker_num_param* qosData); 56484543d1Sopenharmony_ci 57484543d1Sopenharmony_ci/** 58484543d1Sopenharmony_ci * @brief Set the task execution timeout. 59484543d1Sopenharmony_ci * 60484543d1Sopenharmony_ci * @param attr Indicates a pointer to the task attribute. 61484543d1Sopenharmony_ci * @param timeout_ms task execution timeout. 62484543d1Sopenharmony_ci * @version 1.0 63484543d1Sopenharmony_ci */ 64484543d1Sopenharmony_ciFFRT_C_API void ffrt_task_attr_set_timeout(ffrt_task_attr_t* attr, uint64_t timeout_ms); 65484543d1Sopenharmony_ci 66484543d1Sopenharmony_ci/** 67484543d1Sopenharmony_ci * @brief Get the task execution timeout. 68484543d1Sopenharmony_ci * 69484543d1Sopenharmony_ci * @param attr Indicates a pointer to the task attribute. 70484543d1Sopenharmony_ci * @return Returns the task execution timeout. 71484543d1Sopenharmony_ci * @version 1.0 72484543d1Sopenharmony_ci */ 73484543d1Sopenharmony_ciFFRT_C_API uint64_t ffrt_task_attr_get_timeout(const ffrt_task_attr_t* attr); 74484543d1Sopenharmony_ci 75484543d1Sopenharmony_ci/** 76484543d1Sopenharmony_ci * @brief Sets whether the task notifies worker, only support for normal task. 77484543d1Sopenharmony_ci * 78484543d1Sopenharmony_ci * @param attr Indicates a pointer to the task attribute. 79484543d1Sopenharmony_ci * @param notify Indicates whether the task notifies worker. 80484543d1Sopenharmony_ci * @version 1.0 81484543d1Sopenharmony_ci */ 82484543d1Sopenharmony_ciFFRT_C_API void ffrt_task_attr_set_notify_worker(ffrt_task_attr_t* attr, bool notify); 83484543d1Sopenharmony_ci 84484543d1Sopenharmony_ci/** 85484543d1Sopenharmony_ci * @brief Notifies a specified number of workers at a specified QoS level. 86484543d1Sopenharmony_ci * 87484543d1Sopenharmony_ci * @param qos Indicates the QoS. 88484543d1Sopenharmony_ci * @param number Indicates the number of workers to be notified. 89484543d1Sopenharmony_ci * @version 1.0 90484543d1Sopenharmony_ci */ 91484543d1Sopenharmony_ciFFRT_C_API void ffrt_notify_workers(ffrt_qos_t qos, int number); 92484543d1Sopenharmony_ci 93484543d1Sopenharmony_ci/** 94484543d1Sopenharmony_ci * @brief Obtains the ID of this queue. 95484543d1Sopenharmony_ci * 96484543d1Sopenharmony_ci * @return Returns the queue ID. 97484543d1Sopenharmony_ci * @version 1.0 98484543d1Sopenharmony_ci */ 99484543d1Sopenharmony_ciFFRT_C_API int64_t ffrt_this_queue_get_id(void); 100484543d1Sopenharmony_ci#endif 101