Esempio n. 1
0
File: lockt.c Progetto: aahud/harvey
void
main(void)
{
	int64_t start, elapsed, res;
	static Lock l;

	rfork(RFNOTEG|RFREND);
	rStart.l = &rl;
	rCompleted.l = &rl;
	resInWaiter = 0xff;

	spawnWaiter(&l);
	lock(&l);

	alarm(20000);	/* global timeout, FAIL if reached */
	if (!atnotify(failOnTimeout, 1)){
		fprint(2, "%r\n");
		exits("atnotify fails");
	}

	/* verify that lockt returns 0 on timeout */
	start = nsec();
	res = lockt(&l, 1000);
	elapsed = (nsec() - start) / (1000 * 1000);
	if(verbose)
		print("lockt returned %d, elapsed = %d ms\n", res, elapsed);
	if(res != 0 || elapsed < 900 || elapsed > 1300){
		print("FAIL: lockt timeout\n");
		exits("FAIL");
	}

	/* verify that lockt returns 1 if the lock is released and
	 * it can take it
	 */
	resInWaiter = -1;
	qlock(&rl);
	rwakeupall(&rStart);
	qunlock(&rl);
	sleep(1200);
	unlock(&l);

	qlock(&rl);
	while(elapsedInWaiter == 0)
		rsleep(&rCompleted);
	qunlock(&rl);
	if(resInWaiter != 1 || elapsedInWaiter < 1100 || elapsedInWaiter > 1500){
		print("FAIL: lockt delayed acquisition\n");
		exits("FAIL");
	}

	print("PASS\n");
	exits("PASS");
}
Esempio n. 2
0
GameController::GameController() {
   spawnTimer = new Timer(false, 20000);
   monthTimer = new Timer(false, 20000);
   groupTimer = new Timer(false, 20000);
   srand((unsigned)time(0));
   isMonthBreak = false;
   gameUI = GameUI::getInstance();
   monthDay = 0;
   Tween *monthDays = new Tween(&monthDay, Tween::EASE_NONE, 1, 31, MONTH_TIME_SECONDS);
   spawnTime = 8;
   
   maxInGroup = 4;
   spawnGroupToggle = false;
   table = NULL;
   tableList = TavernResources::getInstance()->tablesList;
   gameData = GameData::getInstance();
   spawnMC();
   spawnWaiter();
   //spawnWaiter();
}