[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH XTF v4] Implement pv_read_some
On Mon, Jul 24, 2017 at 08:24:15AM +0200, Felix Schmoll wrote: > Implement reading from PV console. Making use of polling. > > Signed-off-by: Felix Schmoll <eggi.innovations@xxxxxxxxx> > > --- > Changed since v3: > * Add to comment: read function blocks if no data available > --- > common/console.c | 26 ++++++++++++++++++++++++++ > include/xtf/console.h | 2 ++ > 2 files changed, 28 insertions(+) > > diff --git a/common/console.c b/common/console.c > index 7cb2361..b1a35f4 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -46,6 +46,32 @@ static size_t pv_console_write_some(const char *buf, > size_t len) > } > > /* > + * Read out data from the pv ring, either until buffer is filled or no > + * more data are available. Might result in partial strings, depending > + * on how xenconsoled passes in data. > + * > + * Will block if no data are available. > + */ > +size_t pv_console_read_some(char *buf, size_t len) > +{ > + size_t s = 0; > + uint32_t cons, prod; > + > + while ( !test_and_clear_bit(pv_evtchn, shared_info.evtchn_pending) || > + (pv_ring->in_cons == pv_ring->in_prod) ) > + hypercall_poll(pv_evtchn); > + > + cons = pv_ring->in_cons, prod = LOAD_ACQUIRE(&pv_ring->in_prod); Andrew pointed out on IRC this will degrade to cons = prod = LOAD_ACQUIRE(...); I failed to spot this earlier. See http://en.cppreference.com/w/c/language/operator_precedence _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |