pussuw commented on PR #6197:
URL: https://github.com/apache/incubator-nuttx/pull/6197#issuecomment-1134237202

   Now there are still two open questions:
   1. Where is the part prior to the call to _exit() supposed to go now ? There 
are now two definitions of exit() and this one must be removed, but there is 
work that needs to be done prior to _exit().
   ```
   void exit(int status)
   {
     FAR struct tcb_s *tcb = this_task();
   
     /* Only the lower 8-bits of status are used */
   
     status &= 0xff;
   
   #ifdef HAVE_GROUP_MEMBERS
     /* Kill all of the children of the group, preserving only this thread.
      * exit() is normally called from the main thread of the task.  pthreads
      * exit through a different mechanism.
      */
   
     group_kill_children(tcb);
   #endif
   
   #if !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
     /* Recover any mutexes still held by the canceled thread */
   
     pthread_mutex_inconsistent(tcb);
   #endif
   
     /* Perform common task termination logic.  This will get called again later
      * through logic kicked off by _exit().  However, we need to call it before
      * calling _exit() in order to handle atexit() and on_exit() callbacks and
      * so that we can flush buffered I/O (both of which may required
      * suspending).
      */
   
     nxtask_exithook(tcb, status, false);
   
     /* Then "really" exit.  Only the lower 8 bits of the exit status are
      * used.
      */
   
     _exit(status);
   }
   ```
   2. What do I do about this, this no longer compiles ? @Ouss4 ?
   ```
   static void *esp_thread_semphr_get(void)
   {
     int ret;
     int i;
     void *sem;
     struct tcb_s *tcb = this_task();
     struct task_group_s *group = tcb->group;
   
     for (i = 0; i < CONFIG_SCHED_EXIT_MAX; i++)
       {
         if (group->tg_exit[i].func.on == esp_thread_semphr_free)
           {
             break;
           }
       }
   
     if (i >= CONFIG_SCHED_EXIT_MAX)
       {
         sem = esp_semphr_create(1, 0);
         if (!sem)
           {
             wlerr("ERROR: Failed to create semaphore\n");
             return NULL;
           }
   
         ret = on_exit(esp_thread_semphr_free, sem);
         if (ret < 0)
           {
             wlerr("ERROR: Failed to bind semaphore\n");
             esp_semphr_delete(sem);
             return NULL;
           }
       }
     else
       {
         sem = group->tg_exit[i].arg;
       }
   
     return sem;
   }
   ```


-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to