Passing a pointer, how to know when done?

jkuusama wrote on Wednesday, April 28, 2010:


I want to pass relatively large block of data from many tasks task to one. It doesn’t make sense to pass the data itself, but a pointer to it. Using the queue is obvious for passing the pointer, as several tasks can write to one queue. What would you consider a good method of signaling the sender that the receiving task is done with the data? Thank you for your insight!



rtel wrote on Wednesday, April 28, 2010:

This is really an application decision.  I think there are lots of ways it could be done.

For example, it could be the receiving task that frees the memory so the sending task does not have to do anything.  This is only a suitable solution if the memory is dynamically allocation and memory fragmentation is not an issue.

Alternatively the receiving task could somehow mark the memory (write to the first byte, clear the memory, set a different variable, etc.) once it is finished with it.

There are other options too, the receiver could signal the sender using a queue or semaphore, etc.  The best option depends on your application.