1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 09:52:43 +01:00
RIOT/examples/ipc_pingpong/main.c
2014-01-06 10:10:47 +01:00

35 lines
763 B
C

#include <stdio.h>
#include <thread.h>
#include <msg.h>
#include <kernel.h>
void second_thread(void) {
printf("second_thread starting.\n");
msg_t m;
while(1) {
msg_receive(&m);
printf("2nd: got msg from %i\n", m.sender_pid);
m.content.value++;
msg_reply(&m, &m);
}
}
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
int main(void)
{
printf("Hello world!\n");
msg_t m;
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
m.content.value = 1;
while(1) {
msg_send_receive(&m, &m, pid);
printf("Got msg with content %u\n", m.content.value);
}
}