[Tinyos-devel] call-by-value vs. -pointer
Jan Hauer
jan.hauer at gmail.com
Thu Jun 12 07:12:20 PDT 2008
I'd like to hear people's opinion about passing
command-/event-parameters by pointer vs. by value, in a situation
where you would like to use call-by-value semantics, but the number of
arguments / their total size is big. Background: some of the 802.15.4
management primitives use a lot of parameters (in some situations 7
parameters with a total of 25 byte) and there is generally a
perfomance penalty when passing them by value over the stack (more
code size, slower execution). One alternative is that the caller
encapsulates the parameters in a struct and passes a pointer to it.
The drawback is that one needs an agreement about when/how long the
pointer is valid. When you have written the callee component yourself
you can make sure that you keep no reference after the return
statement, but when you cannot control the callee (e.g. signal an
event to some app) passing a pointer can be problematic. As long as
the interfaces are not used very frequently, I tend to prefer the
call-by-value approach even if a long list of parameters is passed -
what do other people think?
Jan
More information about the Tinyos-devel
mailing list