diff -ruN kozos35/kozos.h kozos36/kozos.h --- kozos35/kozos.h Mon Jan 19 21:49:32 2009 +++ kozos36/kozos.h Thu Jan 22 00:06:54 2009 @@ -5,6 +5,7 @@ typedef int (*kz_func)(int argc, char *argv[]); typedef void (*kz_handler)(int signo); +typedef void (*kz_prefunc)(int id); /* syscall */ int kz_run(kz_func func, char *name, int pri, int argc, char *argv[]); @@ -17,8 +18,9 @@ int kz_send(int id, int size, char *p); int kz_recv(int *idp, char **pp); int kz_pending(); -int kz_sethandler(int signo, kz_handler handler); int kz_setsig(int signo); +int kz_sethandler(int signo, kz_handler handler); +int kz_precall(int id, kz_prefunc func); int kz_debug(int sockt); void *kz_kmalloc(int size); int kz_kmfree(void *p); diff -ruN kozos35/syscall.c kozos36/syscall.c --- kozos35/syscall.c Mon Jan 19 21:45:20 2009 +++ kozos36/syscall.c Thu Jan 22 00:06:52 2009 @@ -113,6 +113,15 @@ return param.un.sethandler.ret; } +int kz_precall(int id, kz_prefunc func) +{ + kz_syscall_param_t param; + param.un.precall.id = id; + param.un.precall.func = func; + kz_syscall(KZ_SYSCALL_TYPE_PRECALL, ¶m); + return param.un.precall.ret; +} + int kz_debug(int sockt) { kz_syscall_param_t param; diff -ruN kozos35/syscall.h kozos36/syscall.h --- kozos35/syscall.h Mon Jan 19 21:45:15 2009 +++ kozos36/syscall.h Thu Jan 22 00:05:14 2009 @@ -16,6 +16,7 @@ KZ_SYSCALL_TYPE_PENDING, KZ_SYSCALL_TYPE_SETSIG, KZ_SYSCALL_TYPE_SETHANDLER, + KZ_SYSCALL_TYPE_PRECALL, KZ_SYSCALL_TYPE_DEBUG, KZ_SYSCALL_TYPE_KMALLOC, KZ_SYSCALL_TYPE_KMFREE, @@ -76,6 +77,11 @@ kz_handler handler; int ret; } sethandler; + struct { + int id; + kz_prefunc func; + int ret; + } precall; struct { int sockt; int ret; diff -ruN kozos35/thread.c kozos36/thread.c --- kozos35/thread.c Mon Jan 19 21:47:33 2009 +++ kozos36/thread.c Thu Jan 22 01:27:32 2009 @@ -287,6 +287,14 @@ sendmsg(sigcalls[signo], 0, 0, NULL); } +static int thread_precall(int id, kz_prefunc func) +{ + kz_thread *thp = (kz_thread *)id; + thp->precall = func; + putcurrent(); + return 0; +} + static int thread_debug(int sockt) { debug_sockt = sockt; @@ -366,6 +374,9 @@ p->un.sethandler.ret = thread_sethandler(p->un.sethandler.signo, p->un.sethandler.handler); break; + case KZ_SYSCALL_TYPE_PRECALL: + p->un.precall.ret = thread_precall(p->un.precall.id, p->un.precall.func); + break; case KZ_SYSCALL_TYPE_DEBUG: p->un.debug.ret = thread_debug(p->un.debug.sockt); break; @@ -455,6 +466,10 @@ } schedule(); + + if (current->precall) { + current->precall((int)current); + } /* * スタブでの read() 待ちブロック中に SIGALRM (および SIGHUP)が発生した diff -ruN kozos35/thread.h kozos36/thread.h --- kozos35/thread.h Mon Jan 19 01:03:05 2009 +++ kozos36/thread.h Thu Jan 22 00:13:19 2009 @@ -29,6 +29,8 @@ unsigned int flags; #define KZ_THREAD_FLAG_RUNNING (1 << 0) + kz_prefunc precall; + struct { kz_syscall_type_t type; kz_syscall_param_t *param;