diff --git a/projects/test_suite/Jamfile b/projects/test_suite/Jamfile index eb5ff2d43bd9fc0c295ae810534eb9f15019ff8c..dfb96deb7dd10261cb82f00a2026b3c954474022 100644 --- a/projects/test_suite/Jamfile +++ b/projects/test_suite/Jamfile @@ -6,7 +6,7 @@ SubDir TOP projects test_suite ; -Module test_suite : test_suite.c mutex_trylock_fail.c - : shell posix_io ps uart0 ; +Module test_suite : test_suite.c mutex_trylock_fail.c thread_sleep.c + : shell posix_io ps uart0 hwtimer ; UseModule test_suite ; diff --git a/projects/test_suite/thread_sleep.c b/projects/test_suite/thread_sleep.c new file mode 100644 index 0000000000000000000000000000000000000000..c4bc3294a3e9717ca6f8871b143ff9d5964023b9 --- /dev/null +++ b/projects/test_suite/thread_sleep.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <thread.h> +#include <kernel.h> + +static int integer = 0; +static int i = 0; + +static void second_thread(void) { + while(1) { + integer++; + printf("sleeper: running. integer=%i, i=%i.\n", integer, i); + if (integer % 10 == 0) { + printf("Going to sleep.\n"); + thread_sleep(); + printf("Woke up!\n"); + } + } +} + +static char second_thread_stack[KERNEL_CONF_STACKSIZE_DEFAULT*2]; +static tcb second_thread_tcb; + +void test_thread_sleep(char* line) +{ + int pid = thread_create(&second_thread_tcb, second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_STACKTEST | CREATE_SLEEPING | CREATE_WOUT_YIELD, second_thread, "sleeper"); + + if (pid < 0) { + puts("Error creating second_thread! Stopping test."); + while(1); + } + + while(1) { + i++; + printf(" main: running. integer=%i, i=%i.\n", integer, i); + if (i % 10 == 0) { + printf("Waking up sleeper.\n"); + thread_wakeup(pid); + } + } +}