Example #1
0
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stacksize, int prio)
{
  int code;
  pthread_t tmp;
  struct sys_thread *st = NULL;
  LWIP_UNUSED_ARG(name);
  LWIP_UNUSED_ARG(stacksize);
  LWIP_UNUSED_ARG(prio);

  code = pthread_create(&tmp,
                        NULL,
                        (void *(*)(void *))
                        function,
                        arg);

  if (0 == code) {
    st = introduce_thread(tmp);
  }

  if (NULL == st) {
    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%lx",
                       code, (unsigned long)st));
    abort();
  }
  return st;
}
Example #2
0
/*-----------------------------------------------------------------------------------*/
static struct sys_thread *
current_thread(void)
{
  struct sys_thread *st;
  pthread_t pt;
  pt = pthread_self();
  pthread_mutex_lock(&threads_mutex);

  for(st = threads; st != NULL; st = st->next) {    
    if (pthread_equal(st->pthread, pt)) {
      pthread_mutex_unlock(&threads_mutex);
      
      return st;
    }
  }

  pthread_mutex_unlock(&threads_mutex);

  st = introduce_thread(pt);

  if (!st) {
    printf("current_thread???\n");
    abort();
  }

  return st;
}
Example #3
0
/*-----------------------------------------------------------------------------------*/
static struct sys_thread *
current_thread(void)
{
  struct sys_thread *st;
  uintptr_t pt;
  pt = syscall_mthread_self();
  syscall_mutex_lock(&threads_mutex);

  for(st = threads; st != NULL; st = st->next) {
    if (st->pthread == pt) {
      syscall_mutex_unlock(&threads_mutex);

      return st;
    }
  }

  syscall_mutex_unlock(&threads_mutex);

  st = introduce_thread(pt);

  if (!st) {
    printf("current_thread???\n");
    abort();
  }

  return st;
}
Example #4
0
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(char *name, void __fastcall (* function)(void *arg), void *arg, int stacksize, int prio)
{
  uintptr_t tmp;
  struct sys_thread *st = NULL;

  tmp = syscall_mthread_create_with_arg(function, arg);

  st = introduce_thread(tmp);

  if (NULL == st) {
    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%x",
                       tmp, (int)st));
    abort();
  }
  return st;
}
Example #5
0
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
  int code;
  pthread_t tmp;
  struct sys_thread *st = NULL;
  
  code = pthread_create(&tmp,
                        NULL, 
                        (void *(*)(void *)) 
                        function, 
                        arg);
  
  if (0 == code) {
    st = introduce_thread(tmp);
  }
  
  if (NULL == st) {
    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%x",
                       code, (int)st));
    abort();
  }
  return st;
}