[app][tests] a few tweaks to some tests
-Add more interesting names to fibo threads -Iterate a lot more on some of the thread tests (for faster cpus) -Add spinner command that lets you add threads that spin forever
This commit is contained in:
@@ -41,12 +41,15 @@ static int fibo_thread(void *argv)
|
||||
if (fibo == 1)
|
||||
return 1;
|
||||
|
||||
t[0] = thread_create("fibo", &fibo_thread, (void *)(fibo - 1), DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
char name[32];
|
||||
snprintf(name, sizeof(name), "fibo %lu", fibo - 1);
|
||||
t[0] = thread_create(name, &fibo_thread, (void *)(fibo - 1), DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
if (!t[0]) {
|
||||
printf("error creating thread for fibo %d\n", fibo-1);
|
||||
return 0;
|
||||
}
|
||||
t[1] = thread_create("fibo", &fibo_thread, (void *)(fibo - 2), DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
snprintf(name, sizeof(name), "fibo %lu", fibo - 2);
|
||||
t[1] = thread_create(name, &fibo_thread, (void *)(fibo - 2), DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
if (!t[1]) {
|
||||
printf("error creating thread for fibo %d\n", fibo-2);
|
||||
thread_resume(t[0]);
|
||||
@@ -89,4 +92,5 @@ int fibo(int argc, const cmd_args *argv)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
// vim: set noexpandtab:
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ void clock_tests(void);
|
||||
void float_tests(void);
|
||||
void benchmarks(void);
|
||||
int fibo(int argc, const cmd_args *argv);
|
||||
int spinner(int argc, const cmd_args *argv);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ STATIC_COMMAND("float_tests", "floating point test", (console_cmd)&float_tests)
|
||||
#endif
|
||||
STATIC_COMMAND("bench", "miscellaneous benchmarks", (console_cmd)&benchmarks)
|
||||
STATIC_COMMAND("fibo", "threaded fibonacci", (console_cmd)&fibo)
|
||||
STATIC_COMMAND("spinner", "create a spinning thread", (console_cmd)&spinner)
|
||||
STATIC_COMMAND_END(tests);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -131,7 +131,7 @@ static int semaphore_test(void)
|
||||
static int mutex_thread(void *arg)
|
||||
{
|
||||
int i;
|
||||
const int iterations = 50000;
|
||||
const int iterations = 1000000;
|
||||
|
||||
static volatile int shared = 0;
|
||||
|
||||
@@ -406,9 +406,11 @@ static int atomic_tester(void *arg)
|
||||
int add = (intptr_t)arg;
|
||||
int i;
|
||||
|
||||
TRACEF("add %d\n", add);
|
||||
const int iter = 10000000;
|
||||
|
||||
for (i=0; i < 1000000; i++) {
|
||||
TRACEF("add %d, %d iterations\n", add, iter);
|
||||
|
||||
for (i=0; i < iter; i++) {
|
||||
atomic_add(&atomic, add);
|
||||
}
|
||||
|
||||
@@ -632,4 +634,27 @@ int thread_tests(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spinner_thread(void *arg)
|
||||
{
|
||||
for (;;)
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spinner(int argc, const cmd_args *argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("not enough args\n");
|
||||
printf("usage: %s <priority>\n", argv[0].str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
thread_t *t = thread_create("spinner", spinner_thread, NULL, argv[1].u, DEFAULT_STACK_SIZE);
|
||||
if (t)
|
||||
thread_resume(t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 noexpandtab: */
|
||||
|
||||
Reference in New Issue
Block a user