tbb::task priority and kill task

tbb::task priority and kill task

Hi,

I am working on a socket application, my app is receiving very fast packets and i have to process and replay each packet within specific time (say 100 milliseconds). i am adding every packet to a queue, a thread is picking a packet and executing a tbb::task to process packet. i have 16 cores, and not able to process all packets in given time. 

my question is can i change task priority to high or kill task  which is not started in 50 ms and execute new task ?

what i am doing in my queue processing thread is:

while(1)

packet* p=q.pop();

process_packet* task = new(tbb::task::allocate_root()) process_packet(this,p);

tbb::task::spawn(*task);   

 

}

 

class process_packet: public tbb::task                                                                                                                                                                                  

{

public:                                                                                                                                                                                                          

process_packet(Parent *pPtr,Packet* pData)                                                                                                                                                                                          

: pParent(pPtr),

pPacket(pData)

{                                                                                                                                                                                                            

}                                                                                                                                                                                                            

tbb::task* execute()                                                                                                                                                                                           

{       

.....

 

processing...

.....

send reply..

 

 

return 0;                                                                                                                                                                                                  

}                                                                                                                                                                                                            

private:                                                                                                                                                                                                         

Parent* pParent;        

Packet* pData;

};

 

another question ,is it right approach to process socket packets, i don't know how much packets i will receive.

 

Thanks & Regards,

 

Ejaz

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Ejaz,

I do not see whether wait_for_all is called somewhere. TBB library does not guarantee processing of spawned tasks until that moment.

TBB library has priority support (please see the documentation) but we do not recommend using it because it involves higher overheads which are not always justified since in most of the time the semantics of the workload could be changed towards better use of the library features.

As an example, I would also recommend to try splitting the processing of each packet onto several tasks to extract more parallelism from the system. Consider use of TBB Flow Graph feature because it is a good match for such sporadic (not known in advance) semantics.

Regards,

Aleksei

Hi Fedotoy,

Thank for hints i will try TBB Flow Graph feature, i forgot to add wait_for_all in my post.

 

Thanks and Regard,

Ejaz

 

 

 

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today