Пример #1
0
/*
 * Communicates with simptris
 */
void CommunicationTask(void) {
	scmd* ncmd;

	SeedSimptris((long) SEED);
	StartSimptris();
	printString("\nSimptris Started!\n");
	
	while(1) {

		ncmd = (scmd*) YKQPend(CmdQPtr);
		if (ncmd->command == ROTATE) {
			RotatePiece(ncmd->id, ncmd->parameter);
		}
		else {
			SlidePiece(ncmd->id, ncmd->parameter);
		}
		YKSemPend(commandReceivedSem);
	}
}
Пример #2
0
void STask(void)           // tracks statistics 
{
    unsigned max, switchCount, idleCount;
    int tmp;

    YKIdleCount = 0;
    YKDelayTask(5);
    max = YKIdleCount / 25;
    YKIdleCount = 0;

	//Start Simptris
	SeedSimptris(SEED);
	StartSimptris();
    
    while (1)
    {
        YKDelayTask(20);
        
        YKEnterMutex();
        switchCount = YKCtxSwCount;
        idleCount = YKIdleCount;
        YKExitMutex();
        
        printString("<CS: ");
        printInt((int)switchCount);
        printString(", CPU: ");
        tmp = (int) (idleCount/max);
        printInt(100-tmp);
        printString(">\n\r");
        
        YKEnterMutex();
        YKCtxSwCount = 0;
        YKIdleCount = 0;
        YKExitMutex();
    }
}