2014-02-03 23:03:13 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 INRIA
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
2014-02-03 23:03:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup tests
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Thread test application
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "thread.h"
|
|
|
|
|
2015-04-28 20:02:05 +02:00
|
|
|
char second_thread_stack[THREAD_STACKSIZE_MAIN];
|
|
|
|
char third_thread_stack[THREAD_STACKSIZE_MAIN];
|
2014-01-10 16:21:35 +01:00
|
|
|
|
2014-03-04 20:20:01 +01:00
|
|
|
void *fourth_thread(void *arg)
|
2014-01-25 11:29:35 +01:00
|
|
|
{
|
2014-03-04 20:20:01 +01:00
|
|
|
(void) arg;
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("4th: starting");
|
|
|
|
puts("4th: exiting");
|
2014-03-04 20:20:01 +01:00
|
|
|
return NULL;
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
|
|
|
|
2014-03-04 20:20:01 +01:00
|
|
|
void *third_thread(void *arg)
|
2014-01-25 11:29:35 +01:00
|
|
|
{
|
2014-03-04 20:20:01 +01:00
|
|
|
(void) arg;
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("3rd: starting");
|
|
|
|
puts("3rd: exiting");
|
2014-03-04 20:20:01 +01:00
|
|
|
return NULL;
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
|
|
|
|
2014-03-04 20:20:01 +01:00
|
|
|
void *second_thread(void *arg)
|
2014-01-25 11:29:35 +01:00
|
|
|
{
|
2014-03-04 20:20:01 +01:00
|
|
|
(void) arg;
|
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),
|
2015-04-28 20:02:05 +02:00
|
|
|
THREAD_PRIORITY_MAIN - 2,
|
2015-12-02 12:00:37 +01:00
|
|
|
THREAD_CREATE_STACKTEST,
|
2014-01-25 11:29:35 +01:00
|
|
|
third_thread,
|
2014-03-04 20:20:01 +01:00
|
|
|
NULL,
|
2014-01-25 11:29:35 +01:00
|
|
|
"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),
|
2015-04-28 20:02:05 +02:00
|
|
|
THREAD_PRIORITY_MAIN - 1,
|
2015-12-02 12:00:37 +01:00
|
|
|
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
2014-01-25 11:29:35 +01:00
|
|
|
fourth_thread,
|
2014-03-04 20:20:01 +01:00
|
|
|
NULL,
|
2014-01-25 11:29:35 +01:00
|
|
|
"nr4")
|
2014-01-10 16:21:35 +01:00
|
|
|
) == -1) {
|
2016-06-28 16:14:00 +02:00
|
|
|
puts("2nd: Error creating 4th thread.");
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
puts("2nd: exiting");
|
2014-03-04 20:20:01 +01:00
|
|
|
return NULL;
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
2015-04-28 20:02:05 +02:00
|
|
|
THREAD_PRIORITY_MAIN - 1,
|
2015-12-02 12:00:37 +01:00
|
|
|
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
2014-01-25 11:29:35 +01:00
|
|
|
second_thread,
|
2014-03-04 20:20:01 +01:00
|
|
|
NULL,
|
2014-01-25 11:29:35 +01:00
|
|
|
"nr2")
|
2014-01-10 16:21:35 +01:00
|
|
|
) == -1) {
|
2016-06-28 16:14:00 +02:00
|
|
|
puts("main: Error creating 2nd thread.");
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
2014-01-25 11:29:35 +01:00
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
puts("main: exiting");
|
2014-06-20 20:00:20 +02:00
|
|
|
return 0;
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|