Howdy, > What is a pool here? What does pool.get() and pool.put() mean? My guess is > pool is like a heap; get() and put() is similar to new and delete...
Exactly. A pool is simply a heap managed by the OS and statically allocated at build time. Looking in CtpP.nc we can find: ---- components new PoolC(message_t, FORWARD_COUNT) as MessagePoolP; ---- This is creating a new pool that will be called MessagePoolP with enough room for FORWARD_COUNT number of message_t structures. > Why do we need newMsg from MessagePool? It seems we just return an all > zero newMsg if everything goes well. This is called buffer swapping. The caller passes a complete message into CtpForwardingEngineP. At some point in the future, CtpForwardingEngineP will forward that message into the network. Until then it needs to hold onto it and does so by placing the message in a queue. Since this message is being held onto until it is forwarded, the caller should not modify the message until it has been forwarded. Rather than blocking the caller while everyone waits for the message to be forwarded, CtpForwardingEngineP returns a new message that the caller can do its job with. The caller gave CtpForwardingEngineP one message_t and CtpForwardingEngineP gave (a different) message_t back to the caller. Peace, -Roy _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
