Part Number: BEAGLEBK
Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi,
I want to use queues in my project and was using the following example as reference at this link:

However, I modified this example as per my use case and it looks as this now:
Queue_Elem *elem;
for (elem = Queue_head(myQ);
elem != (Queue_Elem *)myQ;
elem = Queue_next(elem)) {
...
}
Below is a simple example of how to create a Queue, enqueue two elements, and dequeue the elements until the queue is empty:
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/knl/Queue.h>
typedef struct Rec {
Queue_Elem _elem;
Int data;
} Rec;
Int main(Int argc, Char *argv[])
{
Queue_Handle q;
Rec r1;
Rec* rp;
r1.data = 100;
// create a Queue instance 'q'
q = Queue_create(NULL, NULL);
// enQ a couple of records
Queue_enqueue(q, &r1._elem);
//In my app because of some internal process, I change the data field of record and requeue it to queue
r1.data =200;
Queue_enqueue(q, &r1._elem);
// deQ the records and print their data values until Q is empty
while (!Queue_empty(q)) {
rp = Queue_dequeue(q);
System_printf("rec: %d\n", rp->data);
}
System_exit(0);
return (0);
}
Now when I run this, the queue never gets empty and it stays in while loop. My use case is that I want to record a variable value multiple times and every time enqueue it. At the end, I want to dequeue all the values. How can I do this with TI-RTOS?
I hope I am clear with the question.
Regards
Vishav