diff -ruN kozos23/main.c kozos24/main.c --- kozos23/main.c Sun Nov 25 19:50:10 2007 +++ kozos24/main.c Sun Nov 25 21:13:05 2007 @@ -3,15 +3,60 @@ #include "kozos.h" +static char *outnum[] = { "ABCDEFGHIJ", "abcdefghij", "0123456789" }; + +static int sample_main(int argc, char *argv[]) +{ + int i, count; + char *p; + +#define INTERVAL 7 /* CPU能力に応じて調整してください */ + while (1) { + count = 0; + kz_timer(INTERVAL - argc); + kz_recv(NULL, NULL); + p = kz_memalloc(128); + p[0] = '['; + p[1] = '0' + argc; + p[2] = ']'; + p[3] = '\0'; + kz_send(outlog_id, 0, p); + for (i = 0; i < 70; i++) { + p = kz_memalloc(128); + p[0] = outnum[argc][(count++) % 10]; + p[1] = '\0'; + kz_send(outlog_id, 0, p); + } + p = kz_memalloc(128); + p[0] = '\n'; + p[1] = '\0'; + kz_send(outlog_id, 0, p); + } + return 0; +} + int mainfunc(int argc, char *argv[]) { + int sample1_id; + int sample2_id; + int sample3_id; + extintr_id = kz_run(extintr_main, "extintr", 1, 0, NULL); +#if 0 stubd_id = kz_run(stubd_main, "stubd", 2, 0, NULL); +#endif outlog_id = kz_run(outlog_main, "outlog", 3, 0, NULL); idle_id = kz_run(idle_main, "idle", 31, 0, NULL); +#if 0 clock_id = kz_run(clock_main, "clock", 7, 0, NULL); telnetd_id = kz_run(telnetd_main, "telnetd", 8, 0, NULL); httpd_id = kz_run(httpd_main, "httpd", 9, 0, NULL); +#endif + httpd_id = kz_run(httpd_main, "httpd", 9, 0, NULL); + + sample1_id = kz_run(sample_main, "sample1", 10, 0, NULL); + sample2_id = kz_run(sample_main, "sample2", 11, 1, NULL); + sample3_id = kz_run(sample_main, "sample3", 12, 2, NULL); return 0; } diff -ruN kozos23/thread.c kozos24/thread.c --- kozos23/thread.c Sun Nov 25 19:50:10 2007 +++ kozos24/thread.c Sun Nov 25 19:52:06 2007 @@ -254,7 +254,7 @@ return 0; } -void alarm_handler() +static void alarm_handler() { kz_timebuf *tmp; @@ -369,7 +369,7 @@ return; } -static void dispatch() +static void schedule() { int i; for (i = 0; i < PRI_NUM; i++) { @@ -412,7 +412,7 @@ break; } extintr_proc(signo); - dispatch(); + schedule(); /* * スタブでの read() 待ちブロック中に SIGALRM (および SIGHUP)が発生した