Exemplo n.º 1
0
int 
main(int argc, char**argv)
{	
  // Scan options.
  char **args = &argv[1];
  while (*args)
  {
    char *opt = NULL;

    if ((opt = shift_option(&args, "--test_num=")))
      g_run_multiplier = atoi(opt);
  }

  printf("This test will run %d times.\n",
         ((1 << LG2_CAPACITY) * g_run_multiplier));
  
  // Make sure we have enough cpus.
  // if (tmc_cpus_get_dataplane_cpus(&cpus) != 0)
  if (tmc_cpus_get_my_affinity(&cpus) != 0)
    tmc_task_die("tmc_cpus_get_my_affinity() failed.");
  if (tmc_cpus_count(&cpus) < NUM_THREADS)
    tmc_task_die("Insufficient cpus available.");
    
  // Call the main thread function on each cpu, then wait for them all
  // to exit.
  run_threads(NUM_THREADS, thread_func);
  finish_threads(NUM_THREADS);
  
  return 0;
}
Exemplo n.º 2
0
Arquivo: test.c Projeto: be9/networq
int main()
{
	SOCKET accept;
	HANDLE h_exit;
	int err;

	if ((err = nw_init()) != 0) {
		fprintf(stderr, "Error initializing network (%d)\n", err);
		return 1;
	}

	if ((err = nw_listen(&accept, 44556)) != 0) {
		fprintf(stderr, "Error on listening (%d)\n", err);
		nw_shutdown();
		return 1;
	}

	h_exit = nw_install_break_handler();

	err = nw_accept_loop(accept, h_exit, accept_callback);

	fprintf(stderr, "nw_accept_loop() exited with %d\n", err);

	finish_threads();

	CloseHandle(h_exit);
	nw_closesocket(accept);
	nw_shutdown();

	return 0;
}