Unix/Linux Go Back    

NetBSD 6.1.5 - man page for pcq_put (netbsd section 9)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

PCQ(9)				  BSD Kernel Developer's Manual 			   PCQ(9)

     pcq -- producer/consumer queue

     #include <sys/pcq.h>

     pcq_t *
     pcq_create(size_t maxlen, km_flags_t kmflags);

     pcq_destroy(pcq_t *pcq);

     void *
     pcq_get(pcq_t *pcq);

     pcq_maxitems(pcq_t *pcq);

     void *
     pcq_peek(pcq_t *pcq);

     pcq_put(pcq_t *pcq, void *item);

     The machine-independent pcq interface provides lockless producer/consumer queues.	A queue
     (pcq_t) allows multiple writers (producers), but only a single reader (consumer).	The con-
     sumer is expected to be protected by a lock that covers the structure that the pcq_t is
     embedded into (e.g., socket lock, ifnet hwlock).  These queues operate in a first-in, first-
     out (FIFO) manner.  The act of inserting or removing an item from a pcq_t does not modify
     the item in any way.  pcq does not prevent an item from being inserted multiple times into a
     single pcq_t.

     pcq_create(maxlen, kmflags)
	      Create a queue that can store at most maxlen items at one time.  kmflags should be
	      either KM_SLEEP, if pcq_create() is allowed to sleep until resources are available,
	      or KM_NOSLEEP if it should return NULL immediately, if resources are unavailable.

	      Free the resources held by pcq.

	      Remove the next item to be consumed from the queue and return it.  If the queue is
	      empty, return NULL.  The caller must prevent concurrent gets from occuring.

	      Return the maximum number of items that the queue can store at any one time.

	      Return the next item to be consumed from the queue but do not remove it from the
	      queue.  If the queue is empty, return NULL.

     pcq_put(pcq, item)
	      Place an item at the end of the queue.  If there is no room in the queue for the
	      item, return false; otherwise, return true.  The item must not have the value of

     The pcq interface is implemented within the file sys/kern/subr_pcq.c.

     atomic_ops(3), queue(9)

     The pcq interface first appeared in NetBSD 6.0.

BSD					 January 22, 2012				      BSD
Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 08:26 AM.