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 GLOBAL_CONFIG_H 17484543d1Sopenharmony_ci#define GLOBAL_CONFIG_H 18484543d1Sopenharmony_ci 19484543d1Sopenharmony_ci#include "qos.h" 20484543d1Sopenharmony_ci#include "types.h" 21484543d1Sopenharmony_ci 22484543d1Sopenharmony_cinamespace ffrt { 23484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_GLOBAL_HARDLIMIT = 96; 24484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_PARAMS_VALUE = 0Xffffffff; 25484543d1Sopenharmony_ci 26484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_MAXCONCURRENCY = 8; 27484543d1Sopenharmony_ciconstexpr unsigned int MAX_MAXCONCURRENCY = 12; 28484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_HARDLIMIT = 44; 29484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_SINGLE_NUM = 8; 30484543d1Sopenharmony_ci 31484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_GLOBAL_RESERVE_NUM = 24; 32484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_LOW_RESERVE_NUM = 12; 33484543d1Sopenharmony_ciconstexpr unsigned int DEFAULT_HIGH_RESERVE_NUM = 12; 34484543d1Sopenharmony_ciconstexpr unsigned int GLOBAL_QOS_MAXNUM = 256; 35484543d1Sopenharmony_ci 36484543d1Sopenharmony_ciclass QosWorkerConfig { 37484543d1Sopenharmony_cipublic: 38484543d1Sopenharmony_ci struct FfrtQosWorkerNumCfg { 39484543d1Sopenharmony_ci unsigned int hardLimit = DEFAULT_HARDLIMIT; 40484543d1Sopenharmony_ci unsigned int maxConcurrency = DEFAULT_MAXCONCURRENCY; 41484543d1Sopenharmony_ci unsigned int reserveNum = DEFAULT_SINGLE_NUM; 42484543d1Sopenharmony_ci }; 43484543d1Sopenharmony_ci 44484543d1Sopenharmony_ci QosWorkerConfig(int workerNum) 45484543d1Sopenharmony_ci { 46484543d1Sopenharmony_ci mQosWorkerCfg.resize(workerNum); 47484543d1Sopenharmony_ci } 48484543d1Sopenharmony_ci QosWorkerConfig(const QosWorkerConfig&) = delete; 49484543d1Sopenharmony_ci QosWorkerConfig& operator=(const QosWorkerConfig&) = delete; 50484543d1Sopenharmony_ci ~QosWorkerConfig() {} 51484543d1Sopenharmony_ci 52484543d1Sopenharmony_ci unsigned int GetGlobalMaxWorkerNum() const 53484543d1Sopenharmony_ci { 54484543d1Sopenharmony_ci unsigned int ret = 0; 55484543d1Sopenharmony_ci ret += mLowQosReserveWorkerNum; 56484543d1Sopenharmony_ci ret += mHighQosReserveWorkerNum; 57484543d1Sopenharmony_ci ret += mGlobalReserveWorkerNum; 58484543d1Sopenharmony_ci for (const auto &tmpStru : mQosWorkerCfg) { 59484543d1Sopenharmony_ci ret += tmpStru.reserveNum; 60484543d1Sopenharmony_ci } 61484543d1Sopenharmony_ci return ret; 62484543d1Sopenharmony_ci } 63484543d1Sopenharmony_ci 64484543d1Sopenharmony_ci std::vector<FfrtQosWorkerNumCfg> mQosWorkerCfg; 65484543d1Sopenharmony_ci unsigned int mLowQosReserveWorkerNum = DEFAULT_LOW_RESERVE_NUM; 66484543d1Sopenharmony_ci unsigned int mHighQosReserveWorkerNum = DEFAULT_HIGH_RESERVE_NUM; 67484543d1Sopenharmony_ci unsigned int mGlobalReserveWorkerNum = DEFAULT_GLOBAL_RESERVE_NUM; 68484543d1Sopenharmony_ci}; 69484543d1Sopenharmony_ci} 70484543d1Sopenharmony_ci 71484543d1Sopenharmony_ci#endif /* GLOBAL_CONFIG_H */ 72