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 2022/06/03 17:44:51 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6337: Refine the implementation of TLS

xiaoxiang781216 commented on code in PR #6337:
URL: https://github.com/apache/incubator-nuttx/pull/6337#discussion_r889197129


##########
libs/libc/pthread/pthread_keycreate.c:
##########
@@ -70,23 +72,46 @@
 int pthread_key_create(FAR pthread_key_t *key,
                        CODE void (*destructor)(FAR void *))
 {
-  int tlsindex;
+  FAR struct task_info_s *info = task_get_info();
+  int candidate;
+  int ret;
 
   DEBUGASSERT(key != NULL);
+  DEBUGASSERT(info != NULL);
 
-  /* Allocate a TLS index */
+  /* Search for an unused index.  This is done in a critical section here to
+   * avoid concurrent modification of the group TLS index set.
+   */
 
-  tlsindex = tls_alloc(destructor);
+  ret = _SEM_WAIT(&info->ta_sem);

Review Comment:
   Three reasons I want to keep the current change:
   
   1. The old code doesn't handle EINTR too
   2. Many other place use semaphore as lock without checking EINTR
   3. @anjiahao1 is preparing the patch to convert all item 2 to mutex
   
   So, I prefer we fix the problem in a unified(not adhoc) approach.



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

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org