Home | History | Annotate | Download | only in kern

Lines Matching defs:pcq

40  *	P2. atomic_cas(&pcq->pcq_pc) loop to advance the producer
43 * P3. atomic_store_release(&pcq->pcq_items[c], item) to publish
50 * C1. atomic_load_relaxed(&pcq->pcq_pc) to get the consumer
55 * C2. atomic_load_consume(&pcq->pcq_items[c]) to get the next
59 * C3. pcq->pcq_items[c] = NULL to consume the next unconsumed but
64 * C5. atomic_cas(&pcq->pcq_pc) loop to advance the consumer
113 * - load/store C5 synchronizes with load/store P2 at &pcq->pcq_pc
128 #include <sys/pcq.h>
134 struct pcq {
166 pcq_advance(pcq_t *pcq, u_int pc)
169 if (__predict_false(++pc == pcq->pcq_nitems)) {
179 pcq_put(pcq_t *pcq, void *item)
187 v = atomic_load_relaxed(&pcq->pcq_pc);
189 p = pcq_advance(pcq, op);
195 } while (atomic_cas_32(&pcq->pcq_pc, v, nv) != v);
203 atomic_store_release(&pcq->pcq_items[op], item);
217 pcq_peek(pcq_t *pcq)
219 const uint32_t v = atomic_load_relaxed(&pcq->pcq_pc);
225 return (p == c) ? NULL : atomic_load_consume(&pcq->pcq_items[c]);
234 pcq_get(pcq_t *pcq)
240 v = atomic_load_relaxed(&pcq->pcq_pc);
246 item = atomic_load_consume(&pcq->pcq_items[c]);
259 pcq->pcq_items[c] = NULL;
260 c = pcq_advance(pcq, c);
271 * load of pcq->pcq_items[c], but that necessarily happens
272 * before the store to pcq->pcq_items[c] to null it out because
277 while (__predict_false(atomic_cas_32(&pcq->pcq_pc, v, nv) != v)) {
278 v = atomic_load_relaxed(&pcq->pcq_pc);
280 c = pcq_advance(pcq, c);
289 pcq_t *pcq;
294 pcq = kmem_zalloc(offsetof(pcq_t, pcq_items[nitems]), kmflags);
295 if (pcq != NULL) {
296 pcq->pcq_nitems = nitems;
298 return pcq;
302 pcq_destroy(pcq_t *pcq)
305 kmem_free(pcq, offsetof(pcq_t, pcq_items[pcq->pcq_nitems]));
309 pcq_maxitems(pcq_t *pcq)
312 return pcq->pcq_nitems;