Esempio n. 1
0
/** Wrapper function around the real thread function. Posts the semaphore
  * when completed.
  */
static int vcos_thread_wrapper(void *arg)
{
   void *ret;
   VCOS_THREAD_T *thread = arg;

   vcos_assert(thread->magic == VCOS_THREAD_MAGIC);

   thread->thread.thread = current;

   vcos_add_thread(thread);

#ifdef VCOS_WANT_TLS_EMULATION
   vcos_tls_thread_register(&thread->_tls);
#endif

   if (thread->legacy)
   {
      LEGACY_ENTRY_FN_T fn = (LEGACY_ENTRY_FN_T)thread->entry;
      fn(0,thread->arg);
      ret = 0;
   }
   else
   {
      ret = thread->entry(thread->arg);
   }

   thread->exit_data = ret;

   vcos_remove_thread(current);

   /* For join and cleanup */
   vcos_semaphore_post(&thread->wait);

   return 0;
}
static void vcos_thread_wrapper(int argc, void *arg)
#endif
{
   int i;
   void *ret;
   VCOS_THREAD_T *thread = (VCOS_THREAD_T *)arg;

   vcos_assert(thread->magic == VCOS_THREAD_MAGIC);

#ifdef VCOS_WANT_TLS_EMULATION
   vcos_tls_thread_register(&thread->_tls);
#endif

   if (thread->legacy)
   {
      LEGACY_ENTRY_FN_T fn = (LEGACY_ENTRY_FN_T)thread->entry;
      fn(0,thread->arg);
      ret = 0;
   }
   else
   {
      ret = thread->entry(thread->arg);
   }

   // call termination functions
   for (i=0; i<VCOS_MAX_EXIT_HANDLERS; i++)
   {
      if (thread->at_exit[i].pfn) {
         thread->at_exit[i].pfn(thread->at_exit[i].cxt);
      }
   }

   thread->exit_data = ret;
   vcos_semaphore_post(&thread->wait);
}
Esempio n. 3
0
static void _task_timer_expiration_routine(void *cxt)
{
   VCOS_THREAD_T *thread = (VCOS_THREAD_T *)cxt;

   vcos_assert(thread->orig_task_timer_expiration_routine);
   thread->orig_task_timer_expiration_routine(thread->orig_task_timer_context);
   thread->orig_task_timer_expiration_routine = NULL;
}