Hi
I am actually trying to understand the concept of queues from the TI-workshop lab.
void mailbox_queue(void)
{
//---------------------------------
// msg used for Mailbox and Queue
//---------------------------------
MsgObj msg; // create an instance of MsgObj named msg
//---------------------------------
// msgp used for Queue only
//---------------------------------
Msg msgp; // Queues pass POINTERS, so we need a pointer of type Msg
msgp = &msg; // init message pointer to address of msg
msg.val = 1; // set initial value of msg.val (LED state)
while(1){
msg.val ^= 1; // toggle msg.val (LED state)
Semaphore_pend(LEDSem, BIOS_WAIT_FOREVER); // wait on semaphore from Timer ISR
//------------------------------
// MAILBOX CODE follows...
//------------------------------
// Mailbox_post (???, &msg, BIOS_WAIT_FOREVER); // post msg containing LED state into the MAILBOX
//------------------------------
// QUEUE CODE follows...
//------------------------------
Queue_put(queue0, (Queue_Elem*)msgp); // pass pointer to Message object via LED_Queue
Semaphore_post (qMsgSem); // unblock Queue_get to get msg
}
}
I this example,
msg.val is toggled and its address (pointer) is posted in the queue.
On the receiver side, the pointer is read on the queue and the corresponding value is off loaded.
But one scenario i am not able to understand is
For Ex:
msg.val=1 and the pointer is put on Queue_put.
On the receiver side, if the msg.val is already changed (as this structure being defined as local) to a different value before the receiver has got the msg.val this would give a wrong result?
Can some one help me understand this.