You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xianglyc (via GitHub)" <gi...@apache.org> on 2024/10/09 07:30:59 UTC

[PR] arch/x86_64: add support for thread_local [nuttx]

xianglyc opened a new pull request, #13973:
URL: https://github.com/apache/nuttx/pull/13973

   ## Summary
   add support for thread_local
   ## Impact
   no impact
   ## Testing
   
   case:
   #include <pthread.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <unistd.h>
   
   #define NUM_THREADS 5
   
   /* Thread-local variable */
   
   __thread int tls_var = 0;
   
   void *thread_function(void *arg)
   {
       int thread_num = *((int *)arg);
   
       /* Initialize the thread-local variable */
   
       tls_var = thread_num;
   
       /* Sleep to simulate some work */
   
       sleep(1);
   
       /* Print the value of the thread-local variable */
   
       printf("Thread %d, tls_var = %d\n", thread_num, tls_var);
   
       /* Modify the thread-local variable */
   
       tls_var += 10;
   
       /* Print the modified value of the thread-local variable */
   
       printf("Thread %d, tls_var after modification = %d\n", thread_num, tls_var);
   
       return NULL;
   }
   
   int main()
   {
       pthread_t threads[NUM_THREADS];
       int args[NUM_THREADS];
       int ret;
       int i;
   
       /* Create threads */
   
       for (i = 0; i < NUM_THREADS; ++i)
         {
           args[i] = i;
           ret = pthread_create(&threads[i], NULL, thread_function, (void *)&args[i]);
           if (ret)
             {
               printf("ERROR: pthread_create() ret= %d\n", ret);
               exit(EXIT_FAILURE);
           }
       }
   
       /* Join threads */
   
       for (i = 0; i < NUM_THREADS; ++i)
         {
           pthread_join(threads[i], NULL);
         }
   
       printf("done\n");
   
       return 0;
   }
   


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


Re: [PR] arch/x86_64: add support for thread_local [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #13973:
URL: https://github.com/apache/nuttx/pull/13973


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


Re: [PR] arch/x86_64: add support for thread_local [nuttx]

Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #13973:
URL: https://github.com/apache/nuttx/pull/13973#issuecomment-2401559789

   [**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
   
   
   
   The PR summary is missing key information such as what code is changed and how it works. The impact section claims "no impact" which is unlikely and needs justification. Testing only provides a code snippet without specifying build hosts, targets, or logs.
   
   **The PR does not meet the NuttX requirements.**
   
   Here's how to improve it:
   
   **Summary:**
   
   * **Expand on the "why":**  What problem does thread_local support solve? What use cases does it enable?
   * **Be specific about the changes:**  Which files are modified? Are you introducing new system calls? Modifying existing threading structures?
   * **Explain the implementation:** How is thread-local storage allocated and accessed? Are you using compiler extensions, platform-specific features, or a generic approach? 
   
   **Impact:**
   
   * **Address all points:**  Even if an item seems non-applicable, state "NO" explicitly.
   * **Justify "no impact" claims:**  For example, if there's truly no user impact, explain why. If the build process doesn't change, mention that it's handled transparently.
   * **Consider potential implications:** Thread-local storage can have performance and memory usage implications.
   
   **Testing:**
   
   * **Provide build host details:** Operating systems, architectures, compilers used for testing.
   * **Specify target details:**  Architectures, boards, and configurations tested on.
   * **Include actual logs:**  Both before and after the changes, showing the difference in behavior.
   
   **Additional Considerations:**
   
   * **Documentation:**  Since this is a new feature, documentation is crucial. Explain how to use thread-local storage in NuttX.
   * **Error Handling:**  How are errors related to thread-local storage (e.g., allocation failures) handled and reported?
   * **Compatibility:**  Are there any compatibility concerns with existing code or future extensions? 
   


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