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 2023/01/19 01:43:00 UTC

[GitHub] [nuttx] zyfeier commented on pull request #8175: sched/semaphore: increase sem count when holder task exit

zyfeier commented on PR #8175:
URL: https://github.com/apache/nuttx/pull/8175#issuecomment-1396333791

   > @zyfeier
   > 
   > > Increase the sem count when the holder task exit, to avoid lock failure at next time.
   > 
   > Could you explain the lock failure more concretely? Is it possible to detect the failure with ostest?
   
   Here is the test case for this issue, need enable CONFIG_PRIORITY_INHERITANCE and CONFIG_SMP.
   This case will finally stop at` nxmutex_lock(&group->tg_joinlock)`,  and we can see no one is holding
   this lock, but the semcount value is 0.
   
   ```
   static pthread_t g_bench_threads;
   int priority = 98;
   
   static void bench_spawn_helper(void *args)
   {
     UNUSED(args);
     pthread_exit(NULL);
   }
   
   static void thread_test(void)
   {
     struct sched_param param;
     pthread_attr_t attr;
     int policy;
   
     pthread_attr_init(&attr);
     pthread_getschedparam(0, &policy, &param);
     param.sched_priority = priority;
     pthread_attr_setschedparam(&attr, &param);
   
     pthread_create(&g_bench_threads, &attr,
                   (pthread_startroutine_t)bench_spawn_helper, NULL);
     printf("Pthread Create Success!\n");
     pthread_attr_destroy(&attr);
   }
   
   int main(int argc, FAR char *argv[])
   {
     int i = 0;
     for (;;)
       {
         thread_test();
         pthread_cancel(g_bench_threads);
         printf("No.%d -> Test Success!\n", i);
         i++;
       }
   
     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