Skip to content

Commit

Permalink
Merge pull request #1250 from jphickey/fix-1215-task-registration
Browse files Browse the repository at this point in the history
Fix #1215, remove task registration calls #1250
  • Loading branch information
astrogeco committed Mar 29, 2021
2 parents b239365 + 8c70e95 commit 66e2463
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 446 deletions.
100 changes: 49 additions & 51 deletions docs/cFE Application Developers Guide.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/src/cfe_api.dox
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</UL>
<LI> \ref CFEAPIESAppBehavior
<UL>
<LI> #CFE_ES_RegisterApp - \copybrief CFE_ES_RegisterApp
<LI> #CFE_ES_RunLoop - \copybrief CFE_ES_RunLoop
<LI> #CFE_ES_WaitForStartupSync - \copybrief CFE_ES_WaitForStartupSync
<LI> #CFE_ES_WaitForSystemState - \copybrief CFE_ES_WaitForSystemState
Expand All @@ -33,7 +32,6 @@
</UL>
<LI> \ref CFEAPIESChildTask
<UL>
<LI> #CFE_ES_RegisterChildTask - \copybrief CFE_ES_RegisterChildTask
<LI> #CFE_ES_CreateChildTask - \copybrief CFE_ES_CreateChildTask
<LI> #CFE_ES_DeleteChildTask - \copybrief CFE_ES_DeleteChildTask
<LI> #CFE_ES_ExitChildTask - \copybrief CFE_ES_ExitChildTask
Expand Down
10 changes: 0 additions & 10 deletions modules/cfe_testrunner/src/cfe_testrunner_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ void CFE_TestRunner_AppMain(void)
int32 rc;
uint32 RunStatus;

/*
** Register the app with Executive services
*/
rc = CFE_ES_RegisterApp();
if (rc != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("Error in CFE_ES_RegisterApp(): %08lx\n", (unsigned long)rc);
return;
}

/*
* Delay until the system reaches "operational" state -- this is when all libs have initialized
* and all apps have reached their RunLoop.
Expand Down
5 changes: 1 addition & 4 deletions modules/core_api/fsw/inc/cfe_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ typedef int32 CFE_Status_t;
/**
* @brief Application Register Error
*
* Occurs when the #CFE_ES_RegisterApp fails.
* Occurs when a task cannot be registered in ES global tables
*
*/
#define CFE_ES_ERR_APP_REGISTER ((CFE_Status_t)0xc4000017)
Expand Down Expand Up @@ -945,9 +945,6 @@ typedef int32 CFE_Status_t;
* @brief Bad Application ID
*
* The calling application does not have a legitimate Application ID.
* Most likely cause is a failure to register with the cFE via the
* #CFE_ES_RegisterApp function.
*
*/
#define CFE_TBL_ERR_BAD_APP_ID ((CFE_Status_t)0xcc00000A)

Expand Down
48 changes: 6 additions & 42 deletions modules/core_api/fsw/inc/cfe_es.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID);
** \arg #CFE_ES_RunStatus_CORE_APP_INIT_ERROR - \copybrief CFE_ES_RunStatus_CORE_APP_INIT_ERROR
** \arg #CFE_ES_RunStatus_CORE_APP_RUNTIME_ERROR - \copybrief CFE_ES_RunStatus_CORE_APP_RUNTIME_ERROR
**
** \sa #CFE_ES_RunLoop, #CFE_ES_RegisterApp
**
** \sa #CFE_ES_RunLoop
**
******************************************************************************/
void CFE_ES_ExitApp(uint32 ExitStatus);
Expand All @@ -366,7 +367,7 @@ void CFE_ES_ExitApp(uint32 ExitStatus);
** \retval true Application should continue running
** \retval false Application should not continue running
**
** \sa #CFE_ES_ExitApp, #CFE_ES_RegisterApp
** \sa #CFE_ES_ExitApp
**
******************************************************************************/
bool CFE_ES_RunLoop(uint32 *ExitStatus);
Expand Down Expand Up @@ -434,23 +435,6 @@ CFE_Status_t CFE_ES_WaitForSystemState(uint32 MinSystemState, uint32 TimeOutMill
******************************************************************************/
void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds);

/*****************************************************************************/
/**
** \brief Registers a cFE Application with the Executive Services
**
** \par Description
** This API registers the calling Application with the cFE.
**
** \par Assumptions, External Events, and Notes:
** NOTE: This function \b MUST be called before any other cFE API functions are called.
**
** \return Execution status, see \ref CFEReturnCodes
**
** \sa #CFE_ES_ExitApp, #CFE_ES_RunLoop
**
******************************************************************************/
CFE_Status_t CFE_ES_RegisterApp(void);

/*****************************************************************************/
/**
** \ingroup CFEAPIESAppBehavior
Expand Down Expand Up @@ -780,26 +764,6 @@ int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t Resour
* @{
*/

/*****************************************************************************/
/**
** \brief Registers a cFE Child task associated with a cFE Application
**
** \par Description
** This routine registers a cFE Child task and associates it with its parent
** cFE Application.
**
** \par Assumptions, External Events, and Notes:
** NOTE: This API \b MUST be called by the Child Task before any other cFE API calls are made.
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_ES_ERR_CHILD_TASK_REGISTER \copybrief CFE_ES_ERR_CHILD_TASK_REGISTER
**
** \sa #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask
**
******************************************************************************/
CFE_Status_t CFE_ES_RegisterChildTask(void);

/*****************************************************************************/
/**
** \brief Creates a new task under an existing Application
Expand Down Expand Up @@ -837,7 +801,7 @@ CFE_Status_t CFE_ES_RegisterChildTask(void);
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_ES_ERR_CHILD_TASK_CREATE \copybrief CFE_ES_ERR_CHILD_TASK_CREATE
**
** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask
** \sa #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask
**
******************************************************************************/
CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName,
Expand Down Expand Up @@ -915,7 +879,7 @@ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t B
** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS
** \retval #CFE_ES_NOT_IMPLEMENTED \copybrief CFE_ES_NOT_IMPLEMENTED
**
** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask
** \sa #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask
**
******************************************************************************/
CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId);
Expand All @@ -935,7 +899,7 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId);
** at all, it is assumed that the Task was either unregistered or
** this function was called from a cFE Application's main task.
**
** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask
** \sa #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask
**
******************************************************************************/
void CFE_ES_ExitChildTask(void);
Expand Down
53 changes: 0 additions & 53 deletions modules/core_api/ut-stubs/src/ut_es_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,59 +346,6 @@ CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t Buffe
return status;
}

/*****************************************************************************/
/**
** \brief CFE_ES_RegisterApp stub function
**
** \par Description
** This function is used to mimic the response of the cFE ES function
** CFE_ES_RegisterApp. The user can adjust the response by setting
** the values in the ES_RegisterRtn structure prior to this function
** being called. If the value ES_RegisterRtn.count is greater than
** zero then the counter is decremented; if it then equals zero the
** return value is set to the user-defined value ES_RegisterRtn.value.
** CFE_SUCCESS is returned otherwise.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either a user-defined status flag or CFE_SUCCESS.
**
******************************************************************************/
int32 CFE_ES_RegisterApp(void)
{
int32 status;

status = UT_DEFAULT_IMPL(CFE_ES_RegisterApp);

return status;
}

/*****************************************************************************/
/**
** \brief CFE_ES_RegisterChildTask stub function
**
** \par Description
** This function is used to mimic the response of the cFE ES function
** CFE_ES_RegisterChildTask. It always returns CFE_SUCCESS when called.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns CFE_SUCCESS.
**
******************************************************************************/
int32 CFE_ES_RegisterChildTask(void)
{
int32 status = CFE_SUCCESS;

status = UT_DEFAULT_IMPL(CFE_ES_RegisterChildTask);

return status;
}

/*****************************************************************************/
/**
** \brief CFE_ES_WriteToSysLog stub function
Expand Down
2 changes: 0 additions & 2 deletions modules/core_private/ut-stubs/inc/ut_osprintf_stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
#define UT_OSP_ES_APP_STARTUP_OPEN 39
#define UT_OSP_COMMAND_PIPE 40
#define UT_OSP_APP_INIT 41
#define UT_OSP_REGISTER_APP 42
#define UT_OSP_SHARED_LIBRARY_INIT 43
#define UT_OSP_DECOMPRESS_LIBRARY 44
#define UT_OSP_EXTRACT_FILENAME_CF 45
Expand Down Expand Up @@ -96,7 +95,6 @@
#define UT_OSP_STARTUP_SYNC_FAIL_2 67
#define UT_OSP_MODULE_UNLOAD_FAILED 68
#define UT_OSP_TASKEXIT_BAD_CONTEXT 69
#define UT_OSP_BACKGROUND_REGISTER 70
#define UT_OSP_BACKGROUND_TAKE 71

#endif /* UT_OSPRINTF_STUBS_H */
3 changes: 0 additions & 3 deletions modules/core_private/ut-stubs/src/ut_osprintf_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ const char *UT_OSP_MESSAGES[] = {
[UT_OSP_MOUNT_VOLATILE] = "ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n",
/* CFE_ES_ExitApp: CORE Application CFE_ES Had a Runtime Error. */
[UT_OSP_CORE_RUNTIME] = "CFE_ES_ExitApp: CORE Application %s Had a Runtime Error.\n",
/* ES:Call to CFE_ES_RegisterApp Failed, RC = 0x~ */
[UT_OSP_REGISTER_APP] = "ES:Call to CFE_ES_RegisterApp Failed, RC = 0x%08X\n",
/* ES Startup: OS_TaskCreate error creating core App: CFE_TBL: EC = 0x~ */
[UT_OSP_CORE_APP_CREATE] = "ES Startup: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n",
/* ES Startup: Error returned when calling function: CFE_TBL_EarlyInit: EC = 0x~ */
Expand Down Expand Up @@ -161,6 +159,5 @@ const char *UT_OSP_MESSAGES[] = {
[UT_OSP_RECORD_USED] = "ES Startup: Error: ES_TaskTable slot for ID %lx in use at task creation!\n",
/* CFE_ES_ExitChildTask called from invalid task context */
[UT_OSP_TASKEXIT_BAD_CONTEXT] = "CFE_ES_ExitChildTask called from invalid task context\n",
[UT_OSP_BACKGROUND_REGISTER] = "CFE_ES: Background Task Failed to register: %08lx\n",
[UT_OSP_BACKGROUND_TAKE] = "CFE_ES: Failed to take background sem: %08lx\n",
};
77 changes: 0 additions & 77 deletions modules/es/fsw/src/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,44 +639,6 @@ void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds)
CFE_ES_WaitForSystemState(CFE_ES_SystemState_OPERATIONAL, TimeOutMilliseconds);
}

/*
** Function: - See API and header file for details
*/
int32 CFE_ES_RegisterApp(void)
{
int32 Result;

CFE_ES_LockSharedData(__func__, __LINE__);

/*
** Register the task
*/
Result = OS_TaskRegister();

if (Result == OS_SUCCESS)
{
Result = CFE_SUCCESS;
}
else
{
/*
** Cannot create a syslog entry here because it requires the task to
** be registered
*/
Result = CFE_ES_ERR_APP_REGISTER;
}

/*
** Set the default exception environment
*/
CFE_PSP_SetDefaultExceptionEnvironment();

CFE_ES_UnlockSharedData(__func__, __LINE__);

return (Result);

} /* End of CFE_ES_RegisterApp() */

/*
** Function: CFE_ES_GetAppIDByName - See API and header file for details
*/
Expand Down Expand Up @@ -1296,45 +1258,6 @@ int32 CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName,

} /* End of CFE_ES_CreateChildTask() */

/*
** Function: CFE_ES_RegisterChildTask - See API and header file for details
*/
int32 CFE_ES_RegisterChildTask(void)
{
int32 Result;
int32 ReturnCode;

CFE_ES_LockSharedData(__func__, __LINE__);

/*
** Register the task with the OS
*/
Result = OS_TaskRegister();

if (Result != OS_SUCCESS)
{
/*
** Cannot create a syslog entry here because it requires the task to
** be registered
*/
ReturnCode = CFE_ES_ERR_CHILD_TASK_REGISTER;
}
else
{
ReturnCode = CFE_SUCCESS;
}

/*
** Set the default exception environment
*/
CFE_PSP_SetDefaultExceptionEnvironment();

CFE_ES_UnlockSharedData(__func__, __LINE__);

return (ReturnCode);

} /* End of CFE_ES_RegisterChildTask() */

/*
** Function: CFE_ES_IncrementTaskCounter - See API and header file for details
*/
Expand Down
16 changes: 14 additions & 2 deletions modules/es/fsw/src/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,18 @@ void CFE_ES_TaskEntryPoint(void)

if (CFE_ES_GetTaskFunction(&RealEntryFunc) == CFE_SUCCESS && RealEntryFunc != NULL)
{
/*
* Set the default exception environment, which should
* be done serialized (i.e. only one task at a time should
* call into CFE_PSP_SetDefaultExceptionEnvironment).
*/
CFE_ES_LockSharedData(__func__, __LINE__);
CFE_PSP_SetDefaultExceptionEnvironment();
CFE_ES_UnlockSharedData(__func__, __LINE__);

/*
* Call the actual task entry function
*/
(*RealEntryFunc)();
}
}
Expand All @@ -563,8 +575,8 @@ void CFE_ES_TaskEntryPoint(void)
**
** Note that OSAL does not separate the action of creating and start a task, providing
** only OS_TaskCreate which does both. But there is a potential race condition if
** the real task code starts and calls e.g. CFE_ES_RegisterApp() or any other function
** that depends on having an AppID context, before its fully registered in the global app table.
** the real task code starts and calls any function that depends on having an AppID
** context before its fully registered in the global app table.
**
** Therefore this calls a dedicated CFE_ES_AppEntryPoint which then will wait until
** the task is fully registered in the global, before calling the actual app entry point.
Expand Down
8 changes: 0 additions & 8 deletions modules/es/fsw/src/cfe_es_backgroundtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ void CFE_ES_BackgroundTask(void)
OS_time_t LastTime;
const CFE_ES_BackgroundJobEntry_t *JobPtr;

status = CFE_ES_RegisterChildTask();
if (status != CFE_SUCCESS)
{
/* should never occur */
CFE_ES_WriteToSysLog("CFE_ES: Background Task Failed to register: %08lx\n", (unsigned long)status);
return;
}

CFE_PSP_GetTime(&LastTime);

while (true)
Expand Down
10 changes: 0 additions & 10 deletions modules/es/fsw/src/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,6 @@ int32 CFE_ES_TaskInit(void)
uint32 SizeofCfeSegment;
cpuaddr CfeSegmentAddr;

/*
** Register the Application
*/
Status = CFE_ES_RegisterApp();
if (Status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("ES:Call to CFE_ES_RegisterApp Failed, RC = 0x%08X\n", (unsigned int)Status);
return (Status);
}

/*
** Initialize task command execution counters
*/
Expand Down
Loading

0 comments on commit 66e2463

Please sign in to comment.