Skip to content

Commit

Permalink
Merge pull request #917 from jphickey/fix-651-abstract-mempool-id
Browse files Browse the repository at this point in the history
Fix #651, Use resource ID for memory pools
  • Loading branch information
astrogeco committed Oct 1, 2020
2 parents 948fa07 + f6ae2fb commit 3a809eb
Show file tree
Hide file tree
Showing 21 changed files with 2,638 additions and 1,047 deletions.
34 changes: 34 additions & 0 deletions cmake/sample_defs/cpu1_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,40 @@
#define CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS 2


/** \cfeescfg Maximum number of block sizes in pool structures
**
** \par Description:
** The upper limit for the number of block sizes supported in the generic
** pool implementation, which in turn implements the memory pools and CDS.
**
** \par Limits:
** Must be at least one. No specific upper limit, but the number is
** anticipated to be reasonably small (i.e. tens, not hundreds). Large
** values have not been tested.
**
** The ES and CDS block size lists must correlate with this value
*/
#define CFE_PLATFORM_ES_POOL_MAX_BUCKETS 17

/** \cfeescfg Maximum number of memory pools
**
** \par Description:
** The upper limit for the number of memory pools than can concurrently
** exist within the system.
**
** The CFE_SB and CFE_TBL core subsystems each define a memory pool.
**
** Individual applications may also create memory pools, so this value
** should be set sufficiently high enough to support the applications
** being used on this platform.
**
** \par Limits:
** Must be at least 2 to support CFE core - SB and TBL pools. No
** specific upper limit.
*/
#define CFE_PLATFORM_ES_MAX_MEMORY_POOLS 10


/**
** \cfeescfg Define Default ES Memory Pool Block Sizes
**
Expand Down
34 changes: 34 additions & 0 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,8 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr)
CFE_ES_ResourceID_t CurrTaskId;
int32 ReturnCode = CFE_SUCCESS;
CFE_ES_TaskRecord_t *TaskRecPtr;
CFE_ES_MemPoolRecord_t *MemPoolRecPtr;
CFE_ES_MemHandle_t PoolId;
CFE_ES_ResourceID_t AppId;

/*
Expand Down Expand Up @@ -1191,6 +1193,38 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr)

CFE_ES_AppRecordSetFree(AppRecPtr);

/*
** Delete any memory pools associated with this app
*/
MemPoolRecPtr = CFE_ES_Global.MemPoolTable;
for ( i = 0; i < CFE_PLATFORM_ES_MAX_MEMORY_POOLS; i++ )
{
if ( CFE_ES_MemPoolRecordIsUsed(MemPoolRecPtr) &&
CFE_ES_ResourceID_Equal(MemPoolRecPtr->OwnerAppID, AppId))
{
PoolId = CFE_ES_MemPoolRecordGetID(MemPoolRecPtr);

/*
* This needs to release the lock first because
* CFE_ES_PoolDelete acquires the lock.
*/
CFE_ES_UnlockSharedData(__func__, __LINE__);
Status = CFE_ES_PoolDelete(PoolId);
CFE_ES_LockSharedData(__func__, __LINE__);

if ( Status != CFE_SUCCESS )
{
CFE_ES_SysLogWrite_Unsync("CFE_ES_MemPoolCleanupApp: delete pool %lu returned Error: 0x%08X\n",
CFE_ES_ResourceID_ToInteger(PoolId), (unsigned int)Status);
ReturnCode = CFE_ES_APP_CLEANUP_ERR;
}
}

++MemPoolRecPtr;
} /* end for */



CFE_ES_UnlockSharedData(__func__,__LINE__);

return(ReturnCode);
Expand Down
Loading

0 comments on commit 3a809eb

Please sign in to comment.