- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to build some producer-consumer application in tbb. Earlier I use WaitForSingleObject and Release semaphore function from windows api to synchronization threads. My question is how I can synchronize tbb tasks with mutex and lock?
Is this possible at all? Or there is some other techniquefor this...
Thank you in advance...
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The idea is that you should express all blocking dependencies (excluding predictably short waits) as parent-child relationships between tasks and let the task scheduler figure them out. Otherwise the task scheduler will not know what is going on and leave a hardware thread otherwise unused while the software thread that should be running on it is blocked waiting. If you do have such requirements, the most straightforward approach is to do those things outside of TBB in a dedicated thread (despite the name, tbb::tbb_thread is merely an API to such a thread). But feel free to experiment: it's not always black or white.
(Added) Relating to the title of this thread, "Mutex question": those would be the predictably short waits that I mentioned, for which TBB provides several types of mutexes.
(Added) Relating to the title of this thread, "Mutex question": those would be the predictably short waits that I mentioned, for which TBB provides several types of mutexes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Raf for fast answer. Can you tell me where I can learn more about parent-child relationships?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Read the chapters about the Task Scheduler in the Tutorial and the Reference Manual. Broadly speaking, a parent task becomes eligible for execution only when its children have finished, so expressing dependencies that way is a natural fit for the scheduler.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page