mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #4382 from haukepetersen/rm_core_flagsh
core: move thread flags from flags.h to thread.h
This commit is contained in:
commit
cf53aeddd8
@ -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 */
|
||||
/** @} */
|
@ -29,7 +29,6 @@
|
||||
#include "config.h"
|
||||
#include "tcb.h"
|
||||
#include "cpu.h"
|
||||
#include "flags.h"
|
||||
#include "sched.h"
|
||||
#include "cpu_conf.h"
|
||||
|
||||
|
@ -93,6 +93,32 @@
|
||||
*/
|
||||
#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
|
||||
*
|
||||
@ -113,11 +139,13 @@
|
||||
*
|
||||
* 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:
|
||||
* - CREATE_SLEEPING the newly created thread will be put to sleeping state and
|
||||
* must be waken up manually
|
||||
* - CREATE_WOUT_YIELD the newly created thread will not run immediately after creation
|
||||
* - CREATE_STACKTEST write markers into the thread's stack to measure the stack's memory
|
||||
* usage (for debugging and profiling purposes)
|
||||
* - THREAD_CREATE_SLEEPING the newly created thread will be put to sleeping
|
||||
* state and must be waken up manually
|
||||
* - THREAD_CREATE_WOUT_YIELD the newly created thread will not run
|
||||
* immediately after creation
|
||||
* - 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
|
||||
* 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
|
||||
*
|
||||
* 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`
|
||||
*
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "kernel.h"
|
||||
#include "kernel_internal.h"
|
||||
#include "sched.h"
|
||||
#include "flags.h"
|
||||
#include "cpu.h"
|
||||
#include "lpm.h"
|
||||
#include "thread.h"
|
||||
@ -95,12 +94,12 @@ void kernel_init(void)
|
||||
|
||||
thread_create(idle_stack, sizeof(idle_stack),
|
||||
THREAD_PRIORITY_IDLE,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
idle_thread, NULL, idle_name);
|
||||
|
||||
thread_create(main_stack, sizeof(main_stack),
|
||||
THREAD_PRIORITY_MAIN,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
main_trampoline, NULL, main_name);
|
||||
|
||||
cpu_switch_context_exit();
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "irq.h"
|
||||
#include "cib.h"
|
||||
|
||||
#include "flags.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
#include "thread.h"
|
||||
|
@ -148,7 +148,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
|
||||
tcb_t *cb = (tcb_t *) (stack + stacksize);
|
||||
|
||||
#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 */
|
||||
uintptr_t *stackmax = (uintptr_t *) (stack + stacksize);
|
||||
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);
|
||||
|
||||
if (flags & CREATE_SLEEPING) {
|
||||
if (flags & THREAD_CREATE_SLEEPING) {
|
||||
sched_set_status(cb, STATUS_SLEEPING);
|
||||
}
|
||||
else {
|
||||
sched_set_status(cb, STATUS_PENDING);
|
||||
|
||||
if (!(flags & CREATE_WOUT_YIELD)) {
|
||||
if (!(flags & THREAD_CREATE_WOUT_YIELD)) {
|
||||
restoreIRQ(state);
|
||||
sched_switch(priority);
|
||||
return pid;
|
||||
|
@ -156,7 +156,7 @@ void *tftp_server_wrapper(void *arg)
|
||||
void tftp_server_start(void)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ int main(void)
|
||||
msg_t m;
|
||||
|
||||
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");
|
||||
|
||||
m.content.value = 1;
|
||||
|
@ -130,7 +130,8 @@ static int udp_start_server(char *port_str)
|
||||
}
|
||||
/* start server (which means registering pktdump for the chosen port) */
|
||||
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;
|
||||
puts("error initializing thread");
|
||||
return 1;
|
||||
|
@ -49,7 +49,9 @@ int main()
|
||||
printf("\n");
|
||||
|
||||
/* 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("We'll test C++ class and methods here!\n");
|
||||
|
@ -228,7 +228,7 @@ thread::thread(F&& f, Args&&... args)
|
||||
std::unique_ptr<func_and_args> p(
|
||||
new func_and_args(m_data.get(), forward<F>(f), forward<Args>(args)...));
|
||||
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");
|
||||
if (m_handle >= 0) {
|
||||
p.release();
|
||||
|
@ -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;
|
||||
|
||||
_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);
|
||||
|
||||
|
@ -186,7 +186,7 @@ kernel_pid_t gnrc_netdev2_init(char *stack, int stacksize, char priority,
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (res <= 0) {
|
||||
return -EINVAL;
|
||||
|
@ -138,7 +138,7 @@ kernel_pid_t gnrc_nomac_init(char *stack, int stacksize, char priority,
|
||||
return -ENODEV;
|
||||
}
|
||||
/* 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);
|
||||
if (res <= 0) {
|
||||
return -EINVAL;
|
||||
|
@ -268,7 +268,7 @@ kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate
|
||||
|
||||
/* start SLIP thread */
|
||||
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);
|
||||
if (pid < 0) {
|
||||
DEBUG("slip: unable to create SLIP thread\n");
|
||||
|
@ -187,7 +187,8 @@ int gnrc_nettest_init(void)
|
||||
{
|
||||
if (_pid <= KERNEL_PID_UNDEF) {
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_NETTEST_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, NULL, "nettest");
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_event_loop, NULL, "nettest");
|
||||
}
|
||||
|
||||
return _pid;
|
||||
|
@ -85,7 +85,8 @@ kernel_pid_t gnrc_ipv6_init(void)
|
||||
{
|
||||
if (gnrc_ipv6_pid == KERNEL_PID_UNDEF) {
|
||||
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
|
||||
|
@ -55,7 +55,7 @@ kernel_pid_t gnrc_sixlowpan_init(void)
|
||||
}
|
||||
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_SIXLOWPAN_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, NULL, "6lo");
|
||||
THREAD_CREATE_STACKTEST, _event_loop, NULL, "6lo");
|
||||
|
||||
return _pid;
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ kernel_pid_t gnrc_pktdump_init(void)
|
||||
{
|
||||
if (_pid == KERNEL_PID_UNDEF) {
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
|
||||
CREATE_STACKTEST, _eventloop, NULL, "pktdump");
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_eventloop, NULL, "pktdump");
|
||||
}
|
||||
return _pid;
|
||||
}
|
||||
|
@ -49,8 +49,9 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
|
||||
if (gnrc_rpl_pid == KERNEL_PID_UNDEF) {
|
||||
_instance_id = 0;
|
||||
/* start the event loop */
|
||||
gnrc_rpl_pid = thread_create(_stack, sizeof(_stack), GNRC_RPL_PRIO, CREATE_STACKTEST,
|
||||
_event_loop, NULL, "RPL");
|
||||
gnrc_rpl_pid = thread_create(_stack, sizeof(_stack), GNRC_RPL_PRIO,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_event_loop, NULL, "RPL");
|
||||
|
||||
if (gnrc_rpl_pid == KERNEL_PID_UNDEF) {
|
||||
DEBUG("RPL: could not start the event loop\n");
|
||||
|
@ -277,7 +277,7 @@ int gnrc_udp_init(void)
|
||||
if (_pid == KERNEL_PID_UNDEF) {
|
||||
/* start UDP thread */
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_UDP_PRIO,
|
||||
CREATE_STACKTEST, _event_loop, NULL, "udp");
|
||||
THREAD_CREATE_STACKTEST, _event_loop, NULL, "udp");
|
||||
}
|
||||
return _pid;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ kernel_pid_t nhdp_start(void)
|
||||
|
||||
/* Start the NHDP thread */
|
||||
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)
|
||||
/* 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 */
|
||||
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 */
|
||||
signal_msg.type = MSG_TIMER;
|
||||
|
@ -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,
|
||||
PTHREAD_REAPER_STACKSIZE,
|
||||
0,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
pthread_reaper,
|
||||
NULL,
|
||||
"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,
|
||||
stack_size,
|
||||
THREAD_PRIORITY_MAIN,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
THREAD_CREATE_WOUT_YIELD |
|
||||
THREAD_CREATE_STACKTEST,
|
||||
pthread_start_routine,
|
||||
pt,
|
||||
"pthread");
|
||||
|
@ -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)
|
||||
{
|
||||
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 0;
|
||||
|
@ -80,7 +80,7 @@ int main(void)
|
||||
#else
|
||||
thread_create(
|
||||
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");
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -54,7 +54,7 @@ int main(void)
|
||||
busy = 1;
|
||||
k = 23;
|
||||
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");
|
||||
puts("busy_thread created");
|
||||
|
||||
|
@ -49,7 +49,7 @@ int main(void)
|
||||
kernel_pid_t second_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");
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "flags.h"
|
||||
#include "kernel.h"
|
||||
#include "pipe.h"
|
||||
#include "pipe.h"
|
||||
@ -101,10 +100,12 @@ int main(void)
|
||||
}
|
||||
|
||||
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");
|
||||
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");
|
||||
|
||||
unsigned total = 0;
|
||||
|
@ -77,7 +77,8 @@ static void test1(void)
|
||||
kernel_pid_t pid = thread_create(test1_thread_stack,
|
||||
sizeof(test1_thread_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST | CREATE_WOUT_YIELD,
|
||||
THREAD_CREATE_STACKTEST |
|
||||
THREAD_CREATE_WOUT_YIELD,
|
||||
test1_second_thread,
|
||||
NULL,
|
||||
"second");
|
||||
@ -154,7 +155,7 @@ void test2(void)
|
||||
kernel_pid_t pid = thread_create(test2_thread_stack[i],
|
||||
sizeof(test2_thread_stack[i]),
|
||||
priority,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
priority_sema_thread,
|
||||
names[i],
|
||||
names[i]);
|
||||
@ -211,14 +212,14 @@ void test3(void)
|
||||
}
|
||||
puts("first: create thread 1");
|
||||
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) {
|
||||
puts("first: thread create FAILED");
|
||||
return;
|
||||
}
|
||||
puts("first: create thread 2");
|
||||
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) {
|
||||
puts("first: thread create FAILED");
|
||||
return;
|
||||
|
@ -58,7 +58,7 @@ int main(void)
|
||||
pthread_cond_init(&cv, NULL);
|
||||
|
||||
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");
|
||||
|
||||
while (1) {
|
||||
|
@ -128,7 +128,7 @@ int main(void)
|
||||
}
|
||||
|
||||
thread_create(stacks[i], sizeof(stacks[i]),
|
||||
prio, CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
prio, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
fun, NULL, name);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ int main(void)
|
||||
puts("----------------------------------------------------------------");
|
||||
|
||||
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");
|
||||
thread_yield();
|
||||
|
@ -34,7 +34,8 @@ int main(void)
|
||||
{
|
||||
(void) thread_create(
|
||||
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");
|
||||
puts("first thread\n");
|
||||
return 0;
|
||||
|
@ -70,7 +70,8 @@ int main(void)
|
||||
for (int i = 0; i < PROBLEM; ++i) {
|
||||
printf("Creating thread with arg %d\n", (i + 1));
|
||||
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");
|
||||
|
||||
if (ths[i] < 0) {
|
||||
|
@ -50,7 +50,7 @@ void *second_thread(void *arg)
|
||||
third_thread_stack,
|
||||
sizeof(third_thread_stack),
|
||||
THREAD_PRIORITY_MAIN - 2,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
third_thread,
|
||||
NULL,
|
||||
"nr3")
|
||||
@ -64,7 +64,7 @@ void *second_thread(void *arg)
|
||||
third_thread_stack,
|
||||
sizeof(third_thread_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
fourth_thread,
|
||||
NULL,
|
||||
"nr4")
|
||||
@ -84,7 +84,7 @@ int main(void)
|
||||
second_thread_stack,
|
||||
sizeof(second_thread_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST,
|
||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
second_thread,
|
||||
NULL,
|
||||
"nr2")
|
||||
|
@ -84,13 +84,13 @@ void *thread3(void *arg)
|
||||
int main(void)
|
||||
{
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
puts("THREADS CREATED\n");
|
||||
return 0;
|
||||
|
@ -60,7 +60,7 @@ int main(void)
|
||||
msg_init_queue(msg_q, 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");
|
||||
|
||||
/* step 3: receive a msg */
|
||||
|
@ -57,7 +57,7 @@ int main(void)
|
||||
p_main = sched_active_pid;
|
||||
|
||||
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");
|
||||
|
||||
/* step 3: receive a msg */
|
||||
|
@ -56,13 +56,13 @@ int main(void)
|
||||
p_main = sched_active_pid;
|
||||
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
|
||||
puts("THREADS CREATED\n");
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "thread.h"
|
||||
#include "flags.h"
|
||||
#include "kernel.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "mutex.h"
|
||||
@ -110,7 +109,8 @@ static void tests_core_ringbuffer(void)
|
||||
{
|
||||
pid_add = sched_active_pid;
|
||||
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_add();
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ void test_ubjson_test(void (*sender_fun)(void), void (*receiver_fun)(void))
|
||||
mutex_lock(&data.mutexes[1]);
|
||||
|
||||
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_ASSERT(pid_is_valid(receiver_pid));
|
||||
|
||||
|
@ -94,7 +94,7 @@ int main(void)
|
||||
timer_stack,
|
||||
sizeof(timer_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread,
|
||||
NULL,
|
||||
"timer");
|
||||
@ -111,7 +111,7 @@ int main(void)
|
||||
timer_stack_local,
|
||||
sizeof(timer_stack_local),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread_local,
|
||||
NULL,
|
||||
"timer local");
|
||||
|
@ -108,7 +108,7 @@ int main(void)
|
||||
timer_stack,
|
||||
sizeof(timer_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread,
|
||||
NULL,
|
||||
"timer");
|
||||
|
@ -140,7 +140,7 @@ int main(void)
|
||||
slacker_stack1,
|
||||
sizeof(slacker_stack1),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
slacker_thread,
|
||||
NULL,
|
||||
"slacker1");
|
||||
@ -157,7 +157,7 @@ int main(void)
|
||||
slacker_stack2,
|
||||
sizeof(slacker_stack2),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
slacker_thread,
|
||||
NULL,
|
||||
"slacker2");
|
||||
@ -174,7 +174,7 @@ int main(void)
|
||||
worker_stack,
|
||||
sizeof(worker_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
worker_thread,
|
||||
NULL,
|
||||
"worker");
|
||||
|
@ -64,7 +64,7 @@ int main(void)
|
||||
thread_create(stack_timer1,
|
||||
STACKSIZE_TIMER,
|
||||
2,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_func1,
|
||||
NULL,
|
||||
"timer1");
|
||||
@ -72,7 +72,7 @@ int main(void)
|
||||
thread_create(stack_timer2,
|
||||
STACKSIZE_TIMER,
|
||||
3,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_func2,
|
||||
NULL,
|
||||
"timer2");
|
||||
|
@ -98,7 +98,7 @@ int main(void)
|
||||
timer_stack,
|
||||
sizeof(timer_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread,
|
||||
NULL,
|
||||
"timer");
|
||||
@ -115,7 +115,7 @@ int main(void)
|
||||
timer_stack_local,
|
||||
sizeof(timer_stack_local),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
CREATE_STACKTEST,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread_local,
|
||||
NULL,
|
||||
"timer local");
|
||||
|
Loading…
Reference in New Issue
Block a user