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

Convoying and priority inversion

Convoying is a problem that comes up between threads of the same priority and is a concern when using locks and Threading Building Blocks. Convoying occurs when the operating system interrupts a task that is holding a lock. All other tasks must wait until the interrupted task resumes and releases the lock. Fair mutexes can make the situation even worse because if a waiting task is interrupted, all the tasks behind it must wait for it to resume.

To avoid convoying, use atomic operations instead of locks where possible.

Convoying is similar to priority inversion. Priority inversion describes a general case where a lower-priority task holds a shared resource that is required by a higher-priority task. The higher-priority task is therefore blocked until the lower-priority task has released the resource, effectively inverting the relative priorities of the two tasks.

To minimize convoying and priority inversion, use atomic operations if possible. Otherwise, hold any lock as briefly as possible. Precompute whatever you can before acquiring the lock.

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