From 8de17d7b78d4e49a16ecafbe2f113e97aa756bbe Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 17 Nov 2020 17:11:56 -0500 Subject: [PATCH] Fix #1004, default stack size Do not enforce CFE_PLATFORM_ES_DEFAULT_STACK_SIZE as a minimum, it should be a default. --- fsw/cfe-core/src/es/cfe_es_task.c | 24 ++++++++++++++---------- fsw/cfe-core/src/inc/cfe_es_events.h | 17 ----------------- fsw/cfe-core/unit-test/es_UT.c | 6 +++--- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 75af1e6e9..37de080df 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -861,6 +861,7 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartApp_t *data) int32 FilenameLen; int32 AppEntryLen; int32 AppNameLen; + size_t AppStackSize; char LocalFile[OS_MAX_PATH_LEN]; char LocalEntryPt[OS_MAX_API_NAME]; char LocalAppName[OS_MAX_API_NAME]; @@ -897,13 +898,6 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartApp_t *data) CFE_EVS_SendEvent(CFE_ES_START_NULL_APP_NAME_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: App Name is NULL."); } - else if (cmd->StackSize < CFE_PLATFORM_ES_DEFAULT_STACK_SIZE) - { - CFE_ES_TaskData.CommandErrorCounter++; - CFE_EVS_SendEvent(CFE_ES_START_STACK_ERR_EID, CFE_EVS_EventType_ERROR, - "CFE_ES_StartAppCmd: Stack size is less than system Minimum: %d.", - CFE_PLATFORM_ES_DEFAULT_STACK_SIZE); - } else if (cmd->Priority > OS_MAX_PRIORITY) { CFE_ES_TaskData.CommandErrorCounter++; @@ -921,15 +915,25 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartApp_t *data) } else { + /* If stack size was provided, use it, otherwise use default. */ + if (cmd->StackSize == 0) + { + AppStackSize = CFE_PLATFORM_ES_DEFAULT_STACK_SIZE; + } + else + { + AppStackSize = cmd->StackSize; + } + /* ** Invoke application loader/startup function. */ Result = CFE_ES_AppCreate(&AppID, LocalFile, LocalEntryPt, LocalAppName, - (uint32) cmd->Priority, - (uint32) cmd->StackSize, - (uint32) cmd->ExceptionAction); + cmd->Priority, + AppStackSize, + cmd->ExceptionAction); /* ** Send appropriate event message diff --git a/fsw/cfe-core/src/inc/cfe_es_events.h b/fsw/cfe-core/src/inc/cfe_es_events.h index 8b0f4b432..06acbc1fd 100644 --- a/fsw/cfe-core/src/inc/cfe_es_events.h +++ b/fsw/cfe-core/src/inc/cfe_es_events.h @@ -488,23 +488,6 @@ **/ #define CFE_ES_START_NULL_APP_NAME_ERR_EID 29 -/** \brief 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' -** \event 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Application Stack Size parameter is -** less than the default stack size defined in the cfe_platform_cfg.h file: CFE_PLATFORM_ES_DEFAULT_STACK_SIZE. -** -** The \c 'd' term identifies the size of the stack that was given in the command. -**/ -#define CFE_ES_START_STACK_ERR_EID 30 - /** \brief 'CFE_ES_StartAppCmd: Priority is too large: \%d.' ** \event 'CFE_ES_StartAppCmd: Priority is too large: \%d.' ** diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index b0416ad2a..042f11002 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -2966,7 +2966,7 @@ void TestTask(void) "CFE_ES_StartAppCmd", "Invalid exception action"); - /* Test app create with a bad stack size */ + /* Test app create with a default stack size */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", @@ -2981,9 +2981,9 @@ void TestTask(void) UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); UT_Report(__FILE__, __LINE__, - UT_EventIsInHistory(CFE_ES_START_STACK_ERR_EID), + UT_EventIsInHistory(CFE_ES_START_INF_EID), "CFE_ES_StartAppCmd", - "Stack size too small"); + "Default Stack Size"); /* Test app create with a bad priority */ ES_ResetUnitTest();