2010-09-22 15:10:42 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <thread.h>
|
|
|
|
#include <msg.h>
|
|
|
|
#include <kernel.h>
|
|
|
|
|
|
|
|
void second_thread(void) {
|
|
|
|
printf("second_thread starting.\n");
|
2011-03-08 10:54:40 +01:00
|
|
|
msg_t m;
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
msg_receive(&m);
|
|
|
|
// printf("2nd: got msg from %i\n", m.sender_pid);
|
|
|
|
m.content.value++;
|
|
|
|
msg_send(&m, m.sender_pid, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-25 15:40:01 +02:00
|
|
|
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
|
|
|
|
2010-09-22 15:10:42 +02:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
printf("Hello world!\n");
|
|
|
|
|
2011-03-08 10:54:40 +01:00
|
|
|
msg_t m;
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2010-11-04 16:47:24 +01:00
|
|
|
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
m.content.value = 1;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
msg_send(&m, pid, true);
|
|
|
|
msg_receive(&m);
|
|
|
|
printf("Got msg with content %i\n", m.content.value);
|
|
|
|
}
|
|
|
|
}
|