Add buf_ring_full utility function, make sure dequeue/enqueue see the latest
indexes
This commit is contained in:
parent
1c6521cfbb
commit
09452a19b0
@ -203,6 +203,12 @@ buf_ring_empty(struct buf_ring *mr)
|
|||||||
return (mr->br_cons == mr->br_prod);
|
return (mr->br_cons == mr->br_prod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
buf_ring_full(struct buf_ring *mr)
|
||||||
|
{
|
||||||
|
return (mr->br_cons == (mr->br_prod + 1));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The producer and consumer are independently locked
|
* The producer and consumer are independently locked
|
||||||
* this relies on the consumer providing his own serialization
|
* this relies on the consumer providing his own serialization
|
||||||
@ -217,6 +223,7 @@ buf_ring_dequeue(struct buf_ring *mr)
|
|||||||
ring = (caddr_t *)mr->br_ring;
|
ring = (caddr_t *)mr->br_ring;
|
||||||
mask = mr->br_size - 1;
|
mask = mr->br_size - 1;
|
||||||
cons = mr->br_cons;
|
cons = mr->br_cons;
|
||||||
|
mb();
|
||||||
prod = mr->br_prod;
|
prod = mr->br_prod;
|
||||||
m = NULL;
|
m = NULL;
|
||||||
if (cons != prod) {
|
if (cons != prod) {
|
||||||
@ -234,9 +241,10 @@ __buf_ring_enqueue(struct buf_ring *mr, void *m)
|
|||||||
|
|
||||||
int prod, cons, mask, err;
|
int prod, cons, mask, err;
|
||||||
|
|
||||||
cons = mr->br_cons;
|
|
||||||
prod = mr->br_prod;
|
|
||||||
mask = mr->br_size - 1;
|
mask = mr->br_size - 1;
|
||||||
|
prod = mr->br_prod;
|
||||||
|
mb();
|
||||||
|
cons = mr->br_cons;
|
||||||
if (((prod + 1) & mask) != cons) {
|
if (((prod + 1) & mask) != cons) {
|
||||||
mr->br_ring[prod] = m;
|
mr->br_ring[prod] = m;
|
||||||
mb();
|
mb();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user