Esempio n. 1
0
static unsigned long measure_loop_costs(unsigned long spin) 
{
	u64_t start, end, min, max;
	unsigned long temp = 0;

	temp = spin * 15 / 2;
	loop_cost = temp;
	return temp;

	rdtscll(start);
	do {
		int i;
		min = MAXULONG;
		max= 0;
		for (i = 0 ; i < 10 ; i++) {
			temp = get_loop_cost(spin);
			if (temp < min) min = temp;
			if (temp > max) max = temp;
		}
	} while ((max-min) > (min/128));

	loop_cost = temp;
	rdtscll(end);
	assert(end>start);
	printc("spin:%lu, loopcost measurement :%lu\n",spin, temp );
	return temp;
}
Esempio n. 2
0
static void sinusoid_spike() 
{
	u64_t start, end, min, max;
	unsigned long long t;
	unsigned long temp = 0;
	unsigned long long pre_spin;
	unsigned long long val;
	static unsigned long long spin = STEP;
	static int spike = 0;

	unsigned long long ts;

	rdtscll(t);
	val = (unsigned long long)(t & (TOTAL_AMNT-1));
	if (val >= probability) {
		rdtscll(ts);
		printc("spike.....(@%llu)\n", ts);
		pre_spin = spin;
		spin = spin + 100*STEP;
		spike = 1;
	} else {
		if (spike == 1) {
			spike = 0;
			spin = pre_spin;
		}
		rdtscll(ts);
		printc("sinusoid-like.....(@%llu)\n", ts);
		if (spin > threshold) spin = spin - STEP;
		else spin = spin + STEP;
	}

	do {
		int i;
		min = MAXULONG;
		max= 0;
		for (i = 0 ; i < 10 ; i++) {
			temp = get_loop_cost(spin);
			if (temp < min) min = temp;
			if (temp > max) max = temp;
		}
	} while ((max-min) > (min/128));

	/* printc("spin:%llu cost :%lu\n", spin, temp); */
}