Tbb: What Is a Master Thread?
In the Docs for Tbb, There Is a Note About Reserving Slots for 'Master' Threads in an Arena: a Master Thread Can Join Any Thread 'Slot' in an Arena, but Worker...
In the docs for TBB, there is a note about reserving slots for 'master' threads in an arena:
A master thread can join any thread 'slot' in an arena, but worker threads cannot join the slot reserved for a master thread. Also, a task arena is allowed more than one master slot. So far so good. What is not clear to me, is what exactly does being a master thread entail? Is it "just" the main application thread? If so, how can there be more than one master thread?
1 Answer
Conceptually, the term "master thread" refers to any application thread that starts a parallel job. In contrast, a "worker thread" is a TBB-created thread which helps master threads process their job.
Specifically for task_arena, master threads submit jobs via the public API of the class, while worker threads join an arena through the internal interface.
A worker thread that joined an arena from inside can also become a master thread in another arena, in case a task it executes in the first arena calls task_arena::execute().