uC/OS Queue Versus FIFO
Posted: Thu Dec 26, 2013 10:00 am
I am trying to get a good grasp of why I would want to utilize FIFOs as opposed to message queues. The uCOSLibrary document doesn't describe much, but after searching around this forum I think I found that the main difference is that the contents of the FIFO structures are copied into the FIFO in a thread-safe way. Queues just pass a single pointer to the structure they are trying to send. This means that FIFOs can pass temporary stack variables while queues can only pass static heap variables (unless it can be gauranteed that the stack variable will still exist when the receive thread gets it, sometimes used with a handshaking member).
Couldn't the latter problem be solved by using the "new" keyword to change your stack struct into a heap struct, passing its address through the queue, and having the receive thread call "delete" after its done with the struct?
I would guess that avoiding struct copying would be more computationally efficient, but I guess I would have to compare the copying-overhead to the new/delete-overhead.
What else should I consider?
Couldn't the latter problem be solved by using the "new" keyword to change your stack struct into a heap struct, passing its address through the queue, and having the receive thread call "delete" after its done with the struct?
I would guess that avoiding struct copying would be more computationally efficient, but I guess I would have to compare the copying-overhead to the new/delete-overhead.
What else should I consider?