Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
ampcs
ANamespace
Aos
abstime
atomically
atomics
aosmpdu
APacket
apid
Expand Down Expand Up @@ -44,11 +47,13 @@
Bies
binaryfile
BINDIR
Bitfield

Check warning on line 50 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`Bitfield` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
bitfield
bitmaps
bitshifts
bitwidth
bitmask
bitmasks

Check warning on line 56 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`bitmasks` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
bocchino
boolt
BSB
Expand All @@ -73,8 +78,8 @@
callgraph
Campuzano
carg
CBE

Check warning on line 81 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`CBE` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
CBEs

Check warning on line 82 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`CBEs` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
CBF
CBLOCK
CCACHE
Expand Down Expand Up @@ -119,7 +124,7 @@
comlogger
COMLOGGERTEE
commandability
Commandability

Check warning on line 127 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`Commandability` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
COMMANDDISPATCHERIMPL
COMMANDDISPATCHERIMPLCFG
COMPACKET
Expand All @@ -129,6 +134,9 @@
COMSPLITTER
COMSTUB
constexpr
COUNTINGSEMAPHORE

Check warning on line 137 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`COUNTINGSEMAPHORE` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
countingsemaphore
CMPXCHG
cookiecutter
cooldown
coravy
Expand Down Expand Up @@ -170,6 +178,7 @@
deframed
deframer
deframing
dequeue
Deinitialization
deployables
DEPRECATEDLIST
Expand Down Expand Up @@ -211,6 +220,7 @@
dspal
DSSC
Dstate
DWCAS
DVI
DWN
eabi
Expand All @@ -222,12 +232,14 @@
eip
Elts
emptydir
embOS
endcond
endfunction
endmacro
endraw
enduml
enqueue
EPP

Check warning on line 242 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`EPP` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
epp
ERRORCHECK
errornum
Expand Down Expand Up @@ -411,6 +423,9 @@
LASTLOG
LBLOCK
LCHILD
LDARX
LDXR
LDREX
leisher
lestarch
lflag
Expand Down Expand Up @@ -467,11 +482,13 @@
mpdu
Mpu
Msb
MPMC
msc
mscfile
mseconds
mstarch
mstat
msgQ
MState
multiarch
multitool
Expand All @@ -484,6 +501,7 @@
nbits
ncsl
newtio
Neutrino
nmsgs
NOBLOCK
NODELABEL
Expand Down Expand Up @@ -552,8 +570,8 @@
Peet
penv
PERLMOD
PFR

Check warning on line 573 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`PFR` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
PFRs

Check warning on line 574 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`PFRs` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
PHASERMEMBEROUT
PINGENTRIES
PINGIN
Expand Down Expand Up @@ -593,6 +611,7 @@
projectnumber
propget
propput
pshared
protothreading
ptbool
ptf
Expand Down Expand Up @@ -642,6 +661,7 @@
SAlias
Safing
sanitizers
SafeRTOS

Check failure on line 664 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`SafeR` matches a line_forbidden.patterns rule: Expect entries should be one entry per line - `[A-Z](?:[A-Z]|[a-z]|')*?[a-z](?:[a-z]|')*[A-Z]` (forbidden-pattern)
sats
SBF
SBINDIR
Expand Down Expand Up @@ -693,6 +713,8 @@
spdx
spi
spidev
spinlock
spinlocks

Check warning on line 717 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`spinlocks` is ignored by check-spelling because another more general variant is also in expect (ignored-expect-variant)
spsc
sqa
srandom
Expand All @@ -704,13 +726,16 @@
stdbool
stddef
stdint
STDCX
stest
Stl
stmtidx
STREQ
STREQUAL
STRINGUTILS
STRNE
STREX
STXR
strnlen
subgrouping
subhist
Expand Down Expand Up @@ -751,12 +776,15 @@
tfvn
thisdirdoesnotexist
thisfiledoesnotexist
ThreadX

Check failure on line 779 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`ThreadX` matches a line_forbidden.patterns rule: Expect entries should be one entry per line - `[A-Z](?:[A-Z]|[a-z]|')*?[a-z](?:[a-z]|')*[A-Z]` (forbidden-pattern)
Thu
timcanham
timebase
timerfd
timetag
timeval
timedwait
timcanham
Tinternal
tions
tjh
Expand All @@ -779,6 +807,7 @@
tparam
TPP
trinomials
trywait
tts
Tumbar
tumbar
Expand Down Expand Up @@ -832,3 +861,4 @@
XXYY
ziext
zimri
Zephyr
1 change: 1 addition & 0 deletions Os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ add_named_os_module(Console Fw_Logger)
add_named_os_module("File;FileSystem;Directory" Utils_Hash)
add_named_os_module(Task ${CMAKE_THREAD_LIBS_INIT})
add_named_os_module("Mutex;Condition")
add_named_os_module(CountingSemaphore)
add_named_os_module(Queue)
add_named_os_module(Cpu)
add_named_os_module(Memory)
Expand Down
38 changes: 38 additions & 0 deletions Os/CountingSemaphore.cpp
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 notice

Code scanning / CodeQL

Use of basic integral type Note

pshared uses the basic integral type int rather than a typedef with size and signedness.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
: m_delegate(*CountingSemaphoreInterface::getDelegate(m_handle_storage, initial_count, pshared)) {}

Check notice

Code 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
74 changes: 74 additions & 0 deletions Os/CountingSemaphore.hpp
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 notice

Code 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_
40 changes: 40 additions & 0 deletions Os/Generic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Types")
add_custom_target("${FPRIME_CURRENT_MODULE}")

#### PriorityMemQueue (AtomicQueue-based) ####
register_fprime_module(
Os_Generic_PriorityMemQueue_Implementation
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/PriorityMemQueue.cpp"
HEADERS
"${CMAKE_CURRENT_LIST_DIR}/PriorityMemQueue.hpp"
DEPENDS
Fw_Types
Os_Generic_Types
Os_CountingSemaphore
)
register_fprime_implementation(
Os_Generic_PriorityMemQueue
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/DefaultPriorityMemQueue.cpp"
IMPLEMENTS
Os_Queue
DEPENDS
Fw_Types
Os_Generic_PriorityMemQueue_Implementation
)

register_fprime_ut(
PriorityMemQueue_UnitTest
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/PriorityMemQueueTests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/PriorityMemQueueInputValidationTests.cpp"
DEPENDS
Fw_Types
Fw_Time
Os
STest
Os_Generic_PriorityMemQueue_Implementation
CHOOSES_IMPLEMENTATIONS
Os_Generic_PriorityMemQueue
Os_Mutex_Posix
Os_CountingSemaphore_Posix
)

#### Os/Generic/Queue Section ####
register_fprime_module(
Os_Generic_PriorityQueue_Implementation
Expand Down
20 changes: 20 additions & 0 deletions Os/Generic/DefaultPriorityMemQueue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ======================================================================
// \title Os/Generic/DefaultPriorityMemQueue.cpp
// \author B. Duckett

Check failure on line 3 in Os/Generic/DefaultPriorityMemQueue.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`Duckett` is not a recognized word (unrecognized-spelling)
// \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
Loading
Loading