[riot-devel] ns3 question about global variable in RIOT
ludwig.ortmann at fu-berlin.de
Thu Feb 27 13:56:18 CET 2014
Hi Daniel & all,
On Thu, Feb 20, 2014 at 06:05:54PM +0100, Emmanuel Baccelli wrote:
> Daniel Camara from the ns3 team (in cc) asked me a question that I thought
> I'd better relay here to gather the most informed opinions:
> "Is there any conceivable way for all global variables in RIOT to be
> declared as thread local? If this could be done adaptation with ns-3 would
> be MUCH easier."
> Any opinion on this question? Or on how to better formulate the question?
It would be possible to extend all of RIOTs global variables with a macro
like RIOTGLOBAL and have that expand to _thread for a ns3 port. Not
really nice, but we could do that.
What I don't really see is the performance gain. Maybe you can shed
some light here.
Thread-local storage requires the threading library to update all
global variables and the context on every thread switch. Not using
threads on the other hand would require the system scheduler to update
the context. To me it appears that there is overhead involved in both
possibilities that probably cancel each other out.
Using processes instead of threads has the benefit of separated
address spaces though. That means that memory errors in RIOT would not
lead to the whole simulation crashing.
Furthermore I suspect running RIOT as a thread might lead to conflicts
with RIOTs own pthread implementation.. maybe someone from that domain
can say something about this.
More information about the devel