int crasher(int argc, char *argv[])
{
  int i;
  xbt_os_thread_t *crashers;

  xbt_init(&argc, argv);

  /* initializations of the philosopher mecanisms */
  id = xbt_new0(int, crasher_amount);
  crashers = xbt_new(xbt_os_thread_t, crasher_amount);

  for (i = 0; i < crasher_amount; i++)
    id[i] = i;

  /* spawn threads */
  for (i = 0; i < crasher_amount; i++) {
    char *name = bprintf("thread %d", i);
    crashers[i] =
        xbt_os_thread_create(name, &crasher_thread, &id[i], NULL );
    free(name);
  }

  /* wait for them */
  for (i = 0; i < crasher_amount; i++)
    xbt_os_thread_join(crashers[i],NULL);

  xbt_free(crashers);
  xbt_free(id);

  return 0;
}
Example #2
0
JavaContext::~JavaContext()
{
  if (this->thread) {
    // We are not in maestro context
    xbt_os_thread_join(this->thread, nullptr);
    xbt_os_sem_destroy(this->begin);
    xbt_os_sem_destroy(this->end);
  }
}
Example #3
0
void rctx_exit(void)
{
  int i;
  for (i = 0; i < 3; i++)
    sigaction(oldact[i].num, &oldact[i].act, NULL);
  xbt_os_cond_signal(sigwaiter_cond);
  xbt_os_thread_join(sigwaiter_thread, NULL);
  xbt_dynar_free(&bg_jobs);
  xbt_os_cond_destroy(sigwaiter_cond);
  xbt_os_mutex_destroy(sigwaiter_mutex);
  xbt_os_mutex_destroy(armageddon_mutex);
}
Example #4
0
static void wait_it(rctx_t rctx)
{
  XBT_VERB("Join thread %p which were running background cmd <%s>",
        rctx->runner, rctx->filepos);
  xbt_os_thread_join(rctx->runner, NULL);
}
Example #5
0
void jprocess_join(jobject jprocess, JNIEnv * env)
{
	msg_process_t process = jprocess_to_native_process(jprocess,env);
	smx_ctx_java_t context = (smx_ctx_java_t)MSG_process_get_smx_ctx(process);
	xbt_os_thread_join(context->thread,NULL);
}