#include "contiki.h"
static char *ptr;
PROCESS(multi_threading_process,
"Multi-threading process");
AUTOSTART_PROCESSES(&multi_threading_process);
static void
thread_func(char *str, int len)
{
ptr = str + len;
if(len) {
thread_func(str, len - 1);
}
ptr = str + len;
}
static void
thread_main(void *data)
{
while(1) {
thread_func((char *)data, 9);
}
}
{
static struct mt_thread alpha_thread;
static struct mt_thread count_thread;
static int toggle;
mt_start(&alpha_thread, thread_main,
"JIHGFEDCBA");
mt_start(&count_thread, thread_main,
"9876543210");
while(1) {
if(ev == PROCESS_EVENT_TIMER) {
if(toggle) {
toggle--;
} else {
toggle++;
}
puts(ptr);
}
}
}