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


   > > I totally agree @codebje 's comment. It's important to implement the per 
task storage to hold the global variables in libc. Yes, nobody really care 
about: different threads may get a new copy of getopt's state, but many other 
functions need per task(not per thread) semantics.
   > 
   > There is a very simply way to do this. You would need new library APIs to 
be able to access TLS data on the main thread. Then using the TLS pointers and 
keys, each thread could simply refer to the same data in the main thread TLS 
from each child thread. So the pointers would be duplicated in each thread's 
TLS array, but there would be only one instance of the allocated data and would 
be shared across all of the threads in the task group.
   
   Yes, but it waste other thread local storage. We can simulate per-task 
variable from per-thread variable, but I don't think this is right approach 
from both the concept and implementation(memory) perspective.
   
   This is the foundation not only to resolve the libc internal implementation 
issue, but also very useful for application which want per task variables plus 
multiple concurrent instances.


-- 
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