What happens if I declare a Queue of messages instead of a Queue of message pointers ?
I am trying to find out the potential problems of declaring QueueC(message_t, 8) instead of QueueC(message_t*, 8). Then, when I get a packet from the lower layer, I instantiate a new message_t variable, copy the contents of the received message there, queue it and return the buffer to radio Layer. event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t len) { message_t tempMsg; memcpy(&tempMsg,bufPtr,sizeof(message_t); SendQueue.enqueue(tempMsg); return bufPtr; } On 4/13/07, Philip Levis <[EMAIL PROTECTED]> wrote:
On Apr 12, 2007, at 7:25 PM, Mehedi Bakht wrote: > Hi, > > I am a bit confused about why and how the interface Pool should be > used when using the interface Queue (TinyOS 2.x). Any comment/ > explanation will be really appreciated. > The two are completely separate. It just happens to be that some use cases require that you use both of them. A Queue gives you a fixed-length queue of type <t>. For example, a transmission queue is a Queue<message_t*>, that is, a queue of pointers to message buffers. You would instantiate it an 8-deep send queue as a QueueC(message_t*, 8). A Pool is a fixed-size memory pool of type <t>. For example, a pool of message buffers is a Pool<message_t>, and you instantiate it with PoolC(message_t, 8). It happens to be that packet forwarding layers need both of them: when you receive a packet, you need to allocate one to give back to the radio layer, and you also need to put the received packet into the send queue. Phil
-- Mehedi Bakht Graduate Student Department of Computer Science University of Illinois at Urbana-Champaign
_______________________________________________ Tinyos-help mailing list [EMAIL PROTECTED] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help