Much Better Than Raw Native Threads

The task scheduler manages a thread pool and hides the complexity of native threads. The parallel algorithms (covered in Chapter 3) are all based on the task scheduler interface. The task scheduler is designed to address common performance issues of parallel programming with native threads, specifically those issues listed in Table 9-1. The following subsections of this chapter offer details on each item in the table.

Table 9-1. Problems with raw threads

Problem

Intel Threading Building Blocks approach

Oversubscription

One scheduler thread per hardware thread.

Choice of scheduling policy

Nonpreemptive unfair scheduling.

High coding overhead

Programmer specifies tasks, not threads.

Load imbalances

Work stealing balances load.

Portability

No code changes should be needed to use with any C++ compiler on any operating system.

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.