patacongo commented on issue #3868:
URL: 
https://github.com/apache/incubator-nuttx/issues/3868#issuecomment-857702912


   > i suspect it's better to introduce a real per-task-group structure than 
keeping abusing main thread.
   > how do you think?
   
   As I mention above, I think that the root case is the main can exit before 
the last pthread exits in certain race conditions.  So I think that that 
correct solution is to add a reference count so that the main thread data 
persists until the last thread exits.
   
   This logic used to exist in the past.  The task group persisted until the 
last thread exited as determined by a reference count.  That was lost when we 
correct the behavior so that all threads are killed on exit().  The latter 
behavior is the correct one but requires that all threads be killed with 
knife-edge precision.  However, pthread_exit() is inherently a lazy exit and 
the decision needs to be changed to handle a longer, drawn out exit sequence.
   
   This problem has existed for some time.  It will still exist after reverting 
no1wudi's change.  However, the effect before that change was less visible 
since there was no task data that was accessed on exit.
   


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