Пример #1
0
void
reset_game_state(void)
{
	extern int last_highscore;

	SDL_ShowCursor(SDL_DISABLE);

	last_highscore = -1;
	gc.score = 0;
	gc.ships_left = 2;
	gc.level_tics = 0;
	gc.multiplier = 1;

	gc.cur_level = settings.static_settings->start_level;

	ship.is_alive = 0;
	gc.tics_remaining = 0;

	/* last_death_tic = -70; */

	memset(&game_stat_counters, 0, sizeof(game_stat_counters));

	ships_text_width = string_width_in_pixels(font_small, "ships");

	reset_level();
	reset_eye();
	reset_water();
	reset_background();
	reset_arena();
	reset_particles();
	reset_explosions();
	reset_missiles();
	reset_bombs();
	reset_lasers();
	reset_foes();
	reset_powerups();
	reset_in_game_texts();
	reset_ship_powerups();

	set_inner_state(IS_WAVE_TITLE);

	play_music(MUS_STAGE_1);
}
Пример #2
0
static void do_random_experiment(FILE* outfile,
				 int num_cpus, int wss,
				 int sleep_min, int sleep_max,
				 int write_cycle, int sample_count,
				 int best_effort)
{
	int last_cpu, next_cpu, delay, show = 1, i;
	unsigned long preempt_counter = 0;
	unsigned long migration_counter = 0;
	unsigned long counter = 1;
	unsigned long num_pages = wss / getpagesize();
	unsigned long *phys_addrs;

	cycles_t start, stop;
	cycles_t cold, hot1, hot2, hot3, after_resume;

	int *mem;

	if (!num_pages)
		num_pages = 1;

	phys_addrs = malloc(sizeof(long) * num_pages);

	migrate_to(0);
	last_cpu = 0;

	/* prefault and dirty cache */
	reset_arena();

#if defined(__i386__) || defined(__x86_64__)
	if (!best_effort)
		iopl(3);
#endif

	fprintf(outfile,
		"# %5s, %6s, %6s, %6s, %3s, %3s"
		", %10s, %10s, %10s, %10s, %10s"
		", %12s, %12s"
		"\n",
		"COUNT", "WCYCLE",
		"WSS", "DELAY", "SRC", "TGT", "COLD",
		"HOT1", "HOT2", "HOT3", "WITH-CPMD",
		"VIRT ADDR", "PHYS ADDR");


	while (!sample_count ||
	       sample_count >= preempt_counter ||
	       (num_cpus > 1 && sample_count >= migration_counter)) {

		delay = sleep_min + random() % (sleep_max - sleep_min + 1);
		next_cpu = pick_cpu(last_cpu, num_cpus);

		if (sample_count)
			show = (next_cpu == last_cpu && sample_count >= preempt_counter) ||
				(next_cpu != last_cpu && sample_count >= migration_counter);

		mem = allocate(wss);

#if defined(__i386__) || defined(__x86_64__)
		if (!best_effort)
			cli();
#endif
		start = get_cycles();
		mem[0] = touch_mem(mem, wss, write_cycle);
		stop  = get_cycles();
		cold = stop - start;

		start = get_cycles();
		mem[0] = touch_mem(mem, wss, write_cycle);
		stop  = get_cycles();
		hot1 = stop - start;

		start = get_cycles();
		mem[0] = touch_mem(mem, wss, write_cycle);
		stop  = get_cycles();
		hot2 = stop - start;

		start = get_cycles();
		mem[0] = touch_mem(mem, wss, write_cycle);
		stop  = get_cycles();
		hot3 = stop - start;
#if defined(__i386__) || defined(__x86_64__)
		if (!best_effort)
			sti();
#endif
		migrate_to(next_cpu);
		sleep_us(delay);

#if defined(__i386__) || defined(__x86_64__)
		if (!best_effort)
			cli();
#endif
		start = get_cycles();
		mem[0] = touch_mem(mem, wss, write_cycle);
		stop  = get_cycles();
#if defined(__i386__) || defined(__x86_64__)
		if (!best_effort)
			sti();
#endif
		after_resume = stop - start;


		/* run, write ratio, wss, delay, from, to, cold, hot1, hot2,
		 * hot3, after_resume */
		if (show) {
			fprintf(outfile,
				" %6ld, %6d, %6d, %6d, %3d, %3d, "
				"%10" CYCLES_FMT ", "
				"%10" CYCLES_FMT ", "
				"%10" CYCLES_FMT ", "
				"%10" CYCLES_FMT ", "
				"%10" CYCLES_FMT ", "
				"%12lu",
				counter++, write_cycle,
				wss, delay, last_cpu, next_cpu, cold,
				hot1, hot2, hot3,
				after_resume,
				(unsigned long) mem);
			get_phys_addrs(0,
				(unsigned long) mem,
				wss * 1024 + (unsigned long) mem,
				phys_addrs,
				wss);
			for (i = 0; i < num_pages; i++)
				fprintf(outfile, ", %12lu", phys_addrs[i]);
			fprintf(outfile, "\n");
		}
		if (next_cpu == last_cpu)
			preempt_counter++;
		else
			migration_counter++;
		last_cpu = next_cpu;
		deallocate(mem);
	}
	free(phys_addrs);
}