2014-01-10 16:21:35 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "thread.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
|
|
|
|
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
|
|
|
char third_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
|
|
|
|
2014-01-25 11:29:35 +01:00
|
|
|
void fourth_thread(void)
|
|
|
|
{
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("4th: starting");
|
|
|
|
puts("4th: exiting");
|
|
|
|
}
|
|
|
|
|
2014-01-25 11:29:35 +01:00
|
|
|
void third_thread(void)
|
|
|
|
{
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("3rd: starting");
|
|
|
|
puts("3rd: exiting");
|
|
|
|
}
|
|
|
|
|
2014-01-25 11:29:35 +01:00
|
|
|
void second_thread(void)
|
|
|
|
{
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("2nd: starting");
|
|
|
|
|
|
|
|
if ((thread_create(
|
2014-01-25 11:29:35 +01:00
|
|
|
third_thread_stack,
|
|
|
|
sizeof(third_thread_stack),
|
|
|
|
PRIORITY_MAIN - 2,
|
|
|
|
CREATE_STACKTEST,
|
|
|
|
third_thread,
|
|
|
|
"nr3")
|
2014-01-10 16:21:35 +01:00
|
|
|
) == -1) {
|
|
|
|
puts("2nd: Error creating 3rd thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* thread should have returned already */
|
|
|
|
|
|
|
|
if ((thread_create(
|
2014-01-25 11:29:35 +01:00
|
|
|
third_thread_stack,
|
|
|
|
sizeof(third_thread_stack),
|
|
|
|
PRIORITY_MAIN - 1,
|
|
|
|
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
|
|
|
fourth_thread,
|
|
|
|
"nr4")
|
2014-01-10 16:21:35 +01:00
|
|
|
) == -1) {
|
|
|
|
puts("2nd: Error creating 4rd thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
puts("2nd: exiting");
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
puts("main: starting");
|
2014-01-25 11:29:35 +01:00
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
if ((thread_create(
|
2014-01-25 11:29:35 +01:00
|
|
|
second_thread_stack,
|
|
|
|
sizeof(second_thread_stack),
|
|
|
|
PRIORITY_MAIN - 1,
|
|
|
|
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
|
|
|
second_thread,
|
|
|
|
"nr2")
|
2014-01-10 16:21:35 +01:00
|
|
|
) == -1) {
|
|
|
|
puts("main: Error creating 3rd thread.");
|
|
|
|
}
|
2014-01-25 11:29:35 +01:00
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("main: exiting");
|
|
|
|
}
|