Lines Matching +full:t +full:- +full:head
12 (1) Convenience functions for determining information about power-of-2 sized
16 buffer don't want to share a lock.
27 (*) Measuring power-of-2 buffers.
30 - The producer.
31 - The consumer.
41 (1) A 'head' index - the point at which the producer inserts items into the
44 (2) A 'tail' index - the point at which the consumer finds the next item in
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
51 The head index is incremented when items are added, and the tail index when
52 items are removed. The tail index should never jump the head index, and both
56 Typically, items will all be of the same unit size, but this isn't strictly
58 than 1 if multiple items or variable-sized items are to be included in the
63 Measuring power-of-2 buffers
68 modulus (divide) instruction. However, if the buffer is of a power-of-2 size,
69 then a much quicker bitwise-AND instruction can be used instead.
71 Linux provides a set of macros for handling power-of-2 circular buffers. These
102 (#) Measure the non-wrapping occupancy of a buffer::
110 Each of these macros will nominally return a value between 0 and buffer_size-1,
114 they will return a lower bound as the producer controls the head index,
124 head index.
131 independent and may be made on different CPUs - so the result in such a
152 ------------
158 unsigned long head = buffer->head;
160 unsigned long tail = READ_ONCE(buffer->tail);
162 if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
164 struct item *item = buffer[head];
168 smp_store_release(buffer->head,
169 (head + 1) & (buffer->size - 1));
171 /* wake_up() will make sure that the head is committed before
179 before the head index makes it available to the consumer and then instructs the
180 CPU that the revised head index must be written before the consumer is woken.
186 element currently being read by the consumer. Therefore, the unlock-lock
193 ------------
200 unsigned long head = smp_load_acquire(buffer->head);
201 unsigned long tail = buffer->tail;
203 if (CIRC_CNT(head, tail, buffer->size) >= 1) {
211 smp_store_release(buffer->tail,
212 (tail + 1) & (buffer->size - 1));
223 reloading its cached value. This isn't strictly needed if you can
236 See also Documentation/memory-barriers.txt for a description of Linux's memory