Exemple #1
0
int				get_light_to_print_demi(t_env *e, t_data *scene, t_data light)
{
	float	inter1;
	float	inter2;
	float	min;
	float	mem;

	if (e->ray.delta_light >= 0)
	{
		inter2 = (-e->b + sqrt(e->ray.delta_light)) / (2 * e->a);
		inter1 = (-e->b - sqrt(e->ray.delta_light)) / (2 * e->a);
		min = fmin(inter2, inter1);
		mem = rt_init(min, e, scene) + scene->pos.z;
		if (mem > scene->pos.z)
		{
			min = fmax(inter2, inter1);
			mem = rt_init(min, e, scene) + scene->pos.z;
			if (mem > scene->pos.z)
				return (0);
		}
		if (min > 0.1 && (min < e->lenght))
			return (rt_change_col(e, min, light));
	}
	return (0);
}
Exemple #2
0
void Init_ent_native() {
    rt_init();

    m_ent = rb_define_module("Ent");

    c_random_test = rb_define_class_under(m_ent, "RandomTest", rb_cObject);

    rb_define_singleton_method(c_random_test, "new", rb_rt_initialize, -1);
    rb_define_method(c_random_test, "binary?", rb_rt_get_binmode, 0);

    rb_define_method(c_random_test, "read", rb_rt_read_string, 1);
    rb_define_method(c_random_test, "read_string", rb_rt_read_string, 1);
    rb_define_method(c_random_test, "read_file", rb_rt_read_file, 1);
    rb_define_method(c_random_test, "finalize", rb_rt_final, 0);
    rb_define_method(c_random_test, "result", rb_rt_result, 0);
    rb_define_method(c_random_test, "entropy", rb_rt_entropy, 0);
    rb_define_method(c_random_test, "mean", rb_rt_mean, 0);
    rb_define_method(c_random_test, "chisquare", rb_rt_chisquare, 0);
    rb_define_method(c_random_test, "chisquare_probability", rb_rt_chisquare_probability, 0);
    rb_define_method(c_random_test, "montepi", rb_rt_montepi, 0);
    rb_define_method(c_random_test, "scc", rb_rt_scc, 0);
    rb_define_method(c_random_test, "entropy!", rb_rt_entropy_force, 0);
    rb_define_method(c_random_test, "mean!", rb_rt_mean_force, 0);
    rb_define_method(c_random_test, "chisquare!", rb_rt_chisquare_force, 0);
    rb_define_method(c_random_test, "chisquare_probability!", rb_rt_chisquare_probability_force, 0);
    rb_define_method(c_random_test, "montepi!", rb_rt_montepi_force, 0);
    rb_define_method(c_random_test, "scc!", rb_rt_scc_force, 0);
}
int main(int argc, char *argv[])
{
	period = DEFAULT_PERIOD*NS_PER_MS;
	prio = DEFAULT_PRIO;
	calc_loops = DEFAULT_CALC_LOOPS;
	setup();

	rt_init("f:hi:r:t:l:", parse_args, argc, argv);

	if (iterations < 100) {
		printf("Number of iterations cannot be less than 100\n");
		exit(1);
	}

	if (!period || !prio | !calc_loops) {
		usage();
		exit(1);
	}

	set_priority(prio);

	printf("------------------------------------\n");
	printf("Periodic CPU Load Execution Variance\n");
	printf("------------------------------------\n\n");
	printf("Running %d iterations\n", iterations);
	printf("priority: %d\n", prio);
	printf("  period: %d ms\n", period/NS_PER_MS);
	printf("   loops: %d\n", calc_loops);
	printf("    logs: %s*\n", filename_prefix);

	ret = periodic_thread(period, iterations, calc_loops);

	return ret;
}
Exemple #4
0
void* thread(void *args)
{
    struct timespec ts1,ts2,ts3;
    int i;  


    gettime(&ts1);

#ifdef USE_SCHED_CPU
    rt_init(); 
    rt_set_period(period);
    rt_set_deadline(period);// if period = deadline, don't call "rt_set_deadline"
    rt_set_runtime(runtime);

#endif

    cuda_test_madd(1000, ".", prio);
    
    gettime(&ts2);

   // pthread_mutex_lock(&mutex);
   // printf("%ld,",timespec_to_ns_sub(&ts1,&ts2));
   // pthread_mutex_unlock(&mutex);
    return NULL;
}
int
main(int argc, char *argv[])
{
	struct sched_param sp;
	long iter;
	setup();

	rt_init("h", parse_args, argc, argv);

	sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
	if (sp.sched_priority == -1) {
		perror("sched_get_priority_max");
		exit(-1);
	}
	if (sched_setscheduler(0, SCHED_FIFO, &sp) != 0) {
		perror("sched_setscheduler");
		exit(-1);
	}

	if (argc == 1) {
		fprintf(stderr, "Usage: %s iterations [unicast]\n", argv[0]);
		exit(-1);
	}
	iter = strtol(argv[1], NULL, 0);
	test_signal(argc == 2, iter);

	return 0;
}
Exemple #6
0
void calc(uint8_t *buf, int len, int binary, double *csq)
{
long ccount[256];	      /* Bins to count occurrences of values */
long totalc = 0;	      /* Total character count */
double montepi=0, chip=0, scc=0, ent=0, mean=0, chisq=0;

    memset(ccount, 0, sizeof ccount);

    /* Initialise for calculations */
    rt_init(binary);

    /* Scan input file and count character occurrences */
    for(int i=0; i < len; i++) {
	unsigned char ocb = buf[i];
	totalc += (binary ? 8 : 1);

	if(binary) {
	    int b;
    	    unsigned char ob = ocb;
	    for (b = 0; b < 8; b++) {
		ccount[ob & 1]++;
		ob >>= 1;
	    }    
	} else {
	    ccount[ocb]++;
	}
	rt_add(&ocb, 1);
    }
Exemple #7
0
int main(int argc, char** argv)
{
	rt_init();
	int rc = helloFromD();
	rt_term();
	return rc;
}
int main(int argc, char *argv[])
{
	int thr_id1, thr_id2;

	atomic_set(0,&flag);
	setup();

	pass_criteria = THRESHOLD;
	rt_init("l:h", parse_args, argc, argv);	/* we need the buffered print system */

	printf("-------------------------------\n");
	printf("pthread_kill Latency\n");
	printf("-------------------------------\n\n");

	printf("Iterations: %d\n", ITERATIONS);

	debug(DBG_DEBUG, "Main creating threads\n");
	fflush(stdout);

	thr_id1 = create_fifo_thread(signal_receiving_thread, (void*)0, PRIO);
	thr_id2 = create_fifo_thread(signal_sending_thread, (void*)(intptr_t)thr_id1, PRIO-1);
//	thr_id2 = create_other_thread(signal_sending_thread, (void*)(intptr_t)thr_id1);

	debug(DBG_DEBUG, "Main joining threads debug\n");
	join_thread(thr_id1);
	join_thread(thr_id2);
	buffer_print();

	return fail;
}
Exemple #9
0
/*
 * Test pthread creation at different thread priorities.
 */
int main(int argc, char *argv[])
{
	char *pathbuf;
	size_t n;

	rt_init("h", parse_args, argc, argv);

	n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0);
	pathbuf = malloc(n);
	if (!pathbuf)
		abort();
	confstr(_CS_GNU_LIBC_VERSION, pathbuf, n);

	printf("LIBC_VERSION: %s\n", pathbuf);
	free(pathbuf);

	n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
	pathbuf = malloc(n);
	if (!pathbuf)
		abort();
	confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, n);

	printf("LIBPTHREAD_VERSION: %s\n", pathbuf);
	free(pathbuf);

	if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1)
		printf("No Prio inheritance support\n");

	printf("Prio inheritance support present\n");

	return 0;
}
Exemple #10
0
/*
 * Test pthread creation at different thread priorities.
 */
int main(int argc, char* argv[]) {
  pthread_mutexattr_t mutexattr;
  int i, retc, protocol, nopi = 0;
  cpu_set_t mask;
  CPU_ZERO(&mask);
  CPU_SET(0, &mask);
  setup();
  
  rt_init("h",parse_args,argc,argv);

  if ((retc = pthread_barrier_init(&barrier, NULL, 5))) {
    printf("pthread_barrier_init failed: %s\n", strerror(retc));
    exit(retc);
  }

  retc = sched_setaffinity(0, sizeof(mask), &mask);
  if (retc < 0) {
     printf("Main Thread: Can't set affinity: %d %s\n", retc, strerror(retc));
     exit(-1);
  }
  for (i=0;i<argc;i++) {
    if (strcmp(argv[i],"nopi") == 0) nopi = 1;
  }

  printf("Start %s\n",argv[0]);

  if (!nopi) {
    if (pthread_mutexattr_init(&mutexattr) != 0) {
      printf("Failed to init mutexattr\n");
    }
    if (pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT) != 0) {
      printf("Can't set protocol prio inherit\n");
    }
    if (pthread_mutexattr_getprotocol(&mutexattr, &protocol) != 0) {
      printf("Can't get mutexattr protocol\n");
    } else {
      printf("protocol in mutexattr is %d\n", protocol);
    }
    if ((retc = pthread_mutex_init(&glob_mutex, &mutexattr)) != 0) {
      printf("Failed to init mutex: %d\n", retc);
    }
  }

  create_other_thread(func_nonrt,NULL); 
  create_rr_thread(func_rt, NULL, 20); 
  create_rr_thread(func_rt, NULL, 30); 
  create_rr_thread(func_rt, NULL, 40); 
  create_rr_thread(func_noise, NULL, 40); 

  printf("Joining threads\n");
  join_threads();
  printf("Done\n");
  printf("Criteria:Low Priority Thread should Preempt Higher Priority Noise Thread\n");

  return 0;
}
Exemple #11
0
/*
 * Test pthread creation at different thread priorities.
 */
int main(int argc, char *argv[])
{
	int i, retc, nopi = 0;
	cpu_set_t mask;
	CPU_ZERO(&mask);
	CPU_SET(0, &mask);
	setup();

	rt_init("h", parse_args, argc, argv);

	retc = pthread_barrier_init(&barrier, NULL, 5);
	if (retc) {
		printf("pthread_barrier_init failed: %s\n", strerror(retc));
		exit(retc);
	}

	retc = sched_setaffinity(0, sizeof(mask), &mask);
	if (retc < 0) {
		printf("Main Thread: Can't set affinity: %d %s\n", retc,
		       strerror(retc));
		exit(-1);
	}
	for (i = 0; i < argc; i++) {
		if (strcmp(argv[i], "nopi") == 0)
			nopi = 1;
	}

	printf("Start %s\n", argv[0]);

	glob_mutex = malloc(sizeof(pthread_mutex_t));
	if (glob_mutex == NULL) {
		printf("Malloc failed\n");
		exit(errno);
	}

	if (!nopi)
		init_pi_mutex(glob_mutex);

	create_other_thread(func_nonrt, NULL);
	create_rr_thread(func_rt, NULL, 20);
	create_rr_thread(func_rt, NULL, 30);
	create_rr_thread(func_rt, NULL, 40);
	create_rr_thread(func_noise, NULL, 40);

	printf("Joining threads\n");
	join_threads();
	printf("Done\n");

	pthread_mutex_destroy(glob_mutex);
	pthread_mutex_destroy(&cond_mutex);
	pthread_cond_destroy(&cond_var);

	return 0;
}
Exemple #12
0
__naked void os_sys_init1 (void) {
  /* Initialize system and start up a first task. */
  U32 i;

  rt_init ();
  tsk_lock ();

  /* Initialize dynamic memory and task TCB pointers to NULL. */
  for (i = 0; i < os_maxtaskrun; i++) {
    os_active_TCB[i] = NULL;
  }
  _init_box (&mp_tcb, mp_tcb_size, sizeof(struct OS_TCB));
  _init_box (&mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo));
  _init_box ((U32 *)m_tmr, mp_tmr_size, sizeof(struct OS_TMR));

  /* Set up TCB of idle demon */
  os_idle_TCB.task_id    = 255;
  os_idle_TCB.priv_stack = 0;
  os_init_context (&os_idle_TCB, 0, os_idle_demon, __FALSE);

  /* Set up ready list: initially empty */
  os_rdy.cb_type = HCB;
  os_rdy.p_lnk   = NULL;
  /* Set up delay list: initially empty */
  os_dly.cb_type = HCB;
  os_dly.p_dlnk  = NULL;
  os_dly.p_blnk  = NULL;
  os_dly.delta_time = 0;

  /* Fix SP and system variables to assume idle task is running */
  /* Transform main program into idle task by assuming idle TCB */
  os_set_env (&os_idle_TCB);
  os_runtask = &os_idle_TCB;
  os_runtask->state = RUNNING;

  /* Initialize ps queue */
  os_psq->first = 0;
  os_psq->last  = 0;
  os_psq->size  = os_fifo_size;

  /* Initialize system clock timer */
  os_tmr_init ();
  os_init_robin ();

  /* Start up first user task before entering the endless loop */
  os_sys_run ((FUNCP)os_tsk_create0);

  /* Call body of idle task: contains an endless loop */
  os_idle_demon();

  /* This point never reached if idle task contains endless loop */
  for (;;);
}
Exemple #13
0
static int __init mac_static_init(void)
{
	int error, i;
	
	bzero(rt, sizeof(struct nm_route) * NM_BRIDGES); /* safety */
	for (i=0; i < NM_BRIDGES; ++i) 
		rt_init(&rt[i]);
	
	bdgfndev = make_dev(&bdg_cdevsw, 0, UID_ROOT, GID_WHEEL, 0660,
			      BDGFN_NAME);
	return 0;
}
Exemple #14
0
int main(int argc, char *argv[])
{
	long i;
	int ret;
	setup();

	pass_criteria = THRESHOLD;
	rt_init("hi:n:w:", parse_args, argc, argv);

	if (iterations < 100) {
		printf("Number of iterations cannot be less than 100\n");
		exit(1);
	}

	busy_work_time = low_work_time;
	if (num_busy == -1) {
		/* Number of busy threads = No. of CPUs */
		num_busy = sysconf(_SC_NPROCESSORS_ONLN);
	}

	if ((ret = pthread_barrier_init(&bar1, NULL, (num_busy + 2)))) {
		printf("pthread_barrier_init failed: %s\n", strerror(ret));
		exit(ret);
	}
	if ((ret = pthread_barrier_init(&bar2, NULL, (num_busy + 2)))) {
		printf("pthread_barrier_init failed: %s\n", strerror(ret));
		exit(ret);
	}

	init_pi_mutex(&lock);


	if ((ret = create_fifo_thread(low_prio_thread, (void *)0, LOWPRIO)) < 0)
		exit(ret);
	if ((ret = create_fifo_thread(high_prio_thread, (void *)0, HIGHPRIO)) < 0)
		exit(ret);

	for (i = 0; i < num_busy; i++) {
		if ((ret = create_fifo_thread(busy_thread, (void *)i, BUSYPRIO)) < 0)
			exit(ret);
	}

	join_threads();
	printf("Criteria: High prio lock wait time < "
			"(Low prio lock held time + %d us)\n", (int)pass_criteria);

	ret = 0;
	if (max_pi_delay > pass_criteria)
		ret = 1;

	printf("Result: %s\n", ret ? "FAIL" : "PASS");
	return ret;
}
Exemple #15
0
static void
timeout_handler(int sig)
{
	int i, killed, status;
	struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };

	printf("Inside the timeout handler, killing the TC threads \n");
	kill(pid, SIGKILL);
	for (i = 0; i < 5; i++) {
		killed = waitpid(pid, &status, WNOHANG|WUNTRACED);
		if (0 != killed)
			break;
      		nanosleep(&ts, NULL);
	}

	if (0 != killed && pid != killed) {
		printf("\n Failed to kill child process ");
		exit(1);
	}
	printf("\nResult:PASS\n");
	exit(1);
}

int
main(int argc, char **argv)
{
	pid_t termpid;
 	int status;
	setup();

	rt_init("h", parse_args, argc, argv);

	pid = fork();
	if (0 == pid) {
		exit(TEST_FUNCTION);
	}
	else if (pid < 0) {
		printf("\n Cannot fork test program \n");
		exit(1);
	}

	signal(SIGALRM, timeout_handler);
	alarm(TIMEOUT);
	termpid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0));
	if (-1 == termpid) {
		printf("\n Waiting for test program failed, Exiting \n");
		exit(1);
	}

	return 0;
}
Exemple #16
0
int main(int argc, char* argv[])
{
	int m, ret, robust;
	intptr_t t;
	pthread_mutexattr_t mutexattr;
	setup();

	rt_init("h",parse_args,argc,argv);

        if (pthread_mutexattr_init(&mutexattr) != 0) {
                printf("Failed to init mutexattr\n");
        }
        if (pthread_mutexattr_setrobust_np(&mutexattr, PTHREAD_MUTEX_ROBUST_NP) != 0) {
                printf("Can't set mutexattr robust\n");
        }
        if (pthread_mutexattr_getrobust_np(&mutexattr, &robust) != 0) {
                printf("Can't get mutexattr robust\n");
        } else {
                printf("robust in mutexattr is %d\n", robust);
        }


	/* malloc and initialize the mutexes */
	printf("allocating and initializing %d mutexes\n", NUM_MUTEXES);
	for (m = 0; m < NUM_MUTEXES; m++) {
		if (!(mutexes[m] = malloc(sizeof(pthread_mutex_t)))) {
			perror("malloc failed\n");
		}
		if ((ret = pthread_mutex_init(mutexes[m], &mutexattr))) {
			perror("pthread_mutex_init() failed\n");
		}
	}
	printf("mutexes allocated and initialized successfully\n");

	/* start children threads to walk the array, grabbing the locks */
	for (t = 0; t < NUM_THREADS; t++) {
		create_fifo_thread(worker_thread, (void*)t, sched_get_priority_min(SCHED_FIFO));
		}
	/* wait for the children to complete */
	printf("joining threads\n");
	join_threads();
	/* destroy all the mutexes */
	for (m = 0; m < NUM_MUTEXES; m++) {
		if (mutexes[m]) {
			if ((ret = pthread_mutex_destroy(mutexes[m])))
				perror("pthread_mutex_destroy() failed\n");
			free(mutexes[m]);
		}
	}
	return 0;
}
Exemple #17
0
int main(int argc, char **argv) {
    qstr_init();
    rt_init();

    if (argc == 2) {
        do_file(argv[1]);
    } else {
        printf("usage: py [<file>]\n");
        return 1;
    }
    rt_deinit();

    return 0;
}
Exemple #18
0
void exec_task(task_t *task, int loop_1ms, int simtime)
{
	int k; /* do not use i! */
	int nr_jobs = simtime / task->T;
	struct timeval tv, tv_C, tv_T, tv_D, tv_timeout;
	int ret = RET_SUCCESS;

	msecs_to_timeval(task->C, tv_C);
	msecs_to_timeval(task->T, tv_T);
	msecs_to_timeval(task->D, tv_D);
	msecs_to_timeval(DEFAULT_TIMEOUT, tv_timeout);

	/* get own PID. */
	task->pid = getpid();

	/* initialization for using RESCH. */
	if (!rt_init()) {
		printf("Error: cannot begin!\n");
		ret = RET_MISS;
		goto out;
	} 

	xcpu_flag = 0;
	rt_set_priority(task->prio);
	rt_set_wcet(&tv_C); 
	rt_set_period(&tv_T);		
	rt_set_deadline(&tv_D);	
	rt_reserve_cpu(&tv_C, xcpu_handler);
	rt_run(&tv_timeout);

	/* busy loop. */
	for (k = 0; k < nr_jobs; k++) {
		while (!xcpu_flag) {
			gettimeofday(&tv, NULL);
		}
		if (!rt_wait_for_period()) {
			ret = RET_MISS;
			break;
		}
		xcpu_flag = 0;
	}

	rt_exit();
 out:
	/* call _exit() but not exit(), since exit() may remove resources
	   that are shared with the parent and other child processes. */
	_exit(ret);

	/* no return. */
}
Exemple #19
0
/*
 * Test pthread creation at different thread priorities.
 */
int main(int argc, char *argv[])
{
	int i, retc, nopi = 0;
	cpu_set_t mask;
	CPU_ZERO(&mask);
	CPU_SET(0, &mask);
	setup();
	rt_init("h", parse_args, argc, argv);

	retc = pthread_barrier_init(&barrier, NULL, 5);
	if (retc) {
		printf("pthread_barrier_init failed: %s\n", strerror(retc));
		exit(retc);
	}

	retc = sched_setaffinity(0, sizeof(mask), &mask);
	if (retc < 0) {
		printf("Main Thread: Can't set affinity: %d %s\n", retc,\
			strerror(retc));
		exit(-1);
	}

	for (i = 0; i < argc; i++) {
		if (strcmp(argv[i], "nopi") == 0)
			nopi = 1;
	}

	printf("Start %s\n", argv[0]);

	if (!nopi)
		init_pi_mutex(&glob_mutex);

	create_rr_thread(func_lowrt, NULL, 10);
	create_rr_thread(func_rt, NULL, 20);
	create_fifo_thread(func_rt, NULL, 30);
	create_fifo_thread(func_rt, NULL, 40);
	create_rr_thread(func_noise, NULL, 40);

	printf("Joining threads\n");
	join_threads();
	printf("Done\n");
	printf("Criteria: Low Priority Thread and High Priority Thread "\
		"should prempt each other multiple times\n");

	pthread_mutex_destroy(&glob_mutex);
	pthread_mutex_destroy(&cond_mutex);
	pthread_cond_destroy(&cond_var);

	return 0;
}
Exemple #20
0
static void frontend_init()
{
    rt_init();
    gc_disable();

    global._init();
    global.params.isLinux = true;

    Type::_init();
    Id::initialize();
    Module::_init();
    Expression::_init();
    Objc::_init();
    Target::_init();
}
Exemple #21
0
int rtx_gpu_init(void)
{
    struct sigaction sa_kill;
    int ret;

    ret = rt_init();

    /* reregister the KILL signal. */
    memset(&sa_kill, 0, sizeof(sa_kill));
    sigemptyset(&sa_kill.sa_mask);
    sa_kill.sa_handler = gpu_kill_handler;
    sa_kill.sa_flags = 0;
    sigaction(SIGINT, &sa_kill, NULL); /* */

    return ret;
}
Exemple #22
0
int main(int argc, char* argv[])
{
	int i;
	unsigned long prio;
	struct timespec period, runtime, timeout;
	struct timeval tv1, tv2, tv3;

	if (argc != 3) {
		printf("Error: invalid option\n");
	}
	prio = atoi(argv[1]);					/* priority. */
	period = ms_to_timespec(atoi(argv[2]));	/* period. */
	runtime = ms_to_timespec(1000);			/* execution time. */
	timeout = ms_to_timespec(1000);			/* timeout. */

	/* bannar. */
	printf("sample program\n");

	rt_init(); 
	rt_set_period(period);
	rt_set_runtime(runtime);
	rt_set_scheduler(SCHED_FP); /* you can also set SCHED_EDF. */
	rt_set_priority(prio);
	rt_reserve_start(runtime, NULL); /* QoS is guaranteed. */
	rt_run(timeout);

	for (i = 0; i < 20; i++) {
		gettimeofday(&tv1, NULL);
		printf("start %lu:%06lu\n", tv1.tv_sec, tv1.tv_usec);
		fflush(stdout);
		do  {
			gettimeofday(&tv2, NULL);
			/* tv2 - tv1 = tv3 */
			tvsub(&tv2, &tv1, &tv3);
		} while (tv3.tv_sec < 2);
		printf("finish %lu:%06lu\n", tv2.tv_sec, tv2.tv_usec);
		fflush(stdout);

		if (!rt_wait_period()) {
			printf("deadline is missed!\n");
		}
	}
	rt_reserve_stop();
	rt_exit();
	
	return 0;
}
Exemple #23
0
/**
 * Run the entire unit test.
 **/
int main(void)
{
  int i;
  int port;
  guint16 real_port;    /* port at its actual size (for randomtest) */
  double ent, chisq, mean, montepi, scc;        /* randomtest results */

  printf("Testing source port randomness; iterations=%d, minimal entropy=%f\n", ITERATIONS, MIN_ENTROPY);
  rt_init(FALSE);   /* initialize randomtest, not binary */

  /* run test iterations */
  for (i = 0; i < ITERATIONS; i++)
    {
      port = try_bind_once();
#if PRINT_PORTS
      printf("Port bound to: %d\n", port);
#endif
      if (port < PORT_MIN)
        {
          printf("Failed: port number below minimum.\n");
          exit(1);
        }
      if (port > PORT_MAX)
        {
          printf("Failed: port number above maximum.\n");
          exit(1);
        }
      real_port = (guint16)port;
      rt_add(&real_port, sizeof(real_port));
    }

  /* check randomness */
  rt_end(&ent, &chisq, &mean, &montepi, &scc);
  printf("Randomness: entropy=%f, chi-square=%f, mean=%f, monte-carlo-pi=%f, serial correlation=%f\n", ent, chisq, mean, montepi, scc);

  /* make decision */
  if (ent >= MIN_ENTROPY) {
      printf("Passed: entropy is high enough.\n");
      exit(0);
    }
  else
    {
      printf("Failed: entropy is not high enough.\n");
      exit(1);
    }
}
Exemple #24
0
static void frontend_init()
{
    rt_init();
    gc_disable();

    global._init();
    global.params.isLinux = true;
    global.vendor.ptr = "Front-End Tester";
    global.vendor.length = strlen(global.vendor.ptr);

    Type::_init();
    Id::initialize();
    Module::_init();
    Expression::_init();
    Objc::_init();
    target._init(global.params);
    CTFloat::initialize();
}
Exemple #25
0
int main(int argc, char *argv[])
{
	int worker, interrupter;

	setup();

	rt_init("h",parse_args,argc,argv);

	interrupter = create_fifo_thread(thread_interrupter, NULL, 80);
	sleep(1);
	worker = create_fifo_thread(thread_worker, NULL, 10);

	join_thread(worker);
	flag = 1;
	join_thread(interrupter);

	return 0;
}
int main(int argc, char *argv[])
{
	int pri_boost, numcpus;
	setup();

	pass_criteria = CHECK_LIMIT;
	rt_init("hin:", parse_args, argc, argv);

	numcpus = sysconf(_SC_NPROCESSORS_ONLN);

	/* Max no. of busy threads should always be less than/equal the no. of cpus
	   Otherwise, the box will hang */

	if (rt_threads == -1 || rt_threads > numcpus) {
		rt_threads = numcpus;
		printf("Maximum busy thread count(%d), "
		       "should not exceed number of cpus(%d)\n", rt_threads,
		       numcpus);
		printf("Using %d\n", numcpus);
	}

	/* Test boilder plate: title and parameters */
	printf("\n-------------------\n");
	printf("Priority Preemption\n");
	printf("-------------------\n\n");
	printf("Busy Threads: %d\n", rt_threads);
	printf("Interrupter Threads: %s\n",
	       int_threads ? "Enabled" : "Disabled");
	printf("Worker Threads: %d\n\n", NUM_WORKERS);

	pri_boost = 81;
	create_fifo_thread(master_thread, (void *)0,
			   sched_get_priority_min(SCHED_FIFO) + pri_boost);

	/* wait for threads to complete */
	join_threads();

	printf
	    ("\nCriteria: All threads appropriately preempted within %d loop(s)\n",
	     (int)pass_criteria);
	printf("Result: %s\n", ret ? "FAIL" : "PASS");
	return ret;
}
Exemple #27
0
int main(int argc, char *argv[])
{
	setup();
	pass_criteria = PASS_CRITERIA;
	rt_init("l:i:h", parse_args, argc, argv);
	numcpus = sysconf(_SC_NPROCESSORS_ONLN);
	/* the minimum avg concurrent multiplier to pass */
	criteria = pass_criteria * numcpus;
	int new_iterations;

	if (iterations <= 0) {
		fprintf(stderr, "iterations must be greater than zero\n");
		exit(1);
	}

	printf("\n---------------------------------------\n");
	printf("Matrix Multiplication (SMP Performance)\n");
	printf("---------------------------------------\n\n");

	/* Line below rounds up iterations to a multiple of numcpus.
	 * Without this, having iterations not a mutiple of numcpus causes
	 * stats to segfault (overflow stats array).
	 */
	new_iterations = (int) ( (iterations + numcpus - 1) / numcpus) * numcpus;
	if (new_iterations != iterations)
		printf("Rounding up iterations value to nearest multiple of total online CPUs\n");

	iterations = new_iterations;
	iterations_percpu = iterations / numcpus;

	printf("Running %d iterations\n", iterations);
	printf("Matrix Dimensions: %dx%d\n", MATRIX_SIZE, MATRIX_SIZE);
	printf("Calculations per iteration: %d\n", ops);
	printf("Number of CPUs: %u\n", numcpus);

	set_priority(PRIO);
	main_thread();

	return 0;
}
Exemple #28
0
int main(int argc, char *argv[])
{
	init_pi_mutex(&MM);
	init_pi_mutex(&MS);
	init_pi_mutex(&MT);
	setup();

	pthread_cond_init(&CM, NULL);
	pthread_cond_init(&CS, NULL);
	pthread_cond_init(&CT, NULL);

	rt_init("h", parse_args, argc, argv);

	create_other_thread(master_thread, (void *)0);

	// wait for the slaves to quit
	while (atomic_get(&slave_order_c) < NUM_SLAVES)
		usleep(10);

	join_threads();

	return 0;
}
Exemple #29
0
int main(int argc, char *argv[])
{
	int per_id;
	setup();

	pass_criteria = PASS_US;
	rt_init("d:l:ht:i:", parse_args, argc, argv);

	printf("-------------------------------\n");
	printf("Scheduling Latency\n");
	printf("-------------------------------\n\n");

	if (load_ms*NS_PER_MS >= period-OVERHEAD) {
		printf("ERROR: load must be < period - %d us\n", OVERHEAD/NS_PER_US);
		exit(1);
	}

	if (iterations == 0)
		iterations = DEFAULT_ITERATIONS;
	if (iterations < MIN_ITERATIONS) {
		printf("Too few iterations (%d), use min iteration instead (%d)\n",
		       iterations, MIN_ITERATIONS);
		iterations = MIN_ITERATIONS;
	}

	printf("Running %d iterations with a period of %llu ms\n", iterations,
	       period/NS_PER_MS);
	printf("Periodic load duration: %d ms\n", load_ms);
	printf("Expected running time: %d s\n",
	       (int)(iterations*((float)period / NS_PER_SEC)));

	if (stats_container_init(&dat, iterations))
		exit(1);

	if (stats_container_init(&hist, HIST_BUCKETS)) {
		stats_container_free(&dat);
		exit(1);
	}

	/* use the highest value for the quantiles */
	if (stats_quantiles_init(&quantiles, (int)log10(iterations))) {
		stats_container_free(&hist);
		stats_container_free(&dat);
		exit(1);
	}

	/* wait one quarter second to execute */
	start = rt_gettime() + 250 * NS_PER_MS;
	per_id = create_fifo_thread(periodic_thread, (void*)0, PRIO);

	join_thread(per_id);
	join_threads();

	printf("\nCriteria: latencies < %d us\n", (int)pass_criteria);
	printf("Result: %s\n", ret ? "FAIL" : "PASS");

	stats_container_free(&dat);
	stats_container_free(&hist);
	stats_quantiles_free(&quantiles);

	return ret;
}
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    Info << "Reading T_init" << endl;
    volScalarField T_init
    (
        IOobject("T_init", runTime.constant(), mesh, IOobject::MUST_READ),
        mesh
    );
    
    Info << "Reading P_init" << endl;
    volScalarField P_init
    (
        IOobject("P_init", runTime.constant(), mesh, IOobject::MUST_READ),
        mesh
    );

    Info << "Reading rt_init" << endl;
    volScalarField rt_init
    (
        IOobject("rt_init", runTime.constant(), mesh, IOobject::MUST_READ),
        mesh
    );
    
    Info << "Reading r_init" << endl;
    volScalarField r_init
    (
        IOobject("r_init", runTime.constant(), mesh, IOobject::MUST_READ),
        mesh
    );

    Info << "Reading or creating tracer field rhof_init" << endl;
    surfaceScalarField rhof_init
    (
        IOobject("rhof_init", runTime.constant(), mesh, IOobject::READ_IF_PRESENT),
        linearInterpolate(rt_init)
    );
    
    Info << "Creating T" << endl;
    volScalarField T
    (
        IOobject("T", runTime.timeName(), mesh, IOobject::NO_READ),
        T_init
    );
    
    Info << "Creating P" << endl;
    volScalarField P
    (
        IOobject("P", runTime.timeName(), mesh, IOobject::NO_READ),
        P_init
    );
    
    Info << "Creating rt" << endl;
    volScalarField rt
    (
        IOobject("rt", runTime.timeName(), mesh, IOobject::NO_READ),
        rt_init
    );

    Info << "Creating rl" << endl;
    volScalarField rl
    (
        IOobject("rl", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );

    Info << "Creating rv" << endl;
    volScalarField rv
    (
        IOobject("rv", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );
    
    Info << "Creating rl_diag" << endl;
    volScalarField rl_diag
    (
        IOobject("rl_diag", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );

    Info << "Creating rv_diag" << endl;
    volScalarField rv_diag
    (
        IOobject("rv_diag", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );
    
    Info << "Creating rl_analytic" << endl;
    volScalarField rl_analytic
    (
        IOobject("rl_analytic", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );
    
    Info << "Creating rv_analytic" << endl;
    volScalarField rv_analytic
    (
        IOobject("rv_analytic", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );
    
    Info << "Creating rt_analytic" << endl;
    volScalarField rt_analytic
    (
        IOobject("rt_analytic", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );
    
    Info << "Creating S" << endl;
    volScalarField S
    (
        IOobject("S", runTime.timeName(), mesh, IOobject::NO_READ),
        r_init
    );

    Info << "Creating rhof" << endl;
    surfaceScalarField rhof
    (
        IOobject("rhof", runTime.timeName(), mesh, IOobject::NO_READ),
        rhof_init
    );

    IOdictionary rtDict
    (
        IOobject
        (
            "totalMoistureDict",
            mesh.time().system(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        )
    );
    
    IOdictionary rlDict
    (
        IOobject
        (
            "liquidWaterDict",
            mesh.time().system(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        )
    );
    
    IOdictionary rvDict
    (
        IOobject
        (
            "waterVapourDict",
            mesh.time().system(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        )
    );
    
    IOdictionary tempDict
    (
        IOobject
        (
            "tempDict",
            mesh.time().system(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        )
    );
    
    IOdictionary PDict
    (
        IOobject
        (
            "pressureDict",
            mesh.time().system(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE
        )
    );

    const noAdvection velocityField;
    autoPtr<tracerField> rtVal(tracerField::New(rtDict, velocityField));
    
    autoPtr<tracerField> rlVal(tracerField::New(rlDict, velocityField));
    
    autoPtr<tracerField> rvVal(tracerField::New(rvDict, velocityField));
    
    autoPtr<tracerField> tempVal(tracerField::New(tempDict, velocityField));
    
    autoPtr<tracerField> PVal(tracerField::New(PDict, velocityField));
    
    Info << "writing rt for time " << runTime.timeName() << endl;
    rtVal->applyTo(rt);
    rt.write();
    
    Info << "writing rl for time " << runTime.timeName() << endl;
    rlVal->applyTo(rl);
    rl.write();

    Info << "writing rv for time " << runTime.timeName() << endl;
    rvVal->applyTo(rv);
    rv.write();
    
    Info << "writing rl_diag for time " << runTime.timeName() << endl;
    rlVal->applyTo(rl_diag);
    rl_diag.write();

    Info << "writing rv_diag for time " << runTime.timeName() << endl;
    rvVal->applyTo(rv_diag);
    rv_diag.write();

    Info << "writing rl_analytic for time " << runTime.timeName() << endl;
    rlVal->applyTo(rl_analytic);
    rl_analytic.write();
    
    Info << "writing rv_analytic for time " << runTime.timeName() << endl;
    rvVal->applyTo(rv_analytic);
    rv_analytic.write();

    Info << "writing rt_analytic for time " << runTime.timeName() << endl;
    rtVal->applyTo(rt_analytic);
    rt_analytic.write();

    Info << "writing S for time " << runTime.timeName() << endl;
    S.write();

    Info << "writing qf for time " << runTime.timeName() << endl;
    rtVal->applyTo(rhof);
    rhof.write();
    
    Info << "writing T" << endl;
    tempVal->applyTo(T);
    T.write();
    
    Info << "writing P" << endl;
    PVal->applyTo(P);
    P.write();

    return EXIT_SUCCESS;
}