Skip to Main Content
Intel Threading Building Blocks
book

Intel Threading Building Blocks

by James Reinders
July 2007
Intermediate to advanced content levelIntermediate to advanced
332 pages
10h 4m
English
O'Reilly Media, Inc.
Content preview from Intel Threading Building Blocks

Safe Concurrency for Methods and Libraries

It is recommended that you check the documentation for all the libraries you link with and use only thread-safe libraries in your Threading Building Blocks application. If you use libraries that are not thread-safe, you need to be very sure that they are not used improperly (without proper mutual exclusion) by multiple threads concurrently.

In particular, you should make sure you use the thread-safe runtime libraries in Windows (luckily, failure to do so will cause a compile-time error to help you remember this). Therefore, use the /MDd or /MD compiler option with the Intel or Microsoft compilers, for debug or release builds, respectively.

Warning

Windows runtime libraries come in thread-safe and thread-unsafe forms. Using thread-unsafe versions with Intel Threading Building Blocks could cause undefined results.

In general, you should write your code so it does not need locks. Threading Building Blocks offers algorithms that promote implicit synchronization as an alternative to explicit synchronization with locks. But because that is not always possible, you need some guidance on locks.

The thread-safety rules for non-thread-safe libraries reduce to the following general principle: do not invoke methods or functions concurrently on the same object. Two tasks, or threads, can invoke a method or function concurrently on different objects, but not on the same object. A short way to say this is:you need to provide your own locking, and the kind ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Rezaur Rahman

Publisher Resources

ISBN: 9780596514808Errata Page