From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Cressent Subject: Re: preallocation of void ** obj_p of rte_ring_dequeue Date: Tue, 5 Nov 2013 17:54:13 +0000 Message-ID: <20131105175413.GB26311@debian> References: <20131105103325.GA25808@debian> <201311051218.27016.thomas.monjalon@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "dev-VfR2kkLFssw@public.gmane.org" To: Jose Gavine Cueto Return-path: Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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