patacongo commented on pull request #3626: URL: https://github.com/apache/incubator-nuttx/pull/3626#issuecomment-829256289
There is logic on the branch feature/pthread-user that also implements moving pthread_create and pthread_exit to libs/libc/pthread. See https://github.com/apache/incubator-nuttx/tree/feature/pthread-user and PR #1328. That logic is incomplete, however, but it is interesting to compare the technical approach. The primary thing is that: 1. The pthread_create() in sched./pthread was changed to: ``` int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t entry, pthread_addr_t arg) ``` And 2. The new pthread_create() in libs/libc/pthread passes the address of the pthread startup function: ``` int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t pthread_entry, pthread_addr_t arg) { return nx_pthread_create(pthread_startup, thread, attr, pthread_entry, arg); } ``` That keeps things simple. The primary objective here was: 1. To eliminate security problems when pthread_cleanup_popall() is called when the pthread exits: See Issue #1263 and #1328. And 2. Implement pthread thread-specific data destructors (mentioned in #1328) If/when this PR is merged, I will remove the branch, and close the issue and PR. -- 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]
