patacongo edited a comment on pull request #3170:
URL: https://github.com/apache/incubator-nuttx/pull/3170#issuecomment-806718751


   > The problem with that is that every thread will have a copy of all those 
variables even when they are never used. I suggested that we initialize those 
when needed, by only storing a pointer to a struct holding those variables in 
the TLS struct. This allocation could be done once per task (I don't know 
exactly how but I guess it should be possible).
   > 
   > If we store a pointer, we can either use the pthread key approach (more 
standard) with a reserved slot as in this PR or add an explicit extra variable 
(`struct task_globals_s *globals`?). I don't have a strong preference there but 
I'm guessing Greg was going for the standard interface approach.
   
   I basically agree.  I think we need to have a generic, extensible what to 
handle this that does not burden all threads (or at least no more than a 
pointer).  Hardcoding the getopt() variables will burden all threads.  The 
current approach will (typically) only affed the main thread.
   
   This fix for getopt() is a component of  much larger issue that Matias is 
documenting here:  https://github.com/apache/incubator-nuttx/issues/3168 .  A 
dozen or so cases of per-process globals are listed there that should be 
address.  Whatever solution we use, needs to address all of them.  Keeping 
everything is a larger super structure of structures is okay, but I am not 
ready to implement that.
   
   I propose we keep this as it is for now.  All of the TLS management is 
confined to a single file lib_getoptvars.c and so we can easily adapt and 
expand that basic logic as necessary.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to