Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am exactly in this situation: I wrote a library with a global lock (many threads, but only one running at a time in the library) and am refactoring it to support concurrency.</p> <p>I have read books on the subject but what I learned stands in a few points:</p> <ol> <li><strong>think parallel</strong>: imagine a crowd passing through the code. What happens when a method is called while already in action ?</li> <li><strong>think shared</strong>: imagine many people trying to read and alter shared resources at the same time.</li> <li><strong>design</strong>: avoid the problems that points 1 and 2 can raise.</li> <li>never think you can ignore edge cases, they will bite you hard.</li> </ol> <p>Since you cannot proof-test a concurrent design (because thread execution interleaving is not reproducible), you have to ensure that your design is robust by carefully analyzing the code paths and <strong>documenting</strong> how the code is supposed to be used.</p> <p>Once you understand how and where you should bottleneck your code, you can read the documentation on the tools used for this job:</p> <ol> <li>Mutex (exclusive access to a resource)</li> <li>Scoped Locks (good pattern to lock/unlock a Mutex)</li> <li>Semaphores (passing information between threads)</li> <li>ReadWrite Mutex (many readers, exclusive access on write)</li> <li>Signals (how to 'kill' a thread or send it an interrupt signal, how to catch these)</li> <li>Parallel design patterns: boss/worker, producer/consumer, etc (see <a href="http://www.cs.wustl.edu/~schmidt/patterns-ace.html" rel="noreferrer">schmidt</a>)</li> <li>platform specific tools: openMP, C blocks, etc</li> </ol> <p>Good luck ! Concurrency is fun, just take your time...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload