-
Notifications
You must be signed in to change notification settings - Fork 2
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
Move Edu program status history to FRAM #328
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #328 +/- ##
=========================================
Coverage ? 87.27%
=========================================
Files ? 37
Lines ? 1352
Branches ? 50
=========================================
Hits ? 1180
Misses ? 172
Partials ? 0 ☔ View full report in Codecov by Sentry. |
0593f19
to
3f90355
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Unit tests should be as self-contained as possible. Therefore, please remove the dependency on the EDU code and test
RingArray
with a custom type that is defined right in the source file.
auto entry = programStatusHistory.Get(i); | ||
if(entry.startTime == startTime and entry.programId == programId) | ||
{ | ||
programStatusHistory.vals[i].status = newStatus; | ||
entry.status = newStatus; | ||
programStatusHistory.Set(i, entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this is not thread-safe in the sense that someone might call PushBack()
between Get()
and Set()
. This would mean that the index i
might point to a different location/entry. We somehow need to ensure that getting and setting the entry is atomic. The only way that I can think of right now that would achieve that is to add RingArray<T>::FindAndReplace(predicate, newData/Element/Entry)
where predicate
is a callable that takes a T const &
and returns something convertible to bool
.
Add a new RingArray programStatusHistory variable, and a new update() method for it.
The only missing thing is to test that the fram is correctly written, i.e something like `Require(fram::ram::memory[address] == value)`.
Remove useless variables and clang-format comments.
Remove dependency to Edu module.
- Shorten `FindAndReplace()` signature - Rename `ComputeSize()` to `FramSize()` - Add some comments
Also fix the test since the cache entries remain even after resetting the FRAM memory to zero.
Since `RingArray` uses the Thread-safe Interface pattern, public functions must not call other public functions because that would lead to recursive locking. Rodos' semaphores might support that but I think it is cleaner and easier to reason about if we stick to the pattern and ensure that we only ever enter the semaphore once. `FindAndReplace()` used `Get()` and `Set()` so I had to make private implementation functions (`DoGet()` and `DoSet()`) for them that do all the work except for creating the `ScopeProtector`.
There was a warning about a narrowing conversion from 64 to 32 bits, so I changed the underlying type of `RingArray::RingIndex` from `std::size_t` to that of `fram::Size` which is `std::uint32_t`.
516a364
to
17a700c
Compare
Description
Move EDU program status history to FRAM by using the
fram::RingArray
to store program status history entries. Additionally, improve the unit test forRingArray
with the addition of a custom typeRingArray
test case.Fixes #204