Exemple #1
0
int
main()
{
    pthread_t alloc_pth[N_ALLOC_TH], gcollect_pth;
    int i, err;

    cuoo_init();
    _obj_type = cuoo_type_new_opaque_hcs(NULL, sizeof(cu_word_t));

    err = GC_pthread_create(&gcollect_pth, NULL, _gcollect_proc, NULL);
    if (err) _fail(err, "GC_pthread_create");

    for (i = 0; i < N_ALLOC_TH; ++i) {
	err = GC_pthread_create(&alloc_pth[i], NULL, _alloc_proc, &i + i);
	if (err) _fail(err, "GC_pthread_create");
    }
    for (i = 0; i < N_ALLOC_TH; ++i) {
	err = GC_pthread_join(alloc_pth[i], NULL);
	if (err) _fail(err, "GC_pthread_join");
    }

    err = GC_pthread_join(gcollect_pth, NULL);
    if (err) _fail(err, "GC_pthread_join");

    return 2*!!cu_test_bug_count();
}
int main (void)
{
  int i;
  GC_INIT ();

# ifdef GC_SOLARIS_THREADS
    pthread_key_create (&key, on_thread_exit);
# else
    pthread_once (&key_once, make_key);
# endif
  for (i = 0; i < NTHREADS; i++) {
    pthread_t t;

    if (GC_pthread_create(&t, NULL, entry, NULL) == 0) {
      void *res;
      int code = (i & 1) != 0 ? GC_pthread_join(t, &res)
                                : GC_pthread_detach(t);

      if (code != 0) {
        fprintf(stderr, "Thread %s failed %d\n",
                (i & 1) != 0 ? "join" : "detach", code);
        exit(2);
      }
    }
  }
  return 0;
}
Exemple #3
0
void * mz_proc_thread_wait(mz_proc_thread *thread) {
  void *rc;
#ifdef WIN32
  WaitForSingleObject(thread->threadid,INFINITE);
  rc = proc_thread_self->res;
  CloseHandle(thread->threadid);
#else
#   ifdef NEED_GC_THREAD_OPS
  GC_pthread_join(thread->threadid, &rc);
#   else
  pthread_join(thread->threadid, &rc);
#   endif
#endif

  if (!--thread->refcount)
    free(thread);
  
  return rc;
}
Exemple #4
0
int main (void)
{
  int i;
  GC_INIT ();

# ifdef GC_SOLARIS_THREADS
    pthread_key_create (&key, on_thread_exit);
# else
    pthread_once (&key_once, make_key);
# endif
  for (i = 0; i < LIMIT; i++) {
    pthread_t t;
    void *res;
    if (GC_pthread_create (&t, NULL, entry, NULL) == 0
        && (i & 1) != 0)
      GC_pthread_join (t, &res);
  }
  return 0;
}
Exemple #5
0
void * mz_proc_thread_wait(mz_proc_thread *thread) {
    void *rc;
#ifdef WIN32
    DWORD rcw;
    WaitForSingleObject(thread->threadid,INFINITE);
    GetExitCodeThread(thread->threadid, &rcw);
    rc = (void *)rcw;
    CloseHandle(thread->threadid);
#else
#   ifdef NEED_GC_THREAD_OPS
    GC_pthread_join(thread->threadid, &rc);
#   else
    pthread_join(thread->threadid, &rc);
#   endif
#endif

    if (!--thread->refcount)
        free(thread);

    return rc;
}