Merge pull request #4382 from haukepetersen/rm_core_flagsh

core: move thread flags from flags.h to thread.h
This commit is contained in:
Hauke Petersen 2015-12-08 11:36:43 +01:00
commit cf53aeddd8
46 changed files with 112 additions and 117 deletions

View File

@ -1,42 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* 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.
*/
/**
* @addtogroup core_internal
* @{
*
* @file
* @brief Misc flag definitions
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef FLAGS_H
#define FLAGS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Optional flags for controlling a threads initial state.
* @{
*/
#define CREATE_SLEEPING (1) /**< set the new thread to sleeping */
#define AUTO_FREE (2) /**< currently not implemented */
#define CREATE_WOUT_YIELD (4) /**< do not automatically call thread_yield() after creation */
#define CREATE_STACKTEST (8) /**< write markers into the thread's stack to measure stack
usage (for debugging) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* FLAGS_H */
/** @} */

View File

@ -29,7 +29,6 @@
#include "config.h" #include "config.h"
#include "tcb.h" #include "tcb.h"
#include "cpu.h" #include "cpu.h"
#include "flags.h"
#include "sched.h" #include "sched.h"
#include "cpu_conf.h" #include "cpu_conf.h"

View File

@ -93,6 +93,32 @@
*/ */
#define THREAD_PRIORITY_MAIN (THREAD_PRIORITY_MIN - (SCHED_PRIO_LEVELS/2)) #define THREAD_PRIORITY_MAIN (THREAD_PRIORITY_MIN - (SCHED_PRIO_LEVELS/2))
/**
* @name Optional flags for controlling a threads initial state
* @{
*/
/**
* @brief Set the new thread to sleeping
**/
#define THREAD_CREATE_SLEEPING (1)
/**
* @brief Currently not implemented
*/
#define THREAD_AUTO_FREE (2)
/**
* @brief Do not automatically call thread_yield() after creation
*/
#define THREAD_CREATE_WOUT_YIELD (4)
/**
* @brief Write markers into the thread's stack to measure stack usage (for
* debugging)
*/
#define THREAD_CREATE_STACKTEST (8)
/** @} */
/** /**
* @brief Creates a new thread * @brief Creates a new thread
* *
@ -113,11 +139,13 @@
* *
* In addition to the priority, the *flags* argument can be used to alter the * In addition to the priority, the *flags* argument can be used to alter the
* newly created threads behavior after creation. The following flags are available: * newly created threads behavior after creation. The following flags are available:
* - CREATE_SLEEPING the newly created thread will be put to sleeping state and * - THREAD_CREATE_SLEEPING the newly created thread will be put to sleeping
* must be waken up manually * state and must be waken up manually
* - CREATE_WOUT_YIELD the newly created thread will not run immediately after creation * - THREAD_CREATE_WOUT_YIELD the newly created thread will not run
* - CREATE_STACKTEST write markers into the thread's stack to measure the stack's memory * immediately after creation
* usage (for debugging and profiling purposes) * - THREAD_CREATE_STACKTEST write markers into the thread's stack to measure
* the stack's memory usage (for debugging and
* profiling purposes)
* *
* @note Currently we support creating threads from within an ISR, however it is considered * @note Currently we support creating threads from within an ISR, however it is considered
* to be a bad programming practice and we strongly discourage it. * to be a bad programming practice and we strongly discourage it.
@ -229,7 +257,7 @@ const char *thread_getname(kernel_pid_t pid);
/** /**
* @brief Measures the stack usage of a stack * @brief Measures the stack usage of a stack
* *
* Only works if the thread was created with the flag CREATE_STACKTEST. * Only works if the thread was created with the flag THREAD_CREATE_STACKTEST.
* *
* @param[in] stack the stack you want to measure. try `sched_active_thread->stack_start` * @param[in] stack the stack you want to measure. try `sched_active_thread->stack_start`
* *

View File

@ -25,7 +25,6 @@
#include "kernel.h" #include "kernel.h"
#include "kernel_internal.h" #include "kernel_internal.h"
#include "sched.h" #include "sched.h"
#include "flags.h"
#include "cpu.h" #include "cpu.h"
#include "lpm.h" #include "lpm.h"
#include "thread.h" #include "thread.h"
@ -95,12 +94,12 @@ void kernel_init(void)
thread_create(idle_stack, sizeof(idle_stack), thread_create(idle_stack, sizeof(idle_stack),
THREAD_PRIORITY_IDLE, THREAD_PRIORITY_IDLE,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
idle_thread, NULL, idle_name); idle_thread, NULL, idle_name);
thread_create(main_stack, sizeof(main_stack), thread_create(main_stack, sizeof(main_stack),
THREAD_PRIORITY_MAIN, THREAD_PRIORITY_MAIN,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
main_trampoline, NULL, main_name); main_trampoline, NULL, main_name);
cpu_switch_context_exit(); cpu_switch_context_exit();

View File

@ -31,8 +31,6 @@
#include "irq.h" #include "irq.h"
#include "cib.h" #include "cib.h"
#include "flags.h"
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
#include "thread.h" #include "thread.h"

View File

@ -148,7 +148,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
tcb_t *cb = (tcb_t *) (stack + stacksize); tcb_t *cb = (tcb_t *) (stack + stacksize);
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) #if defined(DEVELHELP) || defined(SCHED_TEST_STACK)
if (flags & CREATE_STACKTEST) { if (flags & THREAD_CREATE_STACKTEST) {
/* assign each int of the stack the value of it's address */ /* assign each int of the stack the value of it's address */
uintptr_t *stackmax = (uintptr_t *) (stack + stacksize); uintptr_t *stackmax = (uintptr_t *) (stack + stacksize);
uintptr_t *stackp = (uintptr_t *) stack; uintptr_t *stackp = (uintptr_t *) stack;
@ -212,13 +212,13 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, cb->pid, priority); DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, cb->pid, priority);
if (flags & CREATE_SLEEPING) { if (flags & THREAD_CREATE_SLEEPING) {
sched_set_status(cb, STATUS_SLEEPING); sched_set_status(cb, STATUS_SLEEPING);
} }
else { else {
sched_set_status(cb, STATUS_PENDING); sched_set_status(cb, STATUS_PENDING);
if (!(flags & CREATE_WOUT_YIELD)) { if (!(flags & THREAD_CREATE_WOUT_YIELD)) {
restoreIRQ(state); restoreIRQ(state);
sched_switch(priority); sched_switch(priority);
return pid; return pid;

View File

@ -156,7 +156,7 @@ void *tftp_server_wrapper(void *arg)
void tftp_server_start(void) void tftp_server_start(void)
{ {
thread_create(_tftp_stack, sizeof(_tftp_stack), thread_create(_tftp_stack, sizeof(_tftp_stack),
1, CREATE_WOUT_YIELD | CREATE_STACKTEST, 1, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
tftp_server_wrapper, NULL, "TFTP Server"); tftp_server_wrapper, NULL, "TFTP Server");
} }

View File

@ -51,7 +51,7 @@ int main(void)
msg_t m; msg_t m;
kernel_pid_t pid = thread_create(second_thread_stack, sizeof(second_thread_stack), kernel_pid_t pid = thread_create(second_thread_stack, sizeof(second_thread_stack),
THREAD_PRIORITY_MAIN - 1, CREATE_STACKTEST, THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
second_thread, NULL, "pong"); second_thread, NULL, "pong");
m.content.value = 1; m.content.value = 1;

View File

@ -130,7 +130,8 @@ static int udp_start_server(char *port_str)
} }
/* start server (which means registering pktdump for the chosen port) */ /* start server (which means registering pktdump for the chosen port) */
if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1, if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, _server_thread, port_str, "UDP server") <= KERNEL_PID_UNDEF) { THREAD_CREATE_STACKTEST,
_server_thread, port_str, "UDP server") <= KERNEL_PID_UNDEF) {
server_socket = -1; server_socket = -1;
puts("error initializing thread"); puts("error initializing thread");
return 1; return 1;

View File

@ -49,7 +49,9 @@ int main()
printf("\n"); printf("\n");
/* create thread A */ /* create thread A */
thread_create(threadA_stack, sizeof(threadA_stack), 0, CREATE_WOUT_YIELD, threadA_func, NULL, "thread A"); thread_create(threadA_stack, sizeof(threadA_stack), 0,
THREAD_CREATE_WOUT_YIELD,
threadA_func, NULL, "thread A");
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid); printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid);
printf("We'll test C++ class and methods here!\n"); printf("We'll test C++ class and methods here!\n");

View File

@ -228,7 +228,7 @@ thread::thread(F&& f, Args&&... args)
std::unique_ptr<func_and_args> p( std::unique_ptr<func_and_args> p(
new func_and_args(m_data.get(), forward<F>(f), forward<Args>(args)...)); new func_and_args(m_data.get(), forward<F>(f), forward<Args>(args)...));
m_handle = thread_create( m_handle = thread_create(
m_data->stack, stack_size, THREAD_PRIORITY_MAIN - 1, 0, // CREATE_WOUT_YIELD m_data->stack, stack_size, THREAD_PRIORITY_MAIN - 1, 0,
&thread_proxy<func_and_args>, p.get(), "riot_cpp_thread"); &thread_proxy<func_and_args>, p.get(), "riot_cpp_thread");
if (m_handle >= 0) { if (m_handle >= 0) {
p.release(); p.release();

View File

@ -163,7 +163,7 @@ kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
dev->lqi_mode = 1; dev->lqi_mode = 1;
_pid = thread_create(_rx_stack, GNRC_ZEP_STACK_SIZE, GNRC_ZEP_PRIO, _pid = thread_create(_rx_stack, GNRC_ZEP_STACK_SIZE, GNRC_ZEP_PRIO,
CREATE_STACKTEST, _event_loop, dev, "zep_app"); THREAD_CREATE_STACKTEST, _event_loop, dev, "zep_app");
DEBUG("zep: started thread with PID %" PRIkernel_pid "\n", _pid); DEBUG("zep: started thread with PID %" PRIkernel_pid "\n", _pid);

View File

@ -186,7 +186,7 @@ kernel_pid_t gnrc_netdev2_init(char *stack, int stacksize, char priority,
} }
/* create new gnrc_netdev2 thread */ /* create new gnrc_netdev2 thread */
res = thread_create(stack, stacksize, priority, CREATE_STACKTEST, res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
_gnrc_netdev2_thread, (void *)gnrc_netdev2, name); _gnrc_netdev2_thread, (void *)gnrc_netdev2, name);
if (res <= 0) { if (res <= 0) {
return -EINVAL; return -EINVAL;

View File

@ -138,7 +138,7 @@ kernel_pid_t gnrc_nomac_init(char *stack, int stacksize, char priority,
return -ENODEV; return -ENODEV;
} }
/* create new NOMAC thread */ /* create new NOMAC thread */
res = thread_create(stack, stacksize, priority, CREATE_STACKTEST, res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
_nomac_thread, (void *)dev, name); _nomac_thread, (void *)dev, name);
if (res <= 0) { if (res <= 0) {
return -EINVAL; return -EINVAL;

View File

@ -268,7 +268,7 @@ kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate
/* start SLIP thread */ /* start SLIP thread */
DEBUG("slip: starting SLIP thread\n"); DEBUG("slip: starting SLIP thread\n");
pid = thread_create(stack, stack_size, priority, CREATE_STACKTEST, pid = thread_create(stack, stack_size, priority, THREAD_CREATE_STACKTEST,
_slip, dev, _SLIP_NAME); _slip, dev, _SLIP_NAME);
if (pid < 0) { if (pid < 0) {
DEBUG("slip: unable to create SLIP thread\n"); DEBUG("slip: unable to create SLIP thread\n");

View File

@ -187,7 +187,8 @@ int gnrc_nettest_init(void)
{ {
if (_pid <= KERNEL_PID_UNDEF) { if (_pid <= KERNEL_PID_UNDEF) {
_pid = thread_create(_stack, sizeof(_stack), GNRC_NETTEST_PRIO, _pid = thread_create(_stack, sizeof(_stack), GNRC_NETTEST_PRIO,
CREATE_STACKTEST, _event_loop, NULL, "nettest"); THREAD_CREATE_STACKTEST,
_event_loop, NULL, "nettest");
} }
return _pid; return _pid;

View File

@ -85,7 +85,8 @@ kernel_pid_t gnrc_ipv6_init(void)
{ {
if (gnrc_ipv6_pid == KERNEL_PID_UNDEF) { if (gnrc_ipv6_pid == KERNEL_PID_UNDEF) {
gnrc_ipv6_pid = thread_create(_stack, sizeof(_stack), GNRC_IPV6_PRIO, gnrc_ipv6_pid = thread_create(_stack, sizeof(_stack), GNRC_IPV6_PRIO,
CREATE_STACKTEST, _event_loop, NULL, "ipv6"); THREAD_CREATE_STACKTEST,
_event_loop, NULL, "ipv6");
} }
#ifdef MODULE_FIB #ifdef MODULE_FIB

View File

@ -55,7 +55,7 @@ kernel_pid_t gnrc_sixlowpan_init(void)
} }
_pid = thread_create(_stack, sizeof(_stack), GNRC_SIXLOWPAN_PRIO, _pid = thread_create(_stack, sizeof(_stack), GNRC_SIXLOWPAN_PRIO,
CREATE_STACKTEST, _event_loop, NULL, "6lo"); THREAD_CREATE_STACKTEST, _event_loop, NULL, "6lo");
return _pid; return _pid;
} }

View File

@ -164,7 +164,8 @@ kernel_pid_t gnrc_pktdump_init(void)
{ {
if (_pid == KERNEL_PID_UNDEF) { if (_pid == KERNEL_PID_UNDEF) {
_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO, _pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
CREATE_STACKTEST, _eventloop, NULL, "pktdump"); THREAD_CREATE_STACKTEST,
_eventloop, NULL, "pktdump");
} }
return _pid; return _pid;
} }

View File

@ -49,8 +49,9 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
if (gnrc_rpl_pid == KERNEL_PID_UNDEF) { if (gnrc_rpl_pid == KERNEL_PID_UNDEF) {
_instance_id = 0; _instance_id = 0;
/* start the event loop */ /* start the event loop */
gnrc_rpl_pid = thread_create(_stack, sizeof(_stack), GNRC_RPL_PRIO, CREATE_STACKTEST, gnrc_rpl_pid = thread_create(_stack, sizeof(_stack), GNRC_RPL_PRIO,
_event_loop, NULL, "RPL"); THREAD_CREATE_STACKTEST,
_event_loop, NULL, "RPL");
if (gnrc_rpl_pid == KERNEL_PID_UNDEF) { if (gnrc_rpl_pid == KERNEL_PID_UNDEF) {
DEBUG("RPL: could not start the event loop\n"); DEBUG("RPL: could not start the event loop\n");

View File

@ -277,7 +277,7 @@ int gnrc_udp_init(void)
if (_pid == KERNEL_PID_UNDEF) { if (_pid == KERNEL_PID_UNDEF) {
/* start UDP thread */ /* start UDP thread */
_pid = thread_create(_stack, sizeof(_stack), GNRC_UDP_PRIO, _pid = thread_create(_stack, sizeof(_stack), GNRC_UDP_PRIO,
CREATE_STACKTEST, _event_loop, NULL, "udp"); THREAD_CREATE_STACKTEST, _event_loop, NULL, "udp");
} }
return _pid; return _pid;
} }

View File

@ -94,7 +94,7 @@ kernel_pid_t nhdp_start(void)
/* Start the NHDP thread */ /* Start the NHDP thread */
nhdp_pid = thread_create(nhdp_stack, sizeof(nhdp_stack), THREAD_PRIORITY_MAIN - 1, nhdp_pid = thread_create(nhdp_stack, sizeof(nhdp_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, _nhdp_runner, NULL, "NHDP"); THREAD_CREATE_STACKTEST, _nhdp_runner, NULL, "NHDP");
#if (NHDP_METRIC_NEEDS_TIMER) #if (NHDP_METRIC_NEEDS_TIMER)
/* Configure periodic timer message to refresh metric values */ /* Configure periodic timer message to refresh metric values */
@ -193,7 +193,7 @@ int nhdp_register_if(kernel_pid_t if_pid, uint8_t *addr, size_t addr_size, uint8
/* Start the receiving thread */ /* Start the receiving thread */
nhdp_rcv_pid = thread_create(nhdp_rcv_stack, sizeof(nhdp_rcv_stack), THREAD_PRIORITY_MAIN - 1, nhdp_rcv_pid = thread_create(nhdp_rcv_stack, sizeof(nhdp_rcv_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, _nhdp_receiver, NULL, "nhdp_rcv_thread"); THREAD_CREATE_STACKTEST, _nhdp_receiver, NULL, "nhdp_rcv_thread");
/* Start sending periodic HELLO */ /* Start sending periodic HELLO */
signal_msg.type = MSG_TIMER; signal_msg.type = MSG_TIMER;

View File

@ -143,7 +143,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
volatile kernel_pid_t pid = thread_create(pthread_reaper_stack, volatile kernel_pid_t pid = thread_create(pthread_reaper_stack,
PTHREAD_REAPER_STACKSIZE, PTHREAD_REAPER_STACKSIZE,
0, 0,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
pthread_reaper, pthread_reaper,
NULL, NULL,
"pthread-reaper"); "pthread-reaper");
@ -155,7 +155,8 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
pt->thread_pid = thread_create(stack, pt->thread_pid = thread_create(stack,
stack_size, stack_size,
THREAD_PRIORITY_MAIN, THREAD_PRIORITY_MAIN,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD |
THREAD_CREATE_STACKTEST,
pthread_start_routine, pthread_start_routine,
pt, pt,
"pthread"); "pthread");

View File

@ -147,7 +147,7 @@ static int ip_send(char *addr_str, char *port_str, char *data, unsigned int num,
static int ip_start_server(char *port_str) static int ip_start_server(char *port_str)
{ {
if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1, if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, _server_thread, port_str, "IP server") <= KERNEL_PID_UNDEF) { THREAD_CREATE_STACKTEST, _server_thread, port_str, "IP server") <= KERNEL_PID_UNDEF) {
return 1; return 1;
} }
return 0; return 0;

View File

@ -80,7 +80,7 @@ int main(void)
#else #else
thread_create( thread_create(
pir_handler_stack, sizeof(pir_handler_stack), THREAD_PRIORITY_MAIN - 1, pir_handler_stack, sizeof(pir_handler_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
pir_handler, NULL, "pir_handler"); pir_handler, NULL, "pir_handler");
#endif #endif
return 0; return 0;

View File

@ -54,7 +54,7 @@ int main(void)
busy = 1; busy = 1;
k = 23; k = 23;
thread_create(busy_stack, sizeof(busy_stack), thread_create(busy_stack, sizeof(busy_stack),
THREAD_PRIORITY_MAIN + 1, CREATE_WOUT_YIELD, THREAD_PRIORITY_MAIN + 1, THREAD_CREATE_WOUT_YIELD,
busy_thread, NULL, "busy_thread"); busy_thread, NULL, "busy_thread");
puts("busy_thread created"); puts("busy_thread created");

View File

@ -49,7 +49,7 @@ int main(void)
kernel_pid_t second_pid = thread_create(stack, kernel_pid_t second_pid = thread_create(stack,
sizeof(stack), sizeof(stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, second_thread,
NULL, NULL,
"second_thread"); "second_thread");

View File

@ -29,7 +29,6 @@
#include <inttypes.h> #include <inttypes.h>
#include "thread.h" #include "thread.h"
#include "flags.h"
#include "kernel.h" #include "kernel.h"
#include "pipe.h" #include "pipe.h"
#include "pipe.h" #include "pipe.h"
@ -101,10 +100,12 @@ int main(void)
} }
thread_create(stacks[0], sizeof (stacks[0]), thread_create(stacks[0], sizeof (stacks[0]),
THREAD_PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
run_middle, NULL, "middle"); run_middle, NULL, "middle");
thread_create(stacks[1], sizeof (stacks[1]), thread_create(stacks[1], sizeof (stacks[1]),
THREAD_PRIORITY_MAIN, CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
run_end, NULL, "end"); run_end, NULL, "end");
unsigned total = 0; unsigned total = 0;

View File

@ -77,7 +77,8 @@ static void test1(void)
kernel_pid_t pid = thread_create(test1_thread_stack, kernel_pid_t pid = thread_create(test1_thread_stack,
sizeof(test1_thread_stack), sizeof(test1_thread_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST | CREATE_WOUT_YIELD, THREAD_CREATE_STACKTEST |
THREAD_CREATE_WOUT_YIELD,
test1_second_thread, test1_second_thread,
NULL, NULL,
"second"); "second");
@ -154,7 +155,7 @@ void test2(void)
kernel_pid_t pid = thread_create(test2_thread_stack[i], kernel_pid_t pid = thread_create(test2_thread_stack[i],
sizeof(test2_thread_stack[i]), sizeof(test2_thread_stack[i]),
priority, priority,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
priority_sema_thread, priority_sema_thread,
names[i], names[i],
names[i]); names[i]);
@ -211,14 +212,14 @@ void test3(void)
} }
puts("first: create thread 1"); puts("first: create thread 1");
if (thread_create(test2_thread_stack[0], sizeof(test2_thread_stack[0]), if (thread_create(test2_thread_stack[0], sizeof(test2_thread_stack[0]),
THREAD_PRIORITY_MAIN - 1, CREATE_STACKTEST, THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
test3_one_two_thread, NULL, "thread 1") < 0) { test3_one_two_thread, NULL, "thread 1") < 0) {
puts("first: thread create FAILED"); puts("first: thread create FAILED");
return; return;
} }
puts("first: create thread 2"); puts("first: create thread 2");
if (thread_create(test2_thread_stack[1], sizeof(test2_thread_stack[1]), if (thread_create(test2_thread_stack[1], sizeof(test2_thread_stack[1]),
THREAD_PRIORITY_MAIN - 1, CREATE_STACKTEST, THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
test3_two_one_thread, NULL, "thread 2") < 0) { test3_two_one_thread, NULL, "thread 2") < 0) {
puts("first: thread create FAILED"); puts("first: thread create FAILED");
return; return;

View File

@ -58,7 +58,7 @@ int main(void)
pthread_cond_init(&cv, NULL); pthread_cond_init(&cv, NULL);
kernel_pid_t pid = thread_create(stack,sizeof(stack), THREAD_PRIORITY_MAIN - 1, kernel_pid_t pid = thread_create(stack,sizeof(stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, NULL, "second_thread"); second_thread, NULL, "second_thread");
while (1) { while (1) {

View File

@ -128,7 +128,7 @@ int main(void)
} }
thread_create(stacks[i], sizeof(stacks[i]), thread_create(stacks[i], sizeof(stacks[i]),
prio, CREATE_WOUT_YIELD | CREATE_STACKTEST, prio, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
fun, NULL, name); fun, NULL, name);
} }

View File

@ -34,7 +34,7 @@ int main(void)
puts("----------------------------------------------------------------"); puts("----------------------------------------------------------------");
thread_create(snd_thread_stack, sizeof(snd_thread_stack), THREAD_PRIORITY_MAIN, thread_create(snd_thread_stack, sizeof(snd_thread_stack), THREAD_PRIORITY_MAIN,
CREATE_WOUT_YIELD, snd_thread, NULL, "snd"); THREAD_CREATE_WOUT_YIELD, snd_thread, NULL, "snd");
puts("yield 1"); puts("yield 1");
thread_yield(); thread_yield();

View File

@ -34,7 +34,8 @@ int main(void)
{ {
(void) thread_create( (void) thread_create(
t2_stack, sizeof(t2_stack), t2_stack, sizeof(t2_stack),
THREAD_PRIORITY_MAIN - 1, CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, NULL, "nr2"); second_thread, NULL, "nr2");
puts("first thread\n"); puts("first thread\n");
return 0; return 0;

View File

@ -70,7 +70,8 @@ int main(void)
for (int i = 0; i < PROBLEM; ++i) { for (int i = 0; i < PROBLEM; ++i) {
printf("Creating thread with arg %d\n", (i + 1)); printf("Creating thread with arg %d\n", (i + 1));
ths[i] = thread_create(stacks[i], sizeof(stacks[i]), ths[i] = thread_create(stacks[i], sizeof(stacks[i]),
THREAD_PRIORITY_MAIN - 1, CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
run, NULL, "thread"); run, NULL, "thread");
if (ths[i] < 0) { if (ths[i] < 0) {

View File

@ -50,7 +50,7 @@ void *second_thread(void *arg)
third_thread_stack, third_thread_stack,
sizeof(third_thread_stack), sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 2, THREAD_PRIORITY_MAIN - 2,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
third_thread, third_thread,
NULL, NULL,
"nr3") "nr3")
@ -64,7 +64,7 @@ void *second_thread(void *arg)
third_thread_stack, third_thread_stack,
sizeof(third_thread_stack), sizeof(third_thread_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
fourth_thread, fourth_thread,
NULL, NULL,
"nr4") "nr4")
@ -84,7 +84,7 @@ int main(void)
second_thread_stack, second_thread_stack,
sizeof(second_thread_stack), sizeof(second_thread_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, second_thread,
NULL, NULL,
"nr2") "nr2")

View File

@ -84,13 +84,13 @@ void *thread3(void *arg)
int main(void) int main(void)
{ {
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr1"); thread1, NULL, "nr1");
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1, p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread2, NULL, "nr2"); thread2, NULL, "nr2");
p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1, p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread3, NULL, "nr3"); thread3, NULL, "nr3");
puts("THREADS CREATED\n"); puts("THREADS CREATED\n");
return 0; return 0;

View File

@ -60,7 +60,7 @@ int main(void)
msg_init_queue(msg_q, 1); msg_init_queue(msg_q, 1);
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr1"); thread1, NULL, "nr1");
/* step 3: receive a msg */ /* step 3: receive a msg */

View File

@ -57,7 +57,7 @@ int main(void)
p_main = sched_active_pid; p_main = sched_active_pid;
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr1"); thread1, NULL, "nr1");
/* step 3: receive a msg */ /* step 3: receive a msg */

View File

@ -56,13 +56,13 @@ int main(void)
p_main = sched_active_pid; p_main = sched_active_pid;
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1, p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
sub_thread, "nr1", "nr1"); sub_thread, "nr1", "nr1");
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1, p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
sub_thread, "nr2", "nr2"); sub_thread, "nr2", "nr2");
p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1, p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
sub_thread, "nr3", "nr3"); sub_thread, "nr3", "nr3");
puts("THREADS CREATED\n"); puts("THREADS CREATED\n");

View File

@ -17,7 +17,6 @@
*/ */
#include "thread.h" #include "thread.h"
#include "flags.h"
#include "kernel.h" #include "kernel.h"
#include "ringbuffer.h" #include "ringbuffer.h"
#include "mutex.h" #include "mutex.h"
@ -110,7 +109,8 @@ static void tests_core_ringbuffer(void)
{ {
pid_add = sched_active_pid; pid_add = sched_active_pid;
pid_get = thread_create(stack_get, sizeof (stack_get), pid_get = thread_create(stack_get, sizeof (stack_get),
THREAD_PRIORITY_MAIN, CREATE_SLEEPING | CREATE_STACKTEST, THREAD_PRIORITY_MAIN,
THREAD_CREATE_SLEEPING | THREAD_CREATE_STACKTEST,
run_get, NULL, "get"); run_get, NULL, "get");
run_add(); run_add();
} }

View File

@ -87,7 +87,8 @@ void test_ubjson_test(void (*sender_fun)(void), void (*receiver_fun)(void))
mutex_lock(&data.mutexes[1]); mutex_lock(&data.mutexes[1]);
kernel_pid_t receiver_pid = thread_create(receiver_stack, sizeof(receiver_stack), kernel_pid_t receiver_pid = thread_create(receiver_stack, sizeof(receiver_stack),
THREAD_PRIORITY_MAIN, CREATE_WOUT_YIELD, THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD,
test_ubjson_receiver_trampoline, &data, "receiver"); test_ubjson_receiver_trampoline, &data, "receiver");
TEST_ASSERT(pid_is_valid(receiver_pid)); TEST_ASSERT(pid_is_valid(receiver_pid));

View File

@ -94,7 +94,7 @@ int main(void)
timer_stack, timer_stack,
sizeof(timer_stack), sizeof(timer_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_thread, timer_thread,
NULL, NULL,
"timer"); "timer");
@ -111,7 +111,7 @@ int main(void)
timer_stack_local, timer_stack_local,
sizeof(timer_stack_local), sizeof(timer_stack_local),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_thread_local, timer_thread_local,
NULL, NULL,
"timer local"); "timer local");

View File

@ -108,7 +108,7 @@ int main(void)
timer_stack, timer_stack,
sizeof(timer_stack), sizeof(timer_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_thread, timer_thread,
NULL, NULL,
"timer"); "timer");

View File

@ -140,7 +140,7 @@ int main(void)
slacker_stack1, slacker_stack1,
sizeof(slacker_stack1), sizeof(slacker_stack1),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
slacker_thread, slacker_thread,
NULL, NULL,
"slacker1"); "slacker1");
@ -157,7 +157,7 @@ int main(void)
slacker_stack2, slacker_stack2,
sizeof(slacker_stack2), sizeof(slacker_stack2),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
slacker_thread, slacker_thread,
NULL, NULL,
"slacker2"); "slacker2");
@ -174,7 +174,7 @@ int main(void)
worker_stack, worker_stack,
sizeof(worker_stack), sizeof(worker_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
worker_thread, worker_thread,
NULL, NULL,
"worker"); "worker");

View File

@ -64,7 +64,7 @@ int main(void)
thread_create(stack_timer1, thread_create(stack_timer1,
STACKSIZE_TIMER, STACKSIZE_TIMER,
2, 2,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_func1, timer_func1,
NULL, NULL,
"timer1"); "timer1");
@ -72,7 +72,7 @@ int main(void)
thread_create(stack_timer2, thread_create(stack_timer2,
STACKSIZE_TIMER, STACKSIZE_TIMER,
3, 3,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_func2, timer_func2,
NULL, NULL,
"timer2"); "timer2");

View File

@ -98,7 +98,7 @@ int main(void)
timer_stack, timer_stack,
sizeof(timer_stack), sizeof(timer_stack),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_thread, timer_thread,
NULL, NULL,
"timer"); "timer");
@ -115,7 +115,7 @@ int main(void)
timer_stack_local, timer_stack_local,
sizeof(timer_stack_local), sizeof(timer_stack_local),
THREAD_PRIORITY_MAIN - 1, THREAD_PRIORITY_MAIN - 1,
CREATE_STACKTEST, THREAD_CREATE_STACKTEST,
timer_thread_local, timer_thread_local,
NULL, NULL,
"timer local"); "timer local");