• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "qos_config.h"
17 
18 namespace ffrt {
19 
20 constexpr uint8_t THREAD_AFFINITY_LIT     = 0x0F;
21 constexpr uint8_t THREAD_AFFINITY_MID     = 0x70;
22 constexpr uint8_t THREAD_AFFINITY_BIG     = 0x80;
23 constexpr uint8_t THREAD_AFFINITY_LIT_MID = 0x7F;
24 constexpr uint8_t THREAD_AFFINITY_LIT_BIG = 0x8F;
25 constexpr uint8_t THREAD_AFFINITY_MID_BIG = 0xF0;
26 constexpr uint8_t THREAD_AFFINITY_ALL     = 0xFF;
27 
28 constexpr uint8_t THREAD_PRIO_NORMAL_MIN         = 139;
29 constexpr uint8_t THREAD_PRIO_NORMAL_BACKGROUND  = 130;
30 constexpr uint8_t THREAD_PRIO_NORMAL_UNFAVORABLE = 125;
31 constexpr uint8_t THREAD_PRIO_NORMAL_DEFAULT     = 120;
32 constexpr uint8_t THREAD_PRIO_NORMAL_FAVORABLE   = 119;
33 constexpr uint8_t THREAD_PRIO_NORMAL_FOREGROUND  = 110;
34 constexpr uint8_t THREAD_PRIO_NORMAL_URGENT      = 105;
35 constexpr uint8_t THREAD_PRIO_NORMAL_MAX         = 100;
36 constexpr uint8_t THREAD_PRIO_VIP_MAX            = 89;
37 constexpr uint8_t THREAD_PRIO_RT_HIGHEST         = 88;
38 
QosConfig()39 QosConfig::QosConfig()
40 {
41     setPolicySystem();
42 }
43 
setPolicySystem()44 void QosConfig::setPolicySystem()
45 {
46     g_systemServerQosPolicy = {
47         .policyType = QOS_POLICY_SYSTEM_SERVER,
48         .policyFlag = QOS_FLAG_ALL,
49         .policys = {
50             {10, 0, 250, THREAD_AFFINITY_LIT, THREAD_PRIO_NORMAL_BACKGROUND, 0, 0},
51             {10, 0, 250, THREAD_AFFINITY_ALL, THREAD_PRIO_NORMAL_UNFAVORABLE, 0, 0},
52             {0, 0, 1024, THREAD_AFFINITY_ALL, THREAD_PRIO_NORMAL_DEFAULT, 0, 0},
53             {0, 0, 1024, THREAD_AFFINITY_ALL, THREAD_PRIO_NORMAL_FOREGROUND, 0, 0},
54             {-10, 0, 1024, THREAD_AFFINITY_ALL, THREAD_PRIO_RT_HIGHEST, 1, 1},
55             {-20, 0, 1024, THREAD_AFFINITY_MID_BIG, THREAD_PRIO_RT_HIGHEST, 1, 1},
56         }
57     };
58 }
59 }