Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #648, 649, 664 - refactor all table array access #666

Merged
merged 6 commits into from
Dec 9, 2020

Conversation

jphickey
Copy link
Contributor

@jphickey jphickey commented Dec 2, 2020

Describe the contribution
Refactor the table array access across OSAL. Multiple fixes combined into one PR as they depend on each other.

Fix #648 : Rather than indexing arrays directly, use a token concept in combination with a macro to obtain the table entry. All access is then done through this table pointer. The token contains all relevant information about an object, importantly it has the "truth" as to what actual object ID is being manipulated. This is necessary when operations such as new/delete may change the value in the table itself - the token always has the right value.

Fix #649 : Use the full object ID in the timer call back list. This avoids complexities (and issues) associated with trying to regenerate the ID when the list changes.

Fix #664 : Update the timer sync callback prototype. Pass the entire OSAL ID to the sync function, not just the index. This is technically an API change (although they are both uint32, the value changes). AFAIK this sync feature isn't actively used so this shouldn't really have an impact though.

Testing performed
Build and run all tests for native (POSIX), rtems 4.11 and VxWorks

Expected behavior changes
No impact to behavior - just a substantial cleanup of the internal patterns.

System(s) tested on
Ubuntu 20.04, rtems 4.11

Additional context
This is also necessary as a prerequisite to a couple other OSAL issues - where the original ID needs to be preserved across ops which create/delete entities. The token provides this.

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey changed the base branch from main to integration-candidate December 2, 2020 03:22
@jphickey jphickey force-pushed the fix-648-649-664 branch 2 times, most recently from 40902ed to cf9db6d Compare December 2, 2020 14:26
@jphickey jphickey added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Dec 2, 2020
astrogeco and others added 3 commits December 2, 2020 09:30
osal Integration Candidate: 2020-11-24
Introduce the OS_object_token_t type which tracks a reference
to an OSAL resource.  This contains all information about the
original reference, including the ID, object type, lock type, and
the table index.

Therefore, since the token type contains all relevant info, it
can be used in all places where a bare index was used.

This also considerably simplifies the code, as some functions
which previously output multiple objects only need to operate on
tokens, and the functions which called these functions only need
to instantiate a token.
Use a variable name that matches the type of resource being accessed,
rather than just "local".  In particular this is important for readability
of timecb and timebase code where functions need often need to access both
types of objects at the same time.  This also updates filesys code to match.
@jphickey jphickey changed the base branch from integration-candidate to main December 2, 2020 14:48
@jphickey
Copy link
Contributor Author

jphickey commented Dec 2, 2020

Rebased to latest main ... should be good to go now.

@astrogeco astrogeco added CCB-20201202 and removed CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) labels Dec 2, 2020
@astrogeco
Copy link
Contributor

astrogeco commented Dec 2, 2020

CCB 2020-12-02 APPROVED

  • @klystron78 mentioned that it would be nice to have a "generic functions" archive of some sort
  • Will help solve a lot of other challenges in a maintainable manner

@astrogeco astrogeco requested review from skliper and a user December 2, 2020 18:01
@jphickey jphickey linked an issue Dec 3, 2020 that may be closed by this pull request
@jphickey
Copy link
Contributor Author

jphickey commented Dec 3, 2020

This also fixes #647 although that wasn't in a separate commit -- By using an iterator this is now invoking OS_close() to do the work in both OS_CloseFileByName() and OS_CloseAllFiles() instead of directly deleting the entry itself. So any side effects will be consistent between all of them.

Pass token objects to impl layers to identify the object to operate
on, rather than the index.  The token has extra information including
the original/actual object ID - which matters if the ID might change
as part of the operation (e.g. new/delete).
For the linked list of timer callbacks, use the full object ID
value rather than just the index.  This ensures consistency
in the list and also makes it easier to manage.
ID is preferable to an array index because direct table access
should not be done outside OSAL itself.
@jphickey
Copy link
Contributor Author

jphickey commented Dec 4, 2020

Found a minor issue here where it was filling the active_id field with RESERVED value ... corrected in commit ffb098d (actually didn't cause any breakage here but it did break my next PR for next week).

@astrogeco astrogeco changed the base branch from main to integration-candidate December 7, 2020 15:04
@astrogeco
Copy link
Contributor

@acudmore can you review this?

@astrogeco astrogeco merged commit 5c61560 into nasa:integration-candidate Dec 9, 2020
astrogeco added a commit to nasa/cFS that referenced this pull request Dec 9, 2020
astrogeco added a commit to nasa/cFS that referenced this pull request Dec 9, 2020
@jphickey jphickey deleted the fix-648-649-664 branch January 27, 2021 14:09
@skliper skliper added this to the 6.0.0 milestone Sep 24, 2021
jphickey added a commit to jphickey/osal that referenced this pull request Aug 10, 2022
The "CFE_SB_CmdHdr_t" and "CFE_SB_TlmHdr_t" types were not defined
such that they would have compatible alignment with (and thereby allow
safe casting to/from) a CFE_SB_Msg_t type.

This changes the definition to be a union so that the types are
aligned correctly.
jphickey added a commit to jphickey/osal that referenced this pull request Aug 10, 2022
Update the CFE_ES_ShellTlm_t, CFE_TIME_ToneSignalCmd_t, and
CFE_TIME_FakeToneCmd_t to use the CFE_SB_TlmHdr_t/CFE_SB_CmdHdr_t
types to define the buffer, rather than a uint8 array.

This should not change the size, as it was already defined using
sizeof() this structure, but it will make it aligned correctly
which resolves the compiler warning.

Note that all CMD/TLM should really be defined this way, but
this only selectively changes the places that were actually
generating a compiler warning about this.  There is a risk
that padding will be added, but this change should not change
the padding or size of messages in 32-bit builds.
jphickey added a commit to jphickey/osal that referenced this pull request Aug 10, 2022
Update the CFE_ES_ShellTlm_t, CFE_TIME_ToneSignalCmd_t, and
CFE_TIME_FakeToneCmd_t to use the CFE_SB_TlmHdr_t/CFE_SB_CmdHdr_t
types to define the buffer, rather than a uint8 array.

This should not change the size, as it was already defined using
sizeof() this structure, but it will make it aligned correctly
which resolves the compiler warning.

Note that all CMD/TLM should really be defined this way, but
this only selectively changes the places that were actually
generating a compiler warning about this.  There is a risk
that padding will be added, but this change should not change
the padding or size of messages in 32-bit builds.
jphickey pushed a commit to jphickey/osal that referenced this pull request Aug 10, 2022
jphickey pushed a commit to jphickey/osal that referenced this pull request Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants