1 /* 2 * Copyright (c) 2023 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 FFRT_INNER_API_C_TASK_H 17 #define FFRT_INNER_API_C_TASK_H 18 #include <stdint.h> 19 #include <stdbool.h> 20 #include "type_def_ext.h" 21 22 /** 23 * @brief Skips a task. 24 * 25 * @param handle Indicates a task handle. 26 * @return Returns <b>0</b> if the task is skipped; 27 returns <b>-1</b> otherwise. 28 * @since 10 29 * @version 1.0 30 */ 31 FFRT_C_API int ffrt_skip(ffrt_task_handle_t handle); 32 33 // config 34 FFRT_C_API int ffrt_set_cgroup_attr(ffrt_qos_t qos, ffrt_os_sched_attr* attr); 35 FFRT_C_API void ffrt_restore_qos_config(void); 36 37 /** 38 * @brief worker num setting. 39 * 40 * @param qosData param is default when value equal 0xffffffff. 41 * totalNum = lowQosReserveWorkerNum + highQosReserveWorkerNum + sum of all reserveNum 42 * totalNum is valid in (0,256]. 43 * lowQosReserveWorkerNum is a low partition qos public resource.{[min, max], default} is {[0,256],12}. 44 * highQosReserveWorkerNum is a hight partition qos public resource.{[min, max], default} is {[0,256],12}. 45 * lowQosReserveWorkerNum is a global qos public resource.{[min, max], default} is {[0,256],24}. 46 * qosConfigArray is an array of ffrt_qos_config. 47 * effectLen: param setting will success when qosConfigArray index less than effectLen. 48 * qos valid in [0,5]. 49 * reserveNum: mininum number which qos can create worker.{[min, max], default} is {[0,256],8}. 50 * maxConcurrency is amx concurrency num of the qos.{[min, max], default} is {[0,12],8}. 51 * hardLimit: max number which qos can create worker.{[min, max], default} is {[0,256],44}. 52 * @return return ture when setting success.return false when setting fail, and param is default. 53 * @version 1.0 54 */ 55 FFRT_C_API int ffrt_set_qos_worker_num(ffrt_worker_num_param* qosData); 56 57 /** 58 * @brief Set the task execution timeout. 59 * 60 * @param attr Indicates a pointer to the task attribute. 61 * @param timeout_ms task execution timeout. 62 * @version 1.0 63 */ 64 FFRT_C_API void ffrt_task_attr_set_timeout(ffrt_task_attr_t* attr, uint64_t timeout_ms); 65 66 /** 67 * @brief Get the task execution timeout. 68 * 69 * @param attr Indicates a pointer to the task attribute. 70 * @return Returns the task execution timeout. 71 * @version 1.0 72 */ 73 FFRT_C_API uint64_t ffrt_task_attr_get_timeout(const ffrt_task_attr_t* attr); 74 75 /** 76 * @brief Sets whether the task notifies worker, only support for normal task. 77 * 78 * @param attr Indicates a pointer to the task attribute. 79 * @param notify Indicates whether the task notifies worker. 80 * @version 1.0 81 */ 82 FFRT_C_API void ffrt_task_attr_set_notify_worker(ffrt_task_attr_t* attr, bool notify); 83 84 /** 85 * @brief Notifies a specified number of workers at a specified QoS level. 86 * 87 * @param qos Indicates the QoS. 88 * @param number Indicates the number of workers to be notified. 89 * @version 1.0 90 */ 91 FFRT_C_API void ffrt_notify_workers(ffrt_qos_t qos, int number); 92 93 /** 94 * @brief Obtains the ID of this queue. 95 * 96 * @return Returns the queue ID. 97 * @version 1.0 98 */ 99 FFRT_C_API int64_t ffrt_this_queue_get_id(void); 100 #endif 101