On Wed, Jun 26, 2013 at 11:18 AM, Maurizio Lombardi
<[email protected]> wrote:
> Probably because you would still need an external lock most of the
> times, example:
>
> while (!fifo.isFull())
>       fifo.push(data);
>
> is a potential race condition even if the individual methods are
> thread safe, you need to protect it
> with a mutex:
>
> fibril_mutex_lock();
>
> while (!fifo.isFull())
>       fifo.push(data);
>
> fibril_mutex_unlock();

that depends on the API.
you can have push return EOVERFLOW (or block) if full and do:
while (fifo.push(byte));

or enable multibyte push if you need all of the data to be pushed atomically
fifo.push(data, size);

> mmm, you are right, no need to move the i8042 circular buffer to libc...
> It could be built on top of fifo.h maybe
>
> Oh well, fifo.h is really a barebone version of a fifo... It doesn't
> check for overflows/underflows and
> it does not even raise an error if the initialization fails.
>
> It needs to be improved a little bit to be usable.

yes. I think the kernel use-case can use fifo.count instead of
asids_allocated, too.

jan

_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel

Reply via email to