Lines Matching refs:buffer
16 buffer don't want to share a lock.
25 (*) What is a circular buffer?
38 First of all, what is a circular buffer? A circular buffer is a buffer of
42 buffer.
45 the buffer.
47 Typically when the tail pointer is equal to the head pointer, the buffer is
48 empty; and the buffer is full when the head pointer is one less than the tail
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.
59 buffer, provided that neither index overtakes the other. The implementer must
61 the buffer and be broken into two segments.
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,
80 (*) Measure the remaining capacity of a buffer:
84 This returns the amount of space left in the buffer[1] into which items
88 (*) Measure the maximum consecutive immediate space in a buffer:
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:
109 the buffer without having to wrap back to the beginning of the buffer.
117 but the consumer may still be depleting the buffer on another CPU and
125 producer may still be filling the buffer on another CPU and moving the
129 emptying the buffer.
144 (1) use a single lock to govern access to both ends of the buffer, thus
145 allowing the buffer to be filled and emptied at the same time; and
149 There are two sides to this: the producer that fills the buffer, and the
150 consumer that empties it. Only one thing should be filling a buffer at any one
151 time, and only one thing should be emptying a buffer at any one time, but the
162 unsigned long head = buffer->head;
164 unsigned long tail = ACCESS_ONCE(buffer->tail);
166 if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
167 /* insert one item into the buffer */
168 struct item *item = buffer[head];
172 smp_store_release(buffer->head,
173 (head + 1) & (buffer->size - 1));
204 unsigned long head = smp_load_acquire(buffer->head);
205 unsigned long tail = buffer->tail;
207 if (CIRC_CNT(head, tail, buffer->size) >= 1) {
209 /* extract one item from the buffer */
210 struct item *item = buffer[tail];
215 smp_store_release(buffer->tail,
216 (tail + 1) & (buffer->size - 1));