-
Notifications
You must be signed in to change notification settings - Fork 14
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
Read-only cown v2 #45
Conversation
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.
Here are some initial comments on the PR. I'll do comments on the rest later
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.
Some more comments
17594d2
to
6ec6b0e
Compare
aa5624c
to
f2107f1
Compare
src/rt/sched/cown.h
Outdated
} | ||
|
||
// True means I can write, |
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.
Add comment that "Only one writer can call this."
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.
Here are some comments
src/rt/sched/behaviourcore.h
Outdated
*/ | ||
bool set_next_slot_reader(Slot* n) | ||
{ | ||
// Check that the last two bits are zero |
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.
It would be better to explain the semantic assertion you want to do and not the practical one.
* Assumption - Cowns are allocated at 4 byte boundary. Last 2 bits are | ||
* zero. | ||
*/ | ||
std::atomic<uintptr_t> _cown; |
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.
Is there a reason to change the naming convention? Would a wrapper type work better here?
src/rt/sched/behaviourcore.h
Outdated
status.store(0, std::memory_order_relaxed); | ||
return ( | ||
(status.load(std::memory_order_acquire) & | ||
STATUS_NEXT_SLOT_READER_FLAG) == STATUS_NEXT_SLOT_READER_FLAG); |
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.
Do you need the equality check?
src/rt/sched/behaviourcore.h
Outdated
bool is_wait_2pl() | ||
{ | ||
return (_cown.load(std::memory_order_acquire) & COWN_2PL_READY_FLAG) != | ||
COWN_2PL_READY_FLAG; |
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.
Same as above. Do you need the check?
return true; | ||
} | ||
|
||
uintptr_t old_status_val = |
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.
You probably need some more comments here. It is not clear why you add. Maybe say that this effectively is a fetch and or.
@@ -392,20 +666,30 @@ namespace verona::rt | |||
// Sort the indexing array so we make the requests in the correct order |
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.
We need more comments in the schedule_many behaviour for the read only part
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 think this comment is going to massively restructured by #49, so I would sooner leave that to there.
std::get<0>(i) < std::get<0>(j) : | ||
std::get<1>(i)->cown < std::get<1>(j)->cown; | ||
if (std::get<1>(i)->cown() == std::get<1>(j)->cown()) | ||
if (std::get<0>(i) == std::get<0>(j)) |
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'm not sure I understand the comparison. Add a comment that describes the corner case with one bahaviour with the same cown once with read and once with write accesses.
src/rt/sched/behaviourcore.h
Outdated
*/ | ||
std::atomic<uintptr_t> status; | ||
|
||
Slot(Cown* cown) : cown(cown), status(0) {} | ||
static constexpr uintptr_t STATUS_SLOT_ACTIVE_FLAG = 0x1; |
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.
The term active needs better explanation and probably a different name. How about READ_RESOLVED?
src/rt/sched/behaviourcore.h
Outdated
|
||
if (is_ready()) | ||
if (next_slot() == nullptr) |
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.
Maybe explain what this means since next_slot is overloaded, or use a method call? Maybe a no_successor() call?
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.
Added a no_successors
and used throughout.
Aal::pause(); | ||
} | ||
} | ||
|
||
assert(is_behaviour()); | ||
// Wake up the next behaviour. | ||
if (is_read_only()) |
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.
This is complicated and duplicates code. Would it be possible to simplify? Maybe add methodo to finish the read_only to remove duplicates.
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.
Add a drop_read
to slot to remove duplication.
* Add Data race detection to the example * Alter notification of next_writer Use the read_ref_count to carry whether there is a writer that is expected to be woken up once the readers complete.
420ed8f
to
de3730f
Compare
No description provided.