EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #197 background imageLoading...
Page #197 background image
Queues
Memory and Low-level Functions 5-15
5.3 Queues
The QUE module provides a set of functions to manage a list of QUE
elements. Though elements can be inserted or deleted anywhere within the
list, the QUE module is most often used to implement a FIFO list—elements
are inserted at the tail of the list and removed from the head of the list. QUE
elements can be any structure whose first field is of type QUE_Elem. In
Example 5-15, QUE_Elem is used by the QUE module to enqueue the
structure while the remaining fields contain the actual data to be enqueued.
QUE_create and QUE_delete are used to create and delete queues,
respectively. Since QUE queues are implemented as linked lists, queues
have no maximum size. This is also shown in Example 5-15.
Example 5-15. Managing QUE Elements Using Queues
5.3.1 Atomic QUE Functions
QUE_put and QUE_get are used to atomically insert an element at the tail of
the queue or remove an element from the head of the queue. These functions
are atomic in that elements are inserted and removed with interrupts
disabled. Therefore, multiple threads can safely use these two functions to
modify a queue without any external synchronization.
QUE_get atomically removes and returns the element from the head of the
queue, whereas, QUE_put atomically inserts the element at the tail of the
queue. In both functions, the queue element has type Ptr to avoid
unnecessary type casting as shown in Example 5-16.
Example 5-16. Inserting into a Queue Atomically
typedef struct QUE_Elem {
struct QUE_Elem *next;
struct QUE_Elem *prev;
} QUE_Elem;
typedef struct MsgObj {
QUE_Elem elem;
Char val;
} MsgObj;
QUE_Handle QUE_create(attrs)
QUE_Attrs *attrs;
Void QUE_delete(queue)
QUE_Handle queue;
Ptr QUE_get(queue)
QUE_Handle queue;
Ptr QUE_put(queue, elem)
QUE_Handle queue;
Ptr elem;

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals