atomic 64 bit read/write
ManAtWork
Posts: 2,176
in Propeller 2
Is there a way to force a read or write to two consecutive hub RAM longs being executed in two consecutive clock cycles? This would allow atomic access to 64 bit values without having to use locks. A reader would always either see both old values or both new values when another cog writes to them concurrently.
I believe the egg-beater RAM interface could theoretically do this. But a simple wrfast + wflong + wflong sequence doesn't guarantee back-to-back execution. If the first wflong just hits the right slot then the second comes too late and has to wait six (?) cycles for the next 1-out-of-8 slot.
I believe the egg-beater RAM interface could theoretically do this. But a simple wrfast + wflong + wflong sequence doesn't guarantee back-to-back execution. If the first wflong just hits the right slot then the second comes too late and has to wait six (?) cycles for the next 1-out-of-8 slot.
Comments
As long as the writing party does SETQ+WRLONG and the reading parties do SETQ+RDLONG, all using the same Q value and hub address, you effectively get atomic reads and writes of any number of longs (limited by cog RAM size, of course).
Right. It could interrupt the block transfer and cause another 9 clocks to go by before it's able to resume.
"As long as the writing party does SETQ+WRLONG and the reading parties do SETQ+RDLONG, all using the same Q value and hub address, and if the streamer is not running and code is beeing executed in cog or LUT RAM then you effectively get atomic reads and writes of any number of longs (limited by cog RAM size, of course)."
Correct?
> So we have to say...
>
> "As long as the writing party does SETQ+WRLONG and the reading parties do SETQ+RDLONG, all using the same Q value and hub address, and if the streamer is not running and code is beeing executed in cog or LUT RAM then you effectively get atomic reads and writes of any number of longs (limited by cog RAM size, of course)."
>
> Correct?
Yes.