dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Cyril Cressent <cyril.cressent-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Jose Gavine Cueto <pepedocs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "dev-VfR2kkLFssw@public.gmane.org" <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: preallocation of void ** obj_p of rte_ring_dequeue
Date: Tue, 5 Nov 2013 17:54:13 +0000	[thread overview]
Message-ID: <20131105175413.GB26311@debian> (raw)
In-Reply-To: <CAJ5bv6GcUvNHib02_Xaxs2xaz=J0XaxrqHistnKSQKz5zyYdOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

  parent reply	other threads:[~2013-11-05 17:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 10:15 preallocation of void ** obj_p of rte_ring_dequeue Jose Gavine Cueto
     [not found] ` <CAJ5bv6EVB-oQuVqghaPq+6UQjkiLbhy6x3ascsYZhT_14bBYRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-05 10:33   ` Cyril Cressent
2013-11-05 10:42     ` Jose Gavine Cueto
2013-11-05 11:18     ` Thomas Monjalon
     [not found]       ` <201311051218.27016.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-11-05 16:47         ` Jose Gavine Cueto
     [not found]           ` <CAJ5bv6GcUvNHib02_Xaxs2xaz=J0XaxrqHistnKSQKz5zyYdOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-05 17:54             ` Cyril Cressent [this message]
2013-11-05 23:28               ` Jose Gavine Cueto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131105175413.GB26311@debian \
    --to=cyril.cressent-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=pepedocs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).