Pools are not inherently thread-safe. Coding techniques: allocating a pool per thread [preferred], guarding pool accesses with spinlocks or pthread mutex / condvar pairs, preallocate and barrier sync [tricky].
Thanks… Dave From: vpp-dev-boun...@lists.fd.io [mailto:vpp-dev-boun...@lists.fd.io] On Behalf Of ??? Sent: Monday, May 22, 2017 10:36 PM To: vpp-dev <vpp-dev@lists.fd.io> Subject: [vpp-dev] [multi-thread] Is it safe to pool_get and pool_put in different thread? I am try to add some test code in vpp. It works well in single-thread mode, but I am confused when I want to use it in a multi-thread with worker threads mode. I will use pool_get in a work thread(different work will use different pool), and pool_put in the main thread. When use pool_get to get a buffer, it may cause a memory resize. If at the same time the main thread use pool_put to relese the buffer, is it possible the main thread is operatoring in the old pool memory. or in a extreme situation, the old memory has been alloced to other, the pool_put will change other's memory? For the pool or vec in vpp, is it just safe when we get and put in the same threadindex? Thanks
_______________________________________________ vpp-dev mailing list vpp-dev@lists.fd.io https://lists.fd.io/mailman/listinfo/vpp-dev