[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [Problem] about src/xen/include/public/io/ring.h






On Mon, Apr 8, 2013 at 9:32 PM, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> wrote:
On Mon, Apr 08, 2013 at 04:10:49PM +0800, éç wrote:
> Hi,
> Â Â there is a macro in io/ring.h as follows:
>
> 211#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({
> \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
> 212 Â Âunsigned int req = (_r)->sring->req_prod - (_r)->req_cons;
> Â\
> 213 Â Âunsigned int rsp = RING_SIZE(_r) -
> Â\
> 214 Â Â Â Â((_r)->req_cons - (_r)->rsp_prod_pvt);
> Â\
> 215 Â Âreq < rsp ? req : rsp;
> Â\
> 216})
>
> Anyone could explain this?

Which part are you unclear about?

I might be easier if you deconstruct the macro and write out
inthe code. That should give you an idea of what it does.
<hint: Figure out first what RING_SIZE comes out to>

> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel

Â
Why does the macro for response is :Â
207#define RING_HAS_UNCONSUMED_RESPONSES(_r) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
208 Â Â((_r)->sring->rsp_prod - (_r)->rsp_cons)

why not the macro for request written like this:
#define RING_HAS_UNCONSUMED_REQUESTS(_r) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
  ((_r)->sring->req_prod - (_r)->req_cons)


The RING_SIZE means the maximum number for the shared ring to accommodate the req/resp message struct, is that?
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.