Lines Matching refs:of
9 Linux provides a number of features that can be used to implement circular
10 buffering. There are two sets of such features:
12 (1) Convenience functions for determining information about power-of-2 sized
15 (2) Memory barriers for when the producer and the consumer of objects in the
27 (*) Measuring power-of-2 buffers.
38 First of all, what is a circular buffer? A circular buffer is a buffer of
53 indices should be wrapped to 0 when they reach the end of the buffer, thus
54 allowing an infinite amount of data to flow through the buffer.
56 Typically, items will all be of the same unit size, but this isn't strictly
60 be careful, however, as a region more than one unit in size may wrap the end of
68 Calculation of the occupancy or the remaining capacity of an arbitrarily sized
69 circular buffer would normally be a slow operation, requiring the use of a
70 modulus (divide) instruction. However, if the buffer is of a power-of-2 size,
73 Linux provides a set of macros for handling power-of-2 circular buffers. These
74 can be made use of by:
80 (*) Measure the remaining capacity of a buffer:
84 This returns the amount of space left in the buffer[1] into which items
92 This returns the amount of consecutive space left in the buffer[1] into
94 beginning of the buffer.
97 (*) Measure the occupancy of a buffer:
101 This returns the number of items currently occupying a buffer[2].
104 (*) Measure the non-wrapping occupancy of a buffer:
108 This returns the number of consecutive items[2] that can be extracted from
109 the buffer without having to wrap back to the beginning of the buffer.
112 Each of these macros will nominally return a value between 0 and buffer_size-1,
144 (1) use a single lock to govern access to both ends of the buffer, thus
182 This will instruct the CPU that the contents of the new item must be written
186 Note that wake_up() does not guarantee any sort of barrier unless something
188 there is always one element of the array left empty. Therefore, the
191 pair between consecutive invocations of the consumer provides the necessary
192 ordering between the read of the index indicating that the consumer has
225 Note the use of ACCESS_ONCE() and smp_load_acquire() to read the
242 See also Documentation/memory-barriers.txt for a description of Linux's memory