I'm using TBB combined with Boost.Thread, but I'm not sure I'm using it right. the scenario is as follows:
Our application main's goal is to receive and analyze UDP packets, for that I've used tbb pipeline with several filters (filters
receiving data from the network and filters analyzing the data).
besides that, I have other maintenance and various actions I want to run parallel to the described pipeline, but with lower priority (the pipeline should have the highest priority).
in order to do so I did the following (semi-pseudo code):
boost::thread thr1( boost::bind( &udpPipelineManager::receiveAndHandlePackets, &u1 ) );
boost::thread thr2( boost::bind( &Class1::otherAction1, r1 ) );
boost::thread thr3( boost::bind( &Class2:otherAction2, r2 ) ); ......
thr1 is the thread running the TBB pipeline with many tasks in parallel.
Is this the right way to do it? I have 4 cores, I want the other actions to run on 1 core without distrubing (too much) the pipeline tasks.
**** also, what the threads scheduler policy should be (SCHED_RR, SCHED_FIFO, etc.)?
I don't know what the default is (perhaps it's best to leave all TBB work at default priority), but if you want to affect the priority of TBB work you should use task_scheduler_observer to repeat the action for all worker threads. Also, if any other threads then use TBB, you may run into priority-inversion issues.
can you please elaborate? (example would be best :) )
I didn't understand how the task_scheduler_observer can control the priority of the other tasks/threads?
also, what about the scheduling policy?