Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'll second mghie's advice: thread safety is designed in. Read about it anywhere you can.</p> <p>For a really low level look at how it is implemented, look for a book on the internals of a real time operating system kernel. A good example is <a href="http://www.amazon.com/gp/search?index=books&amp;linkCode=qs&amp;keywords=1578201039" rel="nofollow noreferrer"><strong>MicroC/OS-II: The Real Time Kernel</strong></a> by Jean J. Labrosse, which contains the complete annotated source code to a working kernel along with discussions of why things are done the way they are.</p> <p><strong>Edit</strong>: In light of the improved question focusing on using a RTL function...</p> <p>Any object that can be seen by more than one thread is a potential synchronization issue. A thread-safe object would follow a consistent pattern in every method's implementation of locking "enough" of the object's state for the duration of the method, or perhaps, narrowed to just "long enough". It is certainly the case that any read-modify-write sequence to any part of an object's state must be done atomically with respect to other threads.</p> <p>The art lies in figuring out how to get useful work done without either deadlocking or creating an execution bottleneck. </p> <p>As for finding such problems, testing won't be any guarantee. A problem that shows up in testing can be fixed. But it is extremely difficult to write either unit tests or regression tests for thread safety... so faced with a body of existing code your likely recourse is constant code review until the practice of thread safety becomes second nature.</p>
 

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