CppCon 2014: Herb Sutter "Lock-Free Programming (or, Juggling Razor Blades), Part II"

  Рет қаралды 50,976

CppCon

CppCon

Күн бұрын

Пікірлер: 29
@FanRRice
@FanRRice 4 жыл бұрын
For those who wondering why although in c++20 std::atomic already became a standard, your code can't be compile if you write as such: gcc & clang don't implement it except msvc :(
@warrenbuckley3267
@warrenbuckley3267 3 жыл бұрын
Damn, I just tested this with GCC 11 and got a static assert that std::atomic requires a trivially copyable type... That sucks..
@sean7235
@sean7235 Жыл бұрын
gcc 12.1 and clang 15 now support this.
@sanjuuyonsai
@sanjuuyonsai 10 жыл бұрын
I was about to write a few lines about how there's a problem with the singly linked list's "push front" and "pop front" not updating p next and p between CAS iterations. But luckily, before posting I checked the docs for "compare exchange weak" and discovered that the first parameter is actually a reference that returns an updated snapshot of "head" in it! :( That's one example where references hide the fact that they may be out-parameters. Anyway, a very good and interesting talk!
@NoNameAtAll2
@NoNameAtAll2 4 жыл бұрын
Reference is IN-OUT parameter Const ref is IN parameter
@Astfresser
@Astfresser 2 жыл бұрын
- What is the progress on the question regarding stack overflow 23:22? It might very well be an actual issue in embedded systems. Also it introduces a failure condition - I would like to know an adequate solution for list remove(item). It seems to be far more complex than the other operations even with shared_ptrs - I also believe that herbs push_front is flawed and races with other push_fronts. The problem is that when two tasks queue up before the CAS and pick up head, both p->next will point to the same node previously stored in head (two atomic_loads will happen beside each other). p->next should be updated within the CAS-loop to consider the other node (who won the race) or this node will lose its pointer right away after the next CAS and get deleted.
@dosomething3
@dosomething3 7 жыл бұрын
48:51 "divider = divider->next; " - but in the ctor we initialized: "divider = Node(T())".
@schulmastery
@schulmastery 6 жыл бұрын
you forgot the new keyword
@warrenbuckley3267
@warrenbuckley3267 3 жыл бұрын
I'm curious if there would be an issue if we returned an aliased shared_ptr from the pop_front member function.
@Jackmccallumlols
@Jackmccallumlols 9 жыл бұрын
Shared Pooter
@seditt5146
@seditt5146 5 жыл бұрын
Dude, I came to the comments only because I knew I could not be the only person that drove nuts as he kept saying it. Is it suppose to be called a putter or something? Is he just calling it 'p' 't' 'r' and sounding it out phonically? What gives because that shit drives me crazy.
@toryvindmoe6794
@toryvindmoe6794 4 жыл бұрын
@@seditt5146 it's a shared_ptr. You may want it to be a pointer, but that doesn't make it one.
@93Mosfet
@93Mosfet 2 жыл бұрын
At 38:00 I think is Fedor Pikus asking the question
@jithintc4200
@jithintc4200 3 жыл бұрын
@24:24 can reference be null/nullptr ? References aren't pointers right ? Or is it possible for references to be nullptr ?
@ekimr90
@ekimr90 9 жыл бұрын
If a reference being passed into a function isn't const, it's usually safe to assume that it's an output parameter. At least that's my thought on it.
@phillipratzloff8923
@phillipratzloff8923 6 жыл бұрын
Herb, if you’re monitoring this I’d like to know how a couple of statements you made turned out. 36:18 "It is an open question, including at the standards meeting on Thursday, whether atomic shared_ptr can be written to be lock-free." Can it be atomic? 36:45 I was given an action item on Thursday, between now and November, to try to go put together a benchmark that actually shows it can be competitive or better ….” Is it competitive (faster)?
@perekman3570
@perekman3570 4 жыл бұрын
The atomic shared_ptr specialization is coming in C++20.
@warrenbuckley3267
@warrenbuckley3267 3 жыл бұрын
@@perekman3570 It's been implemented in MSVC but not gcc or clang.
@eiroo5192
@eiroo5192 2 жыл бұрын
In the bonus slides (e.g. 49:02) : the consumer releases its "lock" potentially twice. Isn't that inherently unsafe? Isn't it possible that _this_ consumer does it's second release while the lock is effectively already held by the next consumer (that isn't ready for a release yet)? What is it that I don't understand here?
@myname356
@myname356 Жыл бұрын
Unless I'm missing something, in the line below the first release the function returns already. So you would never release twice in this code.
@origamibulldoser1618
@origamibulldoser1618 10 жыл бұрын
Reference counting the entire list? ... So it's lock free, and should scale well, but has a higher baseline from the reference counting?
@dang5402
@dang5402 3 жыл бұрын
What about double linked lists ? It is so mch hurder I can't even know where to start from.
@sanjuuyonsai
@sanjuuyonsai 9 жыл бұрын
But you don't see that at the calling site, only if you see the called function's signature or documentation.
@GeorgeTsiros
@GeorgeTsiros 6 жыл бұрын
but why is head "shared data"? Doesn't each slist instance get its own head?
@foxtrotromeo4876
@foxtrotromeo4876 5 жыл бұрын
sure, but one slist instance is used in multiple threads. if two threads call pop or push simultaneous, they both access head through that one instance and hence head is shared between the two threads. here, "shared" is defined as multiple threads using it, not multipe objects or datastructures use it.
@sanjuuyonsai
@sanjuuyonsai 10 жыл бұрын
There you go. After making it look less like sourcecode, the error changed to "too long", and I had to shorten it a bit. Censorship sucks. Especially if it's done automatically with obscure rules.
@sanjuuyonsai
@sanjuuyonsai 10 жыл бұрын
Interesting. I tried posting something but only got "Error, try again"
@vladimir4c
@vladimir4c 4 жыл бұрын
Constructing shared_ptr for each push... the performance would be worse then the lock-based implementation
@sanjuuyonsai
@sanjuuyonsai 10 жыл бұрын
test
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 39 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 33 МЛН
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 9 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 12 МЛН
CppCon 2015: Andrei Alexandrescu “std::allocator...”
1:12:27
Introduction to Lock-free Programming - Tony van Eerd
52:31
NDC Conferences
Рет қаралды 10 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 836 М.
17. Synchronization Without Locks
1:20:10
MIT OpenCourseWare
Рет қаралды 33 М.
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 39 МЛН