Re: Merging relayfs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steven Rostedt <[email protected]> wrote:
>
> I will also admit that my ring buffers lost one byte per page.  Because
>  I wanted to save on space with the accounting, and only had a start and
>  end pointer per page.  So when start and end were equal, the buffer was
>  considered empty and when end was one less than start, it was considered
>  full. But since end always pointed to an empty spot, it would still be
>  empty when the buffer was full, thus wasting one byte per page. But to
>  solve this, I would either have to add another variable in the buffer
>  page descriptor (adding at least one byte, but probably 4 bytes) which
>  would just be more waste, or I would have to make a complex system even
>  more complex (ie. adding a flag on the end pointer at the MSB to
>  differentiate between end being empty or filled).

Nope.  Just make the indices 32-bit numbers and let them wrap.

Full:		(tail - head) == size
Empty:		(tail - head) == 0
Add item:	buf[head++ & (size-1)] = item;
Remove item:	buf[tail++ & (size-1)]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux