threads.c
Go to the documentation of this file.00001
00086 #include <stdio.h>
00087 #include <io.h>
00088
00089 #include <cfg/arch.h>
00090 #include <dev/board.h>
00091
00092 #include <sys/thread.h>
00093 #include <sys/timer.h>
00094
00095
00096
00097
00098 THREAD(Thread1, arg)
00099 {
00100
00101
00102
00103 NutThreadSetPriority(16);
00104 for (;;) {
00105 putchar('H');
00106 NutSleep(125);
00107 }
00108 }
00109
00110
00111
00112
00113 THREAD(Thread2, arg)
00114 {
00115
00116
00117
00118 NutThreadSetPriority(128);
00119 for (;;) {
00120 putchar('L');
00121 NutSleep(125);
00122 }
00123 }
00124
00125
00126
00127
00128 int main(void)
00129 {
00130 u_long baud = 115200;
00131
00132
00133
00134
00135
00136 NutRegisterDevice(&DEV_UART, 0, 0);
00137 freopen(DEV_UART_NAME, "w", stdout);
00138 _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
00139
00140 puts("\nThread Test");
00141
00142
00143
00144
00145
00146 NutThreadCreate("t1", Thread1, 0, 512);
00147 NutThreadCreate("t2", Thread2, 0, 512);
00148
00149
00150
00151
00152 for (;;) {
00153 putchar('M');
00154 NutSleep(125);
00155 }
00156 return 0;
00157 }