How can I write a lock free structure?

后端 未结 21 1833
忘了有多久
忘了有多久 2020-12-13 12:57

In my multithreaded application and I see heavy lock contention in it, preventing good scalability across multiple cores. I have decided to use lock free programming to solv

21条回答
  •  轮回少年
    2020-12-13 13:53

    Well, it depends on the kind of structure, but you have to make the structure so that it carefully and silently detects and handles possible conflicts.

    I doubt you can make one that is 100% lock-free, but again, it depends on what kind of structure you need to build.

    You might also need to shard the structure so that multiple threads work on individual items, and then later on synchronize/recombine.

提交回复
热议问题