On Mon, Mar 13, 2017 at 12:38 PM, Sergiy Kibrik <
sergiy.kib...@globallogic.com> wrote:

> On 03/06/2017 05:24 PM, Sergiy Kibrik wrote:
>
> +    return _interface->in_cons != _interface->in_prod;
>>  }
>>
>>  char XEN_Console::readch() {
>> -    return '\0'; /*TODO: support input */
>> +    XENCONS_RING_IDX cons;
>> +    char c;
>> +    assert(_interface);
>> +    cons = _interface->in_cons;
>> +    c = _interface->in[MASK_XENCONS_IDX(cons, _interface->in)];
>>
>
> I think you should gracefully handle the case where you had a false wakeup
> and called readch() when nothing is available, and return 0 in this case
> (as you can see, LineDiscipline::read_poll handles 0 being returned). I
> guess you need to check if cons is actually beyond prod?
>
>
>
> I will do that.
>
>
> Hi Nadav,
> I've looked through LineDiscipline::read_poll() once more and can't figure
> out the possible case of false wake up — it looks like
> driver->input_ready() predicate should always be checked when thread is
> woken, shouldn't it?
> Can you please describe how false readch() call can sneak in?
>

I think you're right, sorry - indeed read_poll() indeed first wait for
input_ready(), so we shouldn't have any false wakeups if input_ready()
doesn't have false positives.

The check for c == 0 was added in commit
4b18685daa5544e0766195fec9eddd454aac149b. Apparently the readkey()
implementation in kbd.cc (the x86 keyboard driver - not the more usual
serial port) sometimes is forced to return 0 after thinking we had an
event. So read_poll() had to ignore this case. But this is not relevant to
your case.

Nadav.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to