patacongo opened a new pull request #1328:
URL: https://github.com/apache/incubator-nuttx/pull/1328


   ## Summary
   
   1. A user-space shim is needed to catch any return from a pthead main 
function and to automatically call pthread_exit() from user space.
   
   Rename pthread_create() in sched/pthread/pthread_create.c to 
nx_pthread_create().  Add one new parameter:  The address of the user-space 
pthread startup function.  Instead of calling the pthread main entry (directly 
or indirectly), pthread_start() would call the pthread startup function, 
passing it the real address of the pthread main function.
   
   The call to pthread_exist would be removed from pthread_startup() and move 
into a new function in user space.
   
   2. Add libs/libc/pthread/lib_pthread_start.c that would contain two trivial 
functions:
   
       static void pthread_startup(pthread_startroutine_t startroutine, 
pthread_addr_t arg)
       {
         pthread_exit(startroutine(arg));
       }
   
       int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
                          pthread_startroutine_t startroutine, pthread_addr_t 
arg)
       {
         return nx_pthread_create(pthread_startup, thread, attr, startroutine, 
arg);
       }
   
   Still to do:
   
   a. Modifiy up_pthread_start so that it takes three parameters:  startup, 
entry, and arg.
   b. Remove pthread_startup function pointer from struct userspace_s; it is no 
longer needed.
   c. Modify how pthread is started in pthread_start() (and 
up_pthread_startup()) so that the startup function is called with the entry and 
arg paramgers.
   d. Remove call to pthread_exit() from pthread_start()
   e. Rename pthread_exit() to nx_pthread_exit().  Remove logic that calls 
pthread_cleanup() functions.
   f. Make nx_pthread_exit() a system call.
   g. Create libc/pthread/pthread_exit() that contains only i) the logic that 
calls the pthread_cleanup functions, and ii) calls the nx_pthread_exit() system 
call.
   h. Extend TLS and pthread-specific data function so that the destructor is 
retained in TLS
   i. Extend pthread_exit() so that it also calls the pthread-specific data 
destructors from user-space.
   
   ## Impact
   
   This PR would effect all logic that uses pthread and, hence, must be well 
verified before merging.
   
   ## Testing
   
   Most testing is performed with sim:ostest which exercises pthread logic 
pretty well.
   
   
   


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


Reply via email to