VOID Test3 ( ) { printf("\n-:: Test 3 - BEGIN ::-\n\n"); UtCreate(Test3_FirstThread, NULL); UtRun(AVAILABLE_PROCESSORS); printf("\n-:: Test 3 - END ::-\n"); }
void EX1_TEST() { UtInit(); _tprintf(_T("\n ::: *** -- Starting EXERCICIO 1 (UtJoin function) TEST -- *** ::: \n")); UtCreate(auxFunction_for_Ex1, NULL); testerHandle = UtCreate(uselessFunction, (UT_ARGUMENT)5); UtRun(); _tprintf(_T("\n\n ::: *** -- EXERCICIO 1 - TEST COMPLETED -- *** ::: \n")); UtEnd(); }
VOID Test1 () { ULONG Index; Test1_Count = 0; printf("\n :: Test 1 - BEGIN :: \n\n"); for (Index = 0; Index < MAX_THREADS; ++Index) { UtCreate(Test1_Thread, (UT_ARGUMENT) ('0' + Index)); } UtRun(); _ASSERTE(Test1_Count == MAX_THREADS); printf("\n\n :: Test 1 - END :: \n"); }
VOID Test1() { ULONG Index; Test1_Count = 0; int stSize = 4 * 1024; printf("\n :: Test 1 - BEGIN :: \n\n"); UCHAR c = 'a'; for (Index = 0; Index < MAX_THREADS; ++Index) { UtCreate(Test1_Thread, (UT_ARGUMENT)('0' + Index), (&c), stSize); } UtRun(); _ASSERTE(Test1_Count == MAX_THREADS); printf("\n\n :: Test 1 - END :: \n"); }
VOID Test1 () { ULONG Index; Test1_Count = 0; printf("\n :: Test 1 - BEGIN :: \n\n"); for (Index = 0; Index < MAX_THREADS; ++Index) { UtCreate(Test1_Thread, (UT_ARGUMENT)('0' + Index), 16 * 4096 , _T("ThreadName")); } UtDump(STACK_SIZE); UtRun(); UtDump(STACK_SIZE); _ASSERTE(Test1_Count == MAX_THREADS); UtEnd(); printf("\n\n :: Test 1 - END :: \n"); }
VOID Test1() { ULONG Index; Test1_Count = 0; printf("\n :: Test 1 b) - BEGIN :: \n\n"); for (Index = 0; Index < MAX_THREADS; ++Index) { handleArray[Index] = UtCreate(Test1_Thread, (UT_ARGUMENT)('0' + Index)); } printf("Print Threads Alive \n"); PrintUtThreadAlive(handleArray); UtRun(); _ASSERTE(Test1_Count == MAX_THREADS); printf("\n\n :: Test 1 b) - END :: \n"); }
static VOID ClientServerMsg() { LONG vals[] = {1,2,3,4,5,6}; CLIENT_ARGS cargs; cargs.numbers = vals; cargs.totalNumbers = sizeof(vals)/sizeof(LONG); InitializeListHead(&QMSG); UtInit(); ClientId = UtCreate(Client, (UT_ARGUMENT) &cargs,16*4096,NULL); ServerId = UtCreate(Server, NULL, 16*4096,NULL); UtRun(); UtEnd(); printf("ClientServerMsg Test Done!\n"); }
VOID Test1 ( ) { ULONG Index; Test1_Count = 0; printf("\n :: Test 1 - BEGIN :: \n\n"); for (Index = 0; Index < 10; ++Index) { UtCreate(Test1_Thread, (UT_ARGUMENT) ('0' + Index)); } UtRun(AVAILABLE_PROCESSORS); _ASSERTE(Test1_Count == 10); printf("\n\n :: Test 1 - END :: \n"); }
int main(){ UtInit(); //JoinTest(); /* Ex1_Test */ //SleepTest(); /* Ex2_Test */ /* Escreva programas para determinar o tempo de comutação de threads na biblioteca UThread. Para a medição de tempos, utilize a função da Windows API GetTickCount. */ SwitchTest(); /* Ex3_Test */ UtRun(); printf("\nPress any key to finish"); getchar(); UtEnd(); return 0; }
VOID Test1() { ULONG Index; Test1_Count = 0; printf("\n :: Test 1 a) - BEGIN :: \n\n"); HANDLE handleArray[MAX_THREADS]; for (Index = 0; Index < MAX_THREADS; ++Index) { handleArray[Index] = UtCreate(Test1_Thread, (UT_ARGUMENT)('0' + Index)); printf("Client %d: State = %d\n", Index, UtThreadState(handleArray[Index])); } UtRun(); _ASSERTE(Test1_Count == MAX_THREADS); printf("\n\n :: Test 1 a) - END :: \n"); }
int main(int argc, const char * argv[]) { if (argc != 3) { fprintf(stderr, "use: %s input_file filter_char\n", argv[0]); exit(1); } UtInit(); Prepare(); UtCreate(ReaderThread, (UT_ARGUMENT)argv[1]); UtCreate(FilterThread, (UT_ARGUMENT)argv[2][0]); UtCreate(PrinterThread, (UT_ARGUMENT)0); UtRun(); UtEnd(); return 0; }
int main(int argc, char* argv[]) { int i; InitConsole(); ClearScreen(BACKGROUND_GRAY, BLACK); UtInit(); UtCreate(Stopper, (UTHREAD_ARGUMENT) SIMULATION_TIME); for (i=0; i < PARTICLES_NUMBER; ++i ) UtCreate(RainParticle, NULL); UtRun(); UtEnd(); ClearScreen(BACKGROUND_WHITE, BLACK); printf("End of Simulation!\n"); return 0; }
VOID Test2 ( ) { UTHREAD_MUTEX Mutex; UtInitializeMutex(&Mutex, FALSE); printf("\n-:: Test 2 - BEGIN ::-\n\n"); Test2_Count = 0; UtCreate(Test2_Thread1, &Mutex); UtCreate(Test2_Thread2, &Mutex); UtCreate(Test2_Thread3, &Mutex); UtRun(AVAILABLE_PROCESSORS); _ASSERTE(Test2_Count == 3); printf("\n-:: Test 2 - END ::-\n"); }
void EX2_TEST() { totalEx2Tests = 4, currentEx2Test = 1; UtInit(); _tprintf(_T("\n ::: *** -- Starting EXERCICIO 2 (UtSleep function) TEST -- *** ::: \n")); // Wait more than 0 milliseconds UtCreate(auxFunction_for_Ex2, (UT_ARGUMENT)0); // Wait more than 2000 milliseconds UtCreate(auxFunction_for_Ex2, (UT_ARGUMENT)2000); // Wait more than 10000 milliseconds UtCreate(auxFunction_for_Ex2, (UT_ARGUMENT)10000); // Wait more than 13000 milliseconds UtCreate(auxFunction_for_Ex2, (UT_ARGUMENT)13000); UtRun(); _tprintf(_T("\n\n ::: *** -- EXERCICIO 2 - TEST COMPLETED -- *** ::: \n")); UtEnd(); }
void EX3_TEST() { UtInit(); _tprintf(_T("\n ::: *** -- Starting EXERCICIO 3 (CONTEXT SWITCH TIME) TEST -- *** ::: \n")); totalEx3Tests = 5; currentEx3Test = 1; ex3FunctionsFinished = 0; test3MustEnd = FALSE; // Create the thread that will wake the others in case they are ALL sleeping UtCreate(auxFunctionThatYields, (UT_ARGUMENT)NULL); UtCreate((UT_FUNCTION)veryUselessTimeConsumingFunction, (UT_ARGUMENT)1000); //1 s UtCreate((UT_FUNCTION)veryUselessTimeConsumingFunction, (UT_ARGUMENT)2000); //2 s UtCreate((UT_FUNCTION)veryUselessTimeConsumingFunction, (UT_ARGUMENT)5000); //5 s UtCreate((UT_FUNCTION)veryUselessTimeConsumingFunction, (UT_ARGUMENT)10000); //10 s UtCreate((UT_FUNCTION)veryUselessTimeConsumingFunction, (UT_ARGUMENT)12000); //12 s UtRun(); _tprintf(_T("\n\n ::: *** -- EXERCICIO 3 - TEST COMPLETED -- *** ::: \n")); UtEnd(); }
DWORD _tmain( DWORD argc, PTCHAR argv[] ) { long numbers[MAX_WORK] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; UtInit(); utClient = UtCreate(Client, numbers); utServer = UtCreate(Server, numbers); UtRun(); UtEnd(); printf("factoriais:\n\t"); for (int i = 0; i < MAX_WORK; i++) printf("%d ", numbers[i]); putchar('\n'); printf("Press enter key to finish...\n"); getchar(); return 0; }