On Wed, Nov 06, 2013 at 12:47:13AM +0800, Jose Gavine Cueto wrote: > Your'e welcome, and by the way the multiprocess example of simple_mp seems > confusing here: > > static int > lcore_recv(__attribute__((unused)) void *arg) > { > unsigned lcore_id = rte_lcore_id(); > > printf("Starting core %u\n", lcore_id); > while (!quit){ > void *msg; > if (rte_ring_dequeue(recv_ring, &msg) < 0){ > usleep(5); > continue; > } > printf("core %u: Received '%s'\n", lcore_id, (char *)msg); > rte_mempool_put(message_pool, msg); > } > > return 0; > } > > It seems that it isn't allocating msg here, or maybe I'm just missing > something
I understand your question better now, and in that light I think my previous answer was confusing. Let me try to clarify: A ring only holds *pointers* to objects. You enqueue pointers, and dequeue those pointers later, somewhere else, usually in another thread. The allocation/deallocation of the actual objects is none the concern of the ring and its enqueue/dequeue operations. If we take the simple_mp example, the msg dequeued by the lcore_recv() thread is created in mp_command.c and a pointer to that message is enqueued on "send_ring". If you read carefully how the rings are created you'll understand how "send_ring" and "recv_ring" relate to each other. I hope this is a bit clearer, Cyril