You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/05/22 05:14:02 UTC

[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #3626: libc: Move pthread stuff to userspace

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


   @no1wudi Are you interested in finishing this job?  That is, fixing on_exit() and atexit() callbacks so that they execute in user mode in all build modes?  Logically this would be a very similar job:  task_startup() and task exits would have to be moved to libs/libc and the callbacks would have to be re-architected so that the call back function points and parameters lie in TLS and the functions are called in some user-space task exit logic.
   
   This, however, is more complex for a couple of reasons:
   
   1. on_exit() and atexit() processing is more entangled task_exithook().  However, I think that that entanglement is no longer necessary.  I think it is an artifact from an older design.  It should be okay to move those callbacks to the beginning of the exit sequence in the current design.  Hmm.. is there some reason why the exit callbacks should not execute while there could be pthreads running in an SMP configuration?  There are a few things to think about.
   2. The task_startup() function is the same for the FLAT and PROTECTED builds, but works differently in the KERNEL build.   In that case, a crt0.o file it linked at the beginning of th problem.  See for example: https://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/armv7-a/crt0.c
   3. There are several ways to exit: exit(), task_delete(), task_reset(), assert(), abort(), .... others?
   
   _exit() might also be in that group, but since that is reserved for emergency terminations, it probably does not need to honor the on_exit() / atexit() (In fact, it is not really safe to call _exit() at all in an embedded system since it leaves files open).
   
   There is a block diagram of the exit sequence here:  https://cwiki.apache.org/confluence/display/NUTTX/Task+Exit+Sequence  I am not sure if that is 100% up to date.


-- 
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:
users@infra.apache.org