Skip to content

Commit

Permalink
Fix #1215, remove task registration calls
Browse files Browse the repository at this point in the history
Explicit task registration is no longer necessary, since all
required actions can be done before invoking the entry point.

This moves the invocation of CFE_PSP_AttachExceptions() from
the registration function to the pre-entry function, this was
the only remaining action in task registration.

All references to task registration in code, docs, and tests
are removed.
  • Loading branch information
jphickey committed Mar 23, 2021
1 parent 98bc158 commit 8c70e95
Show file tree
Hide file tree
Showing 23 changed files with 110 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 @@ -438,7 +438,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 @@ -950,9 +950,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
47 changes: 5 additions & 42 deletions modules/core_api/fsw/inc/cfe_es.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID);
** \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 @@ -367,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 @@ -436,23 +436,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 @@ -793,26 +776,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 @@ -850,7 +813,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 @@ -930,7 +893,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 @@ -950,7 +913,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
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 @@ -553,6 +553,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 @@ -565,8 +577,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 8c70e95

Please sign in to comment.