From 890c5532da783e8d58cfbf28822bcedaa8a0c61d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 14 Nov 2007 16:32:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@90 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 75 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'test/test.c') diff --git a/test/test.c b/test/test.c index 8fe61794c..a40a059f3 100644 --- a/test/test.c +++ b/test/test.c @@ -19,6 +19,8 @@ #include +void ChkIntSources(void); + #if defined(WIN32) && defined(_DEBUG) static BYTE8 wsT1[UserStackSize(512)]; static BYTE8 wsT2[UserStackSize(512)]; @@ -126,6 +128,7 @@ t_msg Thread6(void *p) { t_msg TestThread(void *p) { t_msg msg; unsigned int i; + t_time time; comp = p; println("*****************************"); @@ -137,19 +140,19 @@ t_msg TestThread(void *p) { * Ready list ordering test. */ println("*** Ready List, priority enqueuing test #1, you should read ABCDE:"); - t5 = chThdCreate(NORMALPRIO-5, 0, wsT5, sizeof(wsT5), Thread1, "E"); - t4 = chThdCreate(NORMALPRIO-4, 0, wsT4, sizeof(wsT4), Thread1, "D"); - t3 = chThdCreate(NORMALPRIO-3, 0, wsT3, sizeof(wsT3), Thread1, "C"); - t2 = chThdCreate(NORMALPRIO-2, 0, wsT2, sizeof(wsT2), Thread1, "B"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread1, "A"); + t5 = chThdCreate(chThdGetPriority()-5, 0, wsT5, sizeof(wsT5), Thread1, "E"); + t4 = chThdCreate(chThdGetPriority()-4, 0, wsT4, sizeof(wsT4), Thread1, "D"); + t3 = chThdCreate(chThdGetPriority()-3, 0, wsT3, sizeof(wsT3), Thread1, "C"); + t2 = chThdCreate(chThdGetPriority()-2, 0, wsT2, sizeof(wsT2), Thread1, "B"); + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread1, "A"); wait(); println(""); println("*** Ready List, priority enqueuing test #2, you should read ABCDE:"); - t4 = chThdCreate(NORMALPRIO-4, 0, wsT4, sizeof(wsT4), Thread1, "D"); - t5 = chThdCreate(NORMALPRIO-5, 0, wsT5, sizeof(wsT5), Thread1, "E"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread1, "A"); - t2 = chThdCreate(NORMALPRIO-2, 0, wsT2, sizeof(wsT2), Thread1, "B"); - t3 = chThdCreate(NORMALPRIO-3, 0, wsT3, sizeof(wsT3), Thread1, "C"); + t4 = chThdCreate(chThdGetPriority()-4, 0, wsT4, sizeof(wsT4), Thread1, "D"); + t5 = chThdCreate(chThdGetPriority()-5, 0, wsT5, sizeof(wsT5), Thread1, "E"); + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread1, "A"); + t2 = chThdCreate(chThdGetPriority()-2, 0, wsT2, sizeof(wsT2), Thread1, "B"); + t3 = chThdCreate(chThdGetPriority()-3, 0, wsT3, sizeof(wsT3), Thread1, "C"); wait(); println(""); @@ -158,11 +161,11 @@ t_msg TestThread(void *p) { */ chSemInit(&sem1, 0); println("*** Semaphores, FIFO enqueuing test, you should read ABCDE:"); - t1 = chThdCreate(NORMALPRIO+5, 0, wsT1, sizeof(wsT1), Thread2, "A"); - t2 = chThdCreate(NORMALPRIO+1, 0, wsT2, sizeof(wsT2), Thread2, "B"); - t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread2, "C"); - t4 = chThdCreate(NORMALPRIO+4, 0, wsT4, sizeof(wsT4), Thread2, "D"); - t5 = chThdCreate(NORMALPRIO+2, 0, wsT5, sizeof(wsT5), Thread2, "E"); + t1 = chThdCreate(chThdGetPriority()+5, 0, wsT1, sizeof(wsT1), Thread2, "A"); + t2 = chThdCreate(chThdGetPriority()+1, 0, wsT2, sizeof(wsT2), Thread2, "B"); + t3 = chThdCreate(chThdGetPriority()+3, 0, wsT3, sizeof(wsT3), Thread2, "C"); + t4 = chThdCreate(chThdGetPriority()+4, 0, wsT4, sizeof(wsT4), Thread2, "D"); + t5 = chThdCreate(chThdGetPriority()+2, 0, wsT5, sizeof(wsT5), Thread2, "E"); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); @@ -172,11 +175,11 @@ t_msg TestThread(void *p) { println(""); println("*** Semaphores, priority enqueuing test #1, you should read ABCDE:"); chSemInit(&sem1, 0); - t5 = chThdCreate(NORMALPRIO+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); - t4 = chThdCreate(NORMALPRIO+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); - t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread3, "C"); - t2 = chThdCreate(NORMALPRIO+4, 0, wsT2, sizeof(wsT2), Thread3, "B"); - t1 = chThdCreate(NORMALPRIO+5, 0, wsT1, sizeof(wsT1), Thread3, "A"); + t5 = chThdCreate(chThdGetPriority()+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); + t4 = chThdCreate(chThdGetPriority()+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); + t3 = chThdCreate(chThdGetPriority()+3, 0, wsT3, sizeof(wsT3), Thread3, "C"); + t2 = chThdCreate(chThdGetPriority()+4, 0, wsT2, sizeof(wsT2), Thread3, "B"); + t1 = chThdCreate(chThdGetPriority()+5, 0, wsT1, sizeof(wsT1), Thread3, "A"); chSemLowerPrioSignal(&sem1); chSemLowerPrioSignal(&sem1); chSemLowerPrioSignal(&sem1); @@ -186,11 +189,11 @@ t_msg TestThread(void *p) { println(""); println("*** Semaphores, priority enqueuing test #2, you should read ABCDE:"); chSemInit(&sem1, 0); - t4 = chThdCreate(NORMALPRIO+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); - t5 = chThdCreate(NORMALPRIO+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); - t1 = chThdCreate(NORMALPRIO+5, 0, wsT1, sizeof(wsT1), Thread3, "A"); - t2 = chThdCreate(NORMALPRIO+4, 0, wsT2, sizeof(wsT2), Thread3, "B"); - t3 = chThdCreate(NORMALPRIO+3, 0, wsT3, sizeof(wsT3), Thread3, "C"); + t4 = chThdCreate(chThdGetPriority()+2, 0, wsT4, sizeof(wsT4), Thread3, "D"); + t5 = chThdCreate(chThdGetPriority()+1, 0, wsT5, sizeof(wsT5), Thread3, "E"); + t1 = chThdCreate(chThdGetPriority()+5, 0, wsT1, sizeof(wsT1), Thread3, "A"); + t2 = chThdCreate(chThdGetPriority()+4, 0, wsT2, sizeof(wsT2), Thread3, "B"); + t3 = chThdCreate(chThdGetPriority()+3, 0, wsT3, sizeof(wsT3), Thread3, "C"); chSemLowerPrioSignal(&sem1); chSemLowerPrioSignal(&sem1); chSemLowerPrioSignal(&sem1); @@ -210,7 +213,7 @@ t_msg TestThread(void *p) { * Messages test. */ println("*** Messages, dispatch test, you should read AABBCCDDEE:"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread4, chThdSelf()); + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread4, chThdSelf()); do { chMsgRelease(msg = chMsgWait()); if (msg) @@ -219,7 +222,7 @@ t_msg TestThread(void *p) { chThdWait(t1); println(""); println("*** Messages, timeout test, you should read ABCDE (slowly):"); - t1 = chThdCreate(NORMALPRIO-1, 0, wsT1, sizeof(wsT1), Thread5, chThdSelf()); + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread5, chThdSelf()); for (i = 0; i < 5; i++) { chFDDPut(comp, 'A'+i); chMsgSendTimeout(t1, 'A'+i, 500); @@ -232,16 +235,22 @@ t_msg TestThread(void *p) { * Kernel benchmarks. */ println("*** Kernel Benchmark, context switch stress test:"); - t_time time = chSysGetTime() + 1; - while (chSysGetTime() < time) - ; + time = chSysGetTime() + 1; + while (chSysGetTime() < time) { +#if defined(WIN32) + ChkIntSources(); +#endif + } time += 1000; i = 0; - t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread6, chThdSelf()); - while (chSysGetTime() < time) + t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread6, chThdSelf()); + while (chSysGetTime() < time) { i = chMsgSend(t1, i); +#if defined(WIN32) + ChkIntSources(); +#endif + } chThdTerminate(t1); - chMsgSend(t1, 0); /* Lets the thread check the termination flag.*/ chThdWait(t1); print("Messages throughput = "); printn(i); -- cgit v1.2.3