int execute_test() {
	fthInit();
	int size = 1024;
	char str[size];
	uint64_t i;
	pthread_attr_t attr;
	pthread_attr_init(&attr);
	pthread_t fthPthread[MAX_CORES];

	for (i = 0; i < ncores; i++) {
		pthread_create(&fthPthread[i], &attr, &pthread_routine, (void*) i);
	}

	for (i = 0; i < ncores; i++) {
		pthread_join(fthPthread[i], NULL);
	}

	HomeDir_printStats(homedir, str, size);
	printf("%s\n", str);
	printf("The status should be: nputs is %d, ngets is %d, nremoves is %d,"
			"nhits is %d, nmisses is %d\n", nputs, ngets, nremoves, nhits, nmisses);
	fflush(stdout);

	//Compare with stats_puts, stats_gets, stats_removes,
	//stats_hits, stats_misses in homedir
	plat_assert_always(nputs == homedir->stats_puts);
	plat_assert_always(ngets == homedir->stats_gets);
	plat_assert_always(nremoves == homedir->stats_removes);
	plat_assert_always(nhits == homedir->stats_hits);
	plat_assert_always(nmisses == homedir->stats_misses);
	HomeDir_destroy(homedir);
	return 0;
}
Exemplo n.º 2
0
void
testRoutine1(uint64_t arg)
{
    int size=1024;
    char str[size];

    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testcreate();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testget();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testremove();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    fthKill(222);
}
void testRoutine1(uint64_t arg) {
	int size = 1024;
	char str[size];

	int seq = __sync_fetch_and_add(&g_seq, 1);
	printf("\n%d fth begins\n", seq);
	HomeDir_printStats(homedir, str, size);
	printf("%s\n", str);
	if (seq % 3 == 0) {
		testcreate(seq);
	} else if (seq % 3 == 1) {
		testget(seq);
	} else if (seq % 3 == 2) {
		testremove(seq);
	}
	if (__sync_add_and_fetch(&threads_done, 1) == nthreads * ncores) {
		printf("\nTotal Iterations Completed: %d\n", nthreads * ncores);
		fthKill(222);
	}
	printf("\n%d ends\n", seq);
	fthYield(1);
}