[ofa-general] Re: Is ibv_get_async_event() a blocking call ?

Tang, Changqing changquing.tang at hp.com
Fri Mar 2 09:07:47 PST 2007


Thank you very much.

I wonder if libibverbs can do this way for application and make
ibv_get_async_event() non-blocking. But I will try this way now.

--CQ

 

> -----Original Message-----
> From: Steve Wise [mailto:swise at opengridcomputing.com] 
> Sent: Friday, March 02, 2007 11:01 AM
> To: Tang, Changqing
> Cc: General at lists.openfabrics.org
> Subject: Re: [ofa-general] Re: Is ibv_get_async_event() a 
> blocking call ?
> 
> On Fri, 2007-03-02 at 10:56 -0600, Steve Wise wrote:
> > On Fri, 2007-03-02 at 16:32 +0000, Tang, Changqing wrote:
> > > 
> > > HI, 
> > > 	I did not realize that ibv_get_async_event() is a 
> blocking call, it 
> > > forces me to call it in another thread. But if I don't 
> want to use 
> > > thread in my application, how do I use this function ?
> > > 
> > > 	Thanks.
> > > 
> > > --CQ
> > 
> > You can select() or poll() on the async file descriptor for the QP.
> > 
> > Then you only call ibv_get_async_event() when poll/select indicates 
> > there is something to read.
> 
> Something like this:
> 
> 
> struct my_cxt {
> ...
>         struct ibv_context *context;
>         struct rdma_event_channel *rch;
> ...
> };
> 
> <snip>
> 
>                 fds[0].fd = ctx->rch->fd;
>                 fds[0].events = POLLIN|POLLERR;
>                 fds[1].fd = ctx->context->async_fd;
>                 fds[1].events = 
> POLLHUP|POLLNVAL|POLLPRI|POLLOUT|POLLIN|POLLERR;
>                 if (poll(fds, 2, -1) == -1) {
>                         perror("poll");
>                         exit(1);
>                 }
>                 if (fds[0].revents) {
>                         struct rdma_cm_event *event;
> 
>                         rdma_get_cm_event(ctx->rch, &event);
>                         printf("RDMA CM EVENT %d - %s!\n", 
> event->event, rdma_str_event(event));
>                         rdma_ack_cm_event(event);
> 			...
>                 }
>                 if (fds[1].revents) {
>                         struct ibv_async_event event;
> 
>                         ibv_get_async_event(ctx->context, &event);
>                         printf("ASYNC EVENT %d - %s!\n", 
> event.event_type, ibv_str_async_event(&event));
>                         ibv_ack_async_event(&event);
>                         ...
>                 }
> 
> 
> 



More information about the general mailing list