1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/thread_msg_seq/main.c
Oleg Hahm 983d056c75 core: harmonizes the data type for the process ID
Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
2014-08-01 12:02:54 +02:00

75 lines
1.8 KiB
C

/*
* Copyright (C) 2013 Christian Mehlis <mehlis@inf.fu-berlin.de>
* (C) 2014 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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 Christian Mehlis <mehlis@inf.fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdio.h>
#include "thread.h"
#include "msg.h"
char t1_stack[KERNEL_CONF_STACKSIZE_MAIN];
char t2_stack[KERNEL_CONF_STACKSIZE_MAIN];
char t3_stack[KERNEL_CONF_STACKSIZE_MAIN];
kernel_pid_t p1, p2, p3;
void *sub_thread(void *arg)
{
(void) arg;
kernel_pid_t pid = thread_getpid();
printf("THREAD %s (pid:%" PRIkernel_pid ") start\n", thread_getname(pid), pid);
msg_t msg;
msg.content.ptr = (char*)thread_getname(pid);
msg_send(&msg, 1, 1);
printf("THREAD %s (pid:%" PRIkernel_pid ") end.\n", thread_getname(pid), pid);
return NULL;
}
int main(void)
{
msg_t msg;
p1 = thread_create(t1_stack, sizeof(t1_stack), PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
sub_thread, NULL, "nr1");
p2 = thread_create(t2_stack, sizeof(t2_stack), PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
sub_thread, NULL, "nr2");
p3 = thread_create(t3_stack, sizeof(t3_stack), PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
sub_thread, NULL, "nr3");
puts("THREADS CREATED\n");
for(int i = 0; i < 3; i++) {
msg_receive(&msg);
printf("Got msg from pid %" PRIkernel_pid ": \"%s\"\n", msg.sender_pid, msg.content.ptr);
}
return 0;
}