-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Message Queue with per priority memory allocation #5205
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
Open
bevinduckett
wants to merge
11
commits into
nasa:devel
Choose a base branch
from
bevinduckett:mem-priority-queue
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e2636bd
Added Os::CountingSemaphore osal module (#5173)
bevinduckett e7f0338
Added CountingSemaphore to SDD
bevinduckett 5cdb769
Added new words for spell check of semaphore
bevinduckett 8fd2214
Initial implementation of PriorityMemQueue using a lockless queue
bevinduckett 8a4e9b5
Added flagged words to spelling & improved UTs
bevinduckett 4c55a7e
Merge branch 'devel' into mem-priority-queue
bevinduckett b15daaa
Merge branch 'devel' into mem-priority-queue
thomas-bc 0a3451d
Merge upstream devel into mem-priority-queue; resolve CountingSemapho…
thomas-bc 07e4d39
Merge remote-tracking branch 'JPL-Devin/mem-priority-queue' into mem-…
thomas-bc 5363467
Resolve/revert devel merge quirks
thomas-bc 50486ca
Minimal review changes and formatting
thomas-bc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #include "Os/CountingSemaphore.hpp" | ||
| #include "Fw/Types/Assert.hpp" | ||
|
|
||
| namespace Os { | ||
| CountingSemaphore::CountingSemaphore(U32 initial_count, int pshared) | ||
Check noticeCode scanning / CodeQL Use of basic integral type Note
pshared uses the basic integral type int rather than a typedef with size and signedness.
|
||
| : m_delegate(*CountingSemaphoreInterface::getDelegate(m_handle_storage, initial_count, pshared)) {} | ||
Check noticeCode scanning / CodeQL More than one statement per line Note
This line contains 2 statements; only one is allowed.
|
||
|
|
||
| CountingSemaphore::~CountingSemaphore() { | ||
| m_delegate.~CountingSemaphoreInterface(); | ||
| } | ||
|
|
||
| CountingSemaphore::Status CountingSemaphore::wait() { | ||
| FW_ASSERT(&this->m_delegate == reinterpret_cast<CountingSemaphoreInterface*>(&this->m_handle_storage[0])); | ||
| return this->m_delegate.wait(); | ||
| } | ||
|
|
||
| CountingSemaphore::Status CountingSemaphore::waitTimeout(U32 timeout_ms) { | ||
| FW_ASSERT(&this->m_delegate == reinterpret_cast<CountingSemaphoreInterface*>(&this->m_handle_storage[0])); | ||
| FW_ASSERT(timeout_ms > 0); | ||
| return this->m_delegate.waitTimeout(timeout_ms); | ||
| } | ||
|
|
||
| CountingSemaphore::Status CountingSemaphore::tryWait() { | ||
| FW_ASSERT(&this->m_delegate == reinterpret_cast<CountingSemaphoreInterface*>(&this->m_handle_storage[0])); | ||
| return this->m_delegate.tryWait(); | ||
| } | ||
|
|
||
| CountingSemaphore::Status CountingSemaphore::post() { | ||
| FW_ASSERT(&this->m_delegate == reinterpret_cast<CountingSemaphoreInterface*>(&this->m_handle_storage[0])); | ||
| return this->m_delegate.post(); | ||
| } | ||
|
|
||
| CountingSemaphoreHandle* CountingSemaphore::getHandle() { | ||
| FW_ASSERT(&this->m_delegate == reinterpret_cast<const CountingSemaphoreInterface*>(&this->m_handle_storage[0])); | ||
| return this->m_delegate.getHandle(); | ||
| } | ||
|
|
||
| } // namespace Os | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // ====================================================================== | ||
| // \title Os/CountingSemaphore.hpp | ||
| // \brief common function definitions for Os::CountingSemaphore | ||
| // ====================================================================== | ||
| #include "Os/Os.hpp" | ||
|
|
||
| #ifndef OS_COUNTING_SEMAPHORE_HPP_ | ||
| #define OS_COUNTING_SEMAPHORE_HPP_ | ||
|
|
||
| namespace Os { | ||
|
|
||
| class CountingSemaphoreHandle {}; | ||
|
|
||
| class CountingSemaphoreInterface { | ||
| public: | ||
| enum Status { | ||
| OP_OK, //!< Operation was successful | ||
| ERROR_TIMEOUT, //!< Timeout occurred during wait | ||
| ERROR_INVALID, //!< Invalid semaphore or argument | ||
| ERROR_NOT_IMPLEMENTED, //!< Feature not implemented | ||
| NOT_SUPPORTED, //!< CountingSemaphore does not support operation | ||
| ERROR_OTHER //!< All other errors | ||
| }; | ||
|
|
||
| CountingSemaphoreInterface() = default; | ||
Check noticeCode scanning / CodeQL More than one statement per line Note
This line contains 2 statements; only one is allowed.
|
||
| virtual ~CountingSemaphoreInterface() = default; | ||
|
|
||
| CountingSemaphoreInterface(const CountingSemaphoreInterface& other) = delete; | ||
|
|
||
| virtual CountingSemaphoreInterface& operator=(const CountingSemaphoreInterface& other) = delete; | ||
|
|
||
| virtual Status wait() = 0; | ||
|
|
||
| virtual Status waitTimeout(U32 timeout_ms) = 0; | ||
|
|
||
| virtual Status tryWait() = 0; | ||
|
|
||
| virtual Status post() = 0; | ||
|
|
||
| virtual CountingSemaphoreHandle* getHandle() = 0; | ||
|
|
||
| static CountingSemaphoreInterface* getDelegate(CountingSemaphoreHandleStorage& aligned_new_memory, | ||
| U32 initial_count, | ||
| int pshared); | ||
| }; | ||
|
|
||
| class CountingSemaphore final : public CountingSemaphoreInterface { | ||
| public: | ||
| CountingSemaphore(U32 initial_count, int pshared); | ||
|
|
||
| ~CountingSemaphore() final; | ||
|
|
||
| CountingSemaphore(const CountingSemaphoreInterface& other) = delete; | ||
|
|
||
| CountingSemaphore(const CountingSemaphoreInterface* other) = delete; | ||
|
|
||
| CountingSemaphoreInterface& operator=(const CountingSemaphoreInterface& other) override = delete; | ||
|
|
||
| Status wait() override; | ||
|
|
||
| Status waitTimeout(U32 timeout_ms) override; | ||
|
|
||
| Status tryWait() override; | ||
|
|
||
| Status post() override; | ||
|
|
||
| CountingSemaphoreHandle* getHandle() override; | ||
|
|
||
| private: | ||
| alignas(FW_HANDLE_ALIGNMENT) CountingSemaphoreHandleStorage m_handle_storage; | ||
| CountingSemaphoreInterface& m_delegate; | ||
| }; | ||
| } // namespace Os | ||
| #endif // OS_COUNTING_SEMAPHORE_HPP_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // ====================================================================== | ||
| // \title Os/Generic/DefaultPriorityMemQueue.cpp | ||
| // \author B. Duckett | ||
| // \brief cpp file sets default Os::Queue to generic priority queue implementation via linker | ||
| // | ||
| // \copyright | ||
| // Copyright 2026, by the California Institute of Technology. | ||
| // ALL RIGHTS RESERVED. United States Government Sponsorship | ||
| // acknowledged. | ||
| // ====================================================================== | ||
| #include "Os/Delegate.hpp" | ||
| #include "Os/Queue.hpp" | ||
| #include "PriorityMemQueue.hpp" | ||
|
|
||
| namespace Os { | ||
| QueueInterface* QueueInterface::getDelegate(QueueHandleStorage& aligned_new_memory) { | ||
| return Os::Delegate::makeDelegate<QueueInterface, Os::Generic::PriorityMemQueue, QueueHandleStorage>( | ||
| aligned_new_memory); | ||
| } | ||
| } // namespace Os | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.