Thread: High performance thread safe list implementation?

  1. #1
    Registered User
    Join Date
    Jul 2017
    Posts
    1

    High performance thread safe list implementation?

    i need to find an existing high performance thread safe list implementation in C. I started my research some hours ago and hope you guys have some recommendations whether to use a specific list or tipps on how to search for a good one. I will list some criteria i figured out. Most likely i will forget some crucial information, please let me know and i will deliver them.

    1. Each element of the list stores the same Array type
    2. Write/create/delete/read ratio is 100/5/5/1
    3. Many nodes share the list. To prevent race conditions the list has to be thread safe or i manually protect it with a lock.
    4. Elements will be deleted all across the list

    While searching i hardly found C Lists but a lot of Jave Lists. Do you think its Possible and advisable to port Java Lists to C?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    First of all, what counts as "high performance"?
    Like, how many operations per second (you only mentioned the ratios).

    What kind of processor are you targeting? Is it well spec'ed for the task, or is it so woefully underpowered that you're scrabbling for every last uSec?

    Are you sure this isn't a case of premature optimisation disease?

    Next, it seems odd that reading is done so rarely compared to writing.

    How many writer thread(s) do you have, and how many reader thread(s)?

    Lock-Free Data Structures | Dr Dobb's
    Non-blocking algorithm - Wikipedia

    Lists are easy to implement, I never bother looking for pre-made ones which come with baggage of features that don't interest me.

    > or i manually protect it with a lock.
    That's a good place to start.
    Do that, then measure the performance, and then decide if you need to do something.

    > Do you think its Possible and advisable to port Java Lists to C?
    You'll only discover the hidden magic that you'll have to implement yourself along the way.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    83
    Quote Originally Posted by Salem View Post
    Lock-Free Data Structures | Dr Dobb's
    Non-blocking algorithm - Wikipedia

    Lists are easy to implement, I never bother looking for pre-made ones which come with baggage of features that don't interest me.
    Lists are easy to implement, but lock-free lists are not easy to implement. It might be potentially misleading to write the former immediately after URLs for lock-free code =-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. high-performance tree
    By CodeMonkey in forum C++ Programming
    Replies: 0
    Last Post: 07-16-2011, 07:36 PM
  2. Replies: 11
    Last Post: 06-09-2010, 07:31 PM
  3. Thread safe double linked list
    By ShwangShwing in forum C Programming
    Replies: 7
    Last Post: 06-02-2009, 10:55 AM
  4. thread safe in my code to manipulate List?
    By George2 in forum C# Programming
    Replies: 8
    Last Post: 05-01-2008, 06:57 AM
  5. High-performance call to runtime target.
    By CornedBee in forum C++ Programming
    Replies: 3
    Last Post: 09-01-2006, 06:25 PM

Tags for this Thread