Тёмный

Lock-free programming with modern C++ - Timur Doumler [ACCU 2017] 

ACCU Conference
Подписаться 16 тыс.
Просмотров 18 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 23   
@TheExstud
@TheExstud 4 года назад
The MPMC queue still has an ABA problem, the CAS might succeed if the read pointer circled around. You could fix it with a generation counter I think.
@ACCUConf
@ACCUConf 4 года назад
Thanks for your comment!
@pbholmen
@pbholmen 3 года назад
That's why you should use absolute indexes. He called it unnecessary complexity, but I'd say it's the other way around, It makes most things simpler, Including telling the difference between full and empty.
@ding7616
@ding7616 2 года назад
Hi is there any reference for how to implement this?
@GiadaLoopMachine
@GiadaLoopMachine 6 лет назад
This is pure gold. Thank you.
@JiveDadson
@JiveDadson 6 лет назад
Start here: 12:24
@BreakinUpBuds
@BreakinUpBuds 5 лет назад
ty.
@brod515
@brod515 4 года назад
@1:15:07 can someone explain why it would get stuck in the while loop. It seems to me that if the 1st reader changed the oldReadPos then compare_exchange_strong will return false for the 2nd reader; but on the second run through the loop the 2nd reader will read from the ringBuffer; the 1st reader would not be there to change the readPos so compare_exchange_strong will return true and break the loop. I don't see why the 2nd reader would be stuck in an infinite loop if no one else is changing the readPos.
@ACCUConf
@ACCUConf 4 года назад
We have forwarded your comment to the speaker :)
@celicom
@celicom 7 лет назад
Wonder why nobody noticed, but the SPMC example is fundamentally wrong as pop(...) returns a reference to an element which could be modified by the writer before the caller of the pop would be able to read/copy it. (Returning a reference is almost always a bad idea in MT env.). Idem, it is not easy, imho, to correct the pop here to fix this problem because if you move the line "returned Element = ringBuffer[oldReadPos];" after the CAS check, then the writer again may be able to modify this value before the reader actually moves it from the buffer. Another minor point is that atomic::compare_exchange_strong (and weak) already replaces expected (=oldReadPos) with the contained (=readPos) value if it returns false, so it is no need to do it twice, as in the example....
@maxmoney7pcgaming
@maxmoney7pcgaming 7 лет назад
If I'm understanding your hesitation; pop() doesn't return a reference to an object in the ring buffer. It takes a reference as a parameter and copies the object from the ring buffer into the external object (that pop() has a reference to) using T::operator=(const T&). The client has its own, safe copy before the CAS check. If the write pointer was able to overtake oldReadPos between T::operator=(const T&), that means another thread has advanced the read pointer. Then the CAS check will fail in this thread and the function will go back to the top of the loop. Let me know if I'm missing something though. It's a great thought experiment. Good point on the exchange changing the value on failure. I never realized that :P
@vaughncato
@vaughncato 7 лет назад
Code at 1:16:56 seems to have an ABA problem in pop(). readPos.compare_exchange_strong could be fooled if the writer and another reader wrap the positions.
@tikabass
@tikabass 7 лет назад
By moving while(true) to the top of the function, it doesn't matter if another access makes indices rolls over.
@junyuan5565
@junyuan5565 4 года назад
I agree. The ABA problem lies in the reuse of the index numbers in each circling of the ring buffer.
@leonid998
@leonid998 3 года назад
44:06, how u make sure no one is using an object ur going to dispose? : D... I understand the talk is just about atomics, but shouldn't completely skip the lifetime management part really, it's important.
@XxxGuitarMadnessxxX
@XxxGuitarMadnessxxX 2 года назад
As I'm just now learning about lock-free and std::atomics (relatively new hobby programmer here), this talk was incredibly informative and my eyes are now large with a thirst for more knowledge on this stuff lol Very well put together in my opinion and was very easy to follow along
@Norbivar
@Norbivar 6 лет назад
Atomic compare_exchange's "otherwise does nothing" is a bit ambigious: if the value of the atomic does not equal expected, then expected will be set to the current value of the atomic. For this, expected is always a reference-type.
@solanacean2812
@solanacean2812 5 лет назад
It's not just a bit ambiguous, but plain misleading.
@seditt5146
@seditt5146 5 лет назад
This could be damaging in a wait loop no? If you set Expected to a value then attempt to while(){} if expected is set to the value the first time around next iteration it will view expected as good and perform the swap... this is not desirable is it?
@seditt5146
@seditt5146 4 года назад
TFW you dig up old code... something is wrong so you come back to the video... you see a comment that might help and expand the replies only to find out you were just as confused 10 months ago as you are now.
@dineshrajant4000
@dineshrajant4000 2 года назад
Can I get these slides for reference?
@ACCUConf
@ACCUConf 2 года назад
Slides for the talks are all available on the ACCU.org archive: accu.org/conf-previous/2017/schedule/
@cbrpnk
@cbrpnk 5 лет назад
You've done it again Timur.
Далее
Se las dejo ahí.
00:10
Просмотров 2,2 млн
titan tvman's plan (skibidi toilet 77)
01:00
Просмотров 5 млн
We finally APPROVED @ZachChoi
00:31
Просмотров 9 млн
Introduction to Lock-free Programming - Tony van Eerd
52:31
Back to Basics: Concurrency - Arthur O'Dwyer - CppCon 2020
1:04:28
Solving distributed systems challenges in Rust
3:15:52
Просмотров 242 тыс.