From b8f4b31181df0d2073702aeb838c4f55bd805991 Mon Sep 17 00:00:00 2001 From: SimonLi Date: Fri, 26 Nov 2021 22:36:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dsamgr=5Flite=E6=A0=88?= =?UTF-8?q?=E6=BA=A2=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 共享task的内存默认为0x800,当任务函数调用层次较为复杂的时候,就会出现栈溢出的 问题,增加栈大小可配置参数,根据不同的情况进行栈大小调节 Signed-off-by: SimonLi --- config.gni | 18 ++++++++++++++++++ samgr/BUILD.gn | 12 +++++++++++- samgr/source/samgr_lite.c | 3 ++- samgr/source/samgr_lite_inner.h | 1 - 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 config.gni diff --git a/config.gni b/config.gni new file mode 100644 index 0000000..43b205b --- /dev/null +++ b/config.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 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. + +declare_args() { + # configuration for samgr_lite created shared task's stack size. + # 0 means using system default thread stack size, other positive values will be accepted. + config_ohos_distributedschedule_samgr_lite_shared_task_size = 2048 +} diff --git a/samgr/BUILD.gn b/samgr/BUILD.gn index 351fb6f..77abb36 100755 --- a/samgr/BUILD.gn +++ b/samgr/BUILD.gn @@ -10,8 +10,18 @@ # 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("../config.gni") + +defines = [] + +if (defined(config_ohos_distributedschedule_samgr_lite_shared_task_size) && + config_ohos_distributedschedule_samgr_lite_shared_task_size > 0) { + defines += [ "SHARED_TASK_STACK_SIZE=$config_ohos_distributedschedule_samgr_lite_shared_task_size" ] +} + config("external_settings_shared") { - defines = [ "LAYER_INIT_SHARED_LIB" ] + defines += [ "LAYER_INIT_SHARED_LIB" ] } config("samgr_public") { diff --git a/samgr/source/samgr_lite.c b/samgr/source/samgr_lite.c index d7491c5..dd7e0c4 100755 --- a/samgr/source/samgr_lite.c +++ b/samgr/source/samgr_lite.c @@ -441,7 +441,8 @@ static void AddTaskPool(ServiceImpl *service, TaskConfig *cfg, const char *name) int pos = (int)cfg->priority / PROPERTY_STEP; SamgrLiteImpl *samgr = GetImplement(); if (samgr->sharedPool[pos] == NULL) { - TaskConfig shareCfg = DEFAULT_TASK_CFG(pos); + TaskConfig shareCfg = {LEVEL_HIGH, (int16) ((pos) * PROPERTY_STEP + 1), + SHARED_TASK_STACK_SIZE, 25, SHARED_TASK}; samgr->sharedPool[pos] = SAMGR_CreateFixedTaskPool(&shareCfg, name, DEFAULT_SIZE); } service->taskPool = samgr->sharedPool[pos]; diff --git a/samgr/source/samgr_lite_inner.h b/samgr/source/samgr_lite_inner.h index d4e92c8..bdbb30d 100755 --- a/samgr/source/samgr_lite_inner.h +++ b/samgr/source/samgr_lite_inner.h @@ -31,7 +31,6 @@ extern "C" { #define SINGLE_SIZE 1 #define MAX_POOL_NUM 8 #define PROPERTY_STEP 8 -#define DEFAULT_TASK_CFG(pos) {LEVEL_HIGH, (int16) ((pos) * PROPERTY_STEP + 1), 0x800, 25, SHARED_TASK} #define WDG_SAMGR_INIT_TIME 1000 #define WDG_SVC_REG_TIME 5000 #define WDG_SVC_BOOT_TIME 5000