C H A P T E R 5 |
Fast Queue API |
This chapter describes the Fast Queue API functions. Topics include:
The Fast Queue API provide a facility where threads can exchange or pass data in a first-in-first-out (FIFO) order. This API provides routines for creating and using fast queues, a fast communication mechanism between two or more threads. The fast queues are based on circular buffers and is an advantage over teja queues that are for one consumer and one producer. The fast queues are poll-driven and are more efficient for high packet rates. The fast queue API is not thread safe and need to be protected with locks when they are used by more than one consumer or producer.
The API functions are defined in fastq.h located in the src/dev/net/include directory of the SUNWndps package.
This function creates a new instance of the fast queue. The function yields the CPU for a few cycles by executing a long latency instruction when the queue is full.
fastq_t fastq_create(size_t size)
size - Size of the queue. Required size is the power of 2.
fastq_t - Returns a fast queue instance or NULL if it fails.
This function enqueues a node pointer into the fast queue. If -1 is returned, the queue is either full or some other error has occurred.
node - Pointer to the node to enqueue.
int - Returns 0 if successful or -1 if it fails.
This function dequeues a pointer to a node from the queue. The function yields the CPU for a few cycles by executing a long latency instruction when the queue is empty.
queue - Queue selected for dequeue.
void * - Returns a pointer to the dequeued node or NULL if the queue is empty.
This function enqueues a node pointer into the fast queue. If -1 is returned, the queue is either full or some other error has occurred.
fastq_enqueue_noyield(queue,node)
queue - Queue selected for dequeue.
node - Pointer to the node to enqueue.
int - Returns 0 if successful or -1 if it fails.
This function dequeues a pointer to a node from the queue.
queue - Queue selected for dequeue.
void * - Returns a pointer to the dequeued node or NULL if the queue is empty.
This function returns a value which is the depth of the queue at a given point of time.
queue - Queue requested to obtain size.
int - Returns the number of elements in the queue or 0 if empty.
This function checks if the queue is empty.
queue - Queue selected to test.
int - Returns 1 if the queue is empty or 0 if the queue is not empty.
This function checks if the queue is full.
queue - Queue selected to test.
void * - Returns 1 if the queue is full or 0 if the queue is not full.
Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.