aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-13 16:38:23 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-13 16:38:23 +0000
commite776216d02920673266e31d553078f4edec4a264 (patch)
tree3234cf9898f59dec30092da35cc4f1dd76f77b03 /test
parent95618293b7e096240966c715eb9f5f2f420f9588 (diff)
downloadChibiOS-e776216d02920673266e31d553078f4edec4a264.tar.gz
ChibiOS-e776216d02920673266e31d553078f4edec4a264.tar.bz2
ChibiOS-e776216d02920673266e31d553078f4edec4a264.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@89 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r--test/test.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/test/test.c b/test/test.c
index fbaedd280..8fe61794c 100644
--- a/test/test.c
+++ b/test/test.c
@@ -46,10 +46,29 @@ static void wait(void) {
chThdWait(t5);
}
-static void println(char *msgp) {
+static void printn(unsigned int n) {
+ char buf[16], *p;
+
+ if (!n)
+ chFDDPut(comp, '0');
+ else {
+ p = buf;
+ while (n)
+ *p++ = (n % 10) + '0', n /= 10;
+ while (p > buf)
+ chFDDPut(comp, *--p);
+ }
+}
+
+static void print(char *msgp) {
while (*msgp)
chFDDPut(comp, *msgp++);
+}
+
+static void println(char *msgp) {
+
+ print(msgp);
chFDDPut(comp, '\r');
chFDDPut(comp, '\n');
}
@@ -94,12 +113,19 @@ t_msg Thread5(void *p) {
return 0;
}
+t_msg Thread6(void *p) {
+
+ while (!chThdShouldTerminate())
+ chMsgRelease(chMsgWait() + 1);
+ return 0;
+}
+
/**
* Tester thread, this thread must be created with priority \p NORMALPRIO.
*/
t_msg TestThread(void *p) {
t_msg msg;
- int i;
+ unsigned int i;
comp = p;
println("*****************************");
@@ -202,6 +228,27 @@ t_msg TestThread(void *p) {
chThdWait(t1);
println("");
+ /*
+ * Kernel benchmarks.
+ */
+ println("*** Kernel Benchmark, context switch stress test:");
+ t_time time = chSysGetTime() + 1;
+ while (chSysGetTime() < time)
+ ;
+ time += 1000;
+ i = 0;
+ t1 = chThdCreate(NORMALPRIO+1, 0, wsT1, sizeof(wsT1), Thread6, chThdSelf());
+ while (chSysGetTime() < time)
+ i = chMsgSend(t1, i);
+ chThdTerminate(t1);
+ chMsgSend(t1, 0); /* Lets the thread check the termination flag.*/
+ chThdWait(t1);
+ print("Messages throughput = ");
+ printn(i);
+ print(" msg/S, ");
+ printn(i << 1);
+ println(" ctxsw/S");
+
println("\r\nTest complete");
return 0;
}