Ejemplo n.º 1
0
int
main(int argc, char *argv[])
{
	unsigned int r, size;

	common_srand48((long int)time(NULL));
	if (argc < 2) {
		ck_error("Usage: ck_hs <dictionary> [<repetitions> <initial size>]\n");
	}

	r = 16;
	if (argc >= 3)
		r = atoi(argv[2]);

	size = 8;
	if (argc >= 4)
		size = atoi(argv[3]);

	global_seed = common_lrand48();
	run_test(argv[1], r, size, 0);
	run_test(argv[1], r, size, CK_HS_MODE_DELETE);
	fprintf(stderr, "#    reverse_insertion serial_insertion random_insertion serial_swap "
	    "serial_replace reverse_get serial_get random_get serial_remove negative_get tombstone "
	    "set_unique gc rebuild\n\n");

	return 0;
}
Ejemplo n.º 2
0
static void
table_init(void)
{

	common_srand48((long int)time(NULL));
	if (ck_ht_init(&ht, CK_HT_MODE_BYTESTRING, NULL, &my_allocator, 8, common_lrand48()) == false) {
		perror("ck_ht_init");
		exit(EXIT_FAILURE);
	}

	return;
}
Ejemplo n.º 3
0
static void *
fairness(void *null)
{
	struct block *context = null;
	unsigned int i = context->tid;
	volatile int j;
	long int base;
	unsigned int core;
	CK_COHORT_INSTANCE(basic) *cohort;


	if (aff_iterate_core(&a, &core)) {
		perror("ERROR: Could not affine thread");
		exit(EXIT_FAILURE);
	}

	cohort = &((cohorts + (core / (int)(a.delta)) % n_cohorts)->cohort);

	while (ck_pr_load_uint(&ready) == 0);

	ck_pr_inc_uint(&barrier);
	while (ck_pr_load_uint(&barrier) != nthr);

	while (ready) {
		CK_COHORT_LOCK(basic, cohort, NULL, NULL);

		count[i].value++;
		if (critical) {
			base = common_lrand48() % critical;
			for (j = 0; j < base; j++);
		}

		CK_COHORT_UNLOCK(basic, cohort, NULL, NULL);
	}

	return NULL;
}
Ejemplo n.º 4
0
static void
set_init(void)
{

	common_srand48((long int)time(NULL));
	if (ck_hs_init(&hs, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC, hs_hash, hs_compare, &my_allocator, 8, common_lrand48()) == false) {
		perror("ck_hs_init");
		exit(EXIT_FAILURE);
	}

	return;
}