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 provides 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, which offer 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 needs to be protected with locks when it is 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.
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.
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.
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.
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.
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.
Returns a value that 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.
queue - Queue selected to test.
int - Returns 1 if the queue is empty or 0 if the queue is not empty.
queue - Queue selected to test.
void * - Returns 1 if the queue is full or 0 if the queue is not full.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.