summaryrefslogtreecommitdiffstats
path: root/sys/sys/buf_ring.h
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2009-05-07 19:57:14 +0000
committerkmacy <kmacy@FreeBSD.org>2009-05-07 19:57:14 +0000
commit35d0919f73b2c1f73aa5af18b5242d425502e00e (patch)
tree97e9474ea02fb7f8241b919151c81e55a6091fe2 /sys/sys/buf_ring.h
parentfa0fd85038112daf1c7af75811d6cc4764c7788f (diff)
downloadFreeBSD-src-35d0919f73b2c1f73aa5af18b5242d425502e00e.zip
FreeBSD-src-35d0919f73b2c1f73aa5af18b5242d425502e00e.tar.gz
No man page currently exists so comment the two uncommented
non-trivial functions
Diffstat (limited to 'sys/sys/buf_ring.h')
-rw-r--r--sys/sys/buf_ring.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h
index efea85a..0ffe5a2 100644
--- a/sys/sys/buf_ring.h
+++ b/sys/sys/buf_ring.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright (c) 2007,2008 Kip Macy kmacy@freebsd.org
+ * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,10 @@ struct buf_ring {
void *br_ring[0];
};
-
+/*
+ * multi-producer safe lock-free ring buffer enqueue
+ *
+ */
static __inline int
buf_ring_enqueue(struct buf_ring *br, void *buf)
{
@@ -169,8 +172,9 @@ buf_ring_dequeue_mc(struct buf_ring *br)
}
/*
- * Single-Consumer dequeue for uses where dequeue
- * is protected by a lock
+ * single-consumer dequeue
+ * use where dequeue is protected by a lock
+ * e.g. a network driver's tx queue lock
*/
static __inline void *
buf_ring_dequeue_sc(struct buf_ring *br)
@@ -208,6 +212,11 @@ buf_ring_dequeue_sc(struct buf_ring *br)
return (buf);
}
+/*
+ * return a pointer to the first entry in the ring
+ * without modifying it, or NULL if the ring is empty
+ * race-prone if not protected by a lock
+ */
static __inline void *
buf_ring_peek(struct buf_ring *br)
{
OpenPOWER on IntegriCloud