- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to implement aLong ,low priority task in TBB?
In my application i havesome process tasks ,
and1 very long task that sholud run in the bacground until finished.
The long task should be in low priority and interupted when a process task needs to run.
How do i set the priority of the task?
Can anyone help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to implement aLong ,low priority task in TBB?
In my application i havesome process tasks ,
and1 very long task that sholud run in the bacground until finished.
The long task should be in low priority and interupted when a process task needs to run.
How do i set the priority of the task?
Can anyone help?
When the long low priority task has I/O statements (or other statements that suspend execution) then as Bartolome suggests create an additional thread (not part of TBB pool).
When the long low priority task is completely compute bound then you have two additional options.
1) When the reason for having low priority to this task is for the purpose of permitting other applications to interceed with priority, then when the task starts (top of execute() function) lower your priority. And at bottom of function, restore your priority.
2) When the reason for having low priority task is for the purpose of permitting other tasks in your application to have more run time then you are getting boxed into a corner.
2a) When the other tasks will vary in numbers of threads required (at times using less than number of hardware threads) then oversubscribe the TBB thread pool by one thread and use option 1.
2b) When other tasks will consume computational resources then use other option to create non-TBB thread.
2c) when not running your long low priority task, schedule a NULL task that runs like your long low priority task (lowers priority at start, restores at end) and which performs a loop with Sleep(0) and test for requirement to run long low priority task.
The goal is effective thread subscription.
Jim Dempsey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd suggest combining TBB with some other technique, e.g. Pthreads or Bost threads. One of the threads runs the TBB scheduler and the other one is the low-priority server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to implement aLong ,low priority task in TBB?
In my application i havesome process tasks ,
and1 very long task that sholud run in the bacground until finished.
The long task should be in low priority and interupted when a process task needs to run.
How do i set the priority of the task?
Can anyone help?
When the long low priority task has I/O statements (or other statements that suspend execution) then as Bartolome suggests create an additional thread (not part of TBB pool).
When the long low priority task is completely compute bound then you have two additional options.
1) When the reason for having low priority to this task is for the purpose of permitting other applications to interceed with priority, then when the task starts (top of execute() function) lower your priority. And at bottom of function, restore your priority.
2) When the reason for having low priority task is for the purpose of permitting other tasks in your application to have more run time then you are getting boxed into a corner.
2a) When the other tasks will vary in numbers of threads required (at times using less than number of hardware threads) then oversubscribe the TBB thread pool by one thread and use option 1.
2b) When other tasks will consume computational resources then use other option to create non-TBB thread.
2c) when not running your long low priority task, schedule a NULL task that runs like your long low priority task (lowers priority at start, restores at end) and which performs a loop with Sleep(0) and test for requirement to run long low priority task.
The goal is effective thread subscription.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help,
My case is (2) - Low and high priority tasks in one application,
it's a video processing application with "Process" thread that must be finished ina desired time frame,
And the longlow priority task needs to work "only when time is available" ,
I need the ability to interupt it when new frame arrives.
I hoped that therewill bea solutioninsideTBB ,
i'll have to use something else to prioritze my threads.
thanks,
Barak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help,
My case is (2) - Low and high priority tasks in one application,
it's a video processing application with "Process" thread that must be finished ina desired time frame,
And the longlow priority task needs to work "only when time is available" ,
I need the ability to interupt it when new frame arrives.
I hoped that therewill bea solutioninsideTBB ,
i'll have to use something else to prioritze my threads.
thanks,
Barak
Use Boost.Threads for native threads when you have to. The API is easy and most of it has been incoporated into the C++0x standard.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page