From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: Implementing poll(2) for Mini-OS? Date: Mon, 18 Feb 2013 18:12:24 +0100 Message-ID: <20130218171224.GL17292@type.bordeaux.inria.fr> References: <1361202056.3825.28.camel@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1361202056.3825.28.camel@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: Daniel De Graaf , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Wei Liu, le Mon 18 Feb 2013 15:40:56 +0000, a =E9crit : > I sent a patch to switch cxenstored's event loop from using select to > using poll several weeks ago, What is the rationale BTW? Efficiency? > My main question is, is it possible to just wrap around select(2) in > Mini-OS to implement poll(2)? (as shown in the conceptual patch) Yes, except that there are evil small differences between poll and select, which we need to take care of. About the 32 fd limitation, it indeed comes from the days when we always had a bounded number of things to open. We need to drop that limitation, but it should be easy, by turning the `files' array into a reallocable pointer. There is just one important thing: the xenbus_event_queue events field has to be made a pointer to a dynamically-allocated queue, otherwise it will get moved by the reallocation and things will go wrong very badly. > +int poll(struct pollfd pfd[], int nfds, int timeout) > +{ ... > + > + /* Timeout in poll is in second. */ > + _timeo.tv_sec =3D timeout; FIXME: timeout is in ms, not sec. > + _timeo.tv_usec =3D 0; Samuel