1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/thread_exit/main.c
Lucas Jenss 426170b064 Improve naming of thread stacksize/priority constants
As discussed in #2725, this commit renames a number of stacksize constants to
better convey their intended usage. In addition, constants for thread priority
are given a `THREAD_` prefix. Changes are:

* KERNEL_CONF_STACKSIZE_PRINTF renamed to THREAD_EXTRA_STACKSIZE_PRINTF
* KERNEL_CONF_STACKSIZE_DEFAULT renamed to THREAD_STACKSIZE_DEFAULT
* KERNEL_CONF_STACKSIZE_IDLE renamed to THREAD_STACKSIZE_IDLE
* KERNEL_CONF_STACKSIZE_MAIN renamed to THREAD_STACKSIZE_MAIN
* Move thread stacksizes from kernel.h to thread.h, since the prefix changed
* PRIORITY_MIN renamed to THREAD_PRIORITY_MIN
* PRIORITY_IDLE renamed to THREAD_PRIORITY_IDLE
* PRIORITY_MAIN renamed to THREAD_PRIORITY_MAIN
* Move thread priorities from kernel.h to thread.h since the prefix has changed
* MINIMUM_STACK_SIZE renamed to THREAD_STACKSIZE_MINIMUM for consistency
2015-05-21 00:14:23 +02:00

98 lines
1.9 KiB
C

/*
* Copyright (C) 2013 INRIA
*
* 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.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Thread test application
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*
* @}
*/
#include <stdio.h>
#include "thread.h"
char second_thread_stack[THREAD_STACKSIZE_MAIN];
char third_thread_stack[THREAD_STACKSIZE_MAIN];
void *fourth_thread(void *arg)
{
(void) arg;
puts("4th: starting");
puts("4th: exiting");
return NULL;
}
void *third_thread(void *arg)
{
(void) arg;
puts("3rd: starting");
puts("3rd: exiting");
return NULL;
}
void *second_thread(void *arg)
{
(void) arg;
puts("2nd: starting");
if ((thread_create(
third_thread_stack,
sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 2,
CREATE_STACKTEST,
third_thread,
NULL,
"nr3")
) == -1) {
puts("2nd: Error creating 3rd thread.");
}
/* thread should have returned already */
if ((thread_create(
third_thread_stack,
sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
fourth_thread,
NULL,
"nr4")
) == -1) {
puts("2nd: Error creating 4rd thread.");
}
puts("2nd: exiting");
return NULL;
}
int main(void)
{
puts("main: starting");
if ((thread_create(
second_thread_stack,
sizeof(second_thread_stack),
THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
second_thread,
NULL,
"nr2")
) == -1) {
puts("main: Error creating 3rd thread.");
}
puts("main: exiting");
return 0;
}