diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm/distpkt.c klic-3.003-2002-03-02/runtime/config/pvm/distpkt.c
--- klic-3.003-2002-02-26d/runtime/config/pvm/distpkt.c	Tue Feb 26 18:20:17 2002
+++ klic-3.003-2002-03-02/runtime/config/pvm/distpkt.c	Sat Mar  2 16:30:10 2002
@@ -10,7 +10,7 @@
 /*
   Communication buffer management
   ALLOCATE COMBUF		combuf *alloc_combuf(bufsize)
-  FREE COMBUF			void *free_combuf(buf)
+  FREE COMBUF			void free_combuf(buf)
   BACKUP COMBUF			combuf *backup_combuf(buf)
   realloc combuf		static combuf *realloc_combuf(inbuf, bufsize)
   EXPAND OUTBUF			void expand_outbuf(outbuf)
diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm/distpkt.h klic-3.003-2002-03-02/runtime/config/pvm/distpkt.h
--- klic-3.003-2002-02-26d/runtime/config/pvm/distpkt.h	Sun Jan 13 14:29:18 2002
+++ klic-3.003-2002-03-02/runtime/config/pvm/distpkt.h	Sat Mar  2 15:33:06 2002
@@ -5,7 +5,6 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 /* PVM dependent inter-pe communication library */
-/* $Id: distpkt.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 
 #include <pvm3.h>
 
@@ -27,7 +26,6 @@
 Extern combuf* pending_msg Init(0);
 
 /* Buffer I/O primitives and its associates */
-#define IS_BUFFER_EMPTY(inbuf)	((inbuf)->rd_index == (inbuf)->wt_index)
 #define NODE_TO_BUFFER(node)	kumon_outbuf
 #define GET_BUFFER(inbuf)	((inbuf)->buffer[(inbuf)->rd_index++])
 
diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm/distproc.c klic-3.003-2002-03-02/runtime/config/pvm/distproc.c
--- klic-3.003-2002-02-26d/runtime/config/pvm/distproc.c	Tue Feb 26 15:57:39 2002
+++ klic-3.003-2002-03-02/runtime/config/pvm/distproc.c	Sat Mar  2 15:59:32 2002
@@ -5,7 +5,6 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 /* PVM dependent process spawn library */
-/* $Id: distproc.c,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 
 #include <stdio.h>
 #include <klic/basic.h>  /* klic_fprintf */
@@ -537,17 +536,3 @@
     return;
   }
 }
-
-#if 0
-extern NeverReturn void
-myexit(char* s, int l, int c)
-{
-  FILE* f;
-  char buf[10];
-  sprintf(buf, "/tmp/%d", getpid());
-  f = fopen(buf, "w");
-  klic_fprintf(f, "exit(pid=%d,my_node=%d) %s:%d\n", getpid(), my_node, s, l);
-  fclose(f);
-  exit(c);
-}
-#endif
diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm/distproc.h klic-3.003-2002-03-02/runtime/config/pvm/distproc.h
--- klic-3.003-2002-02-26d/runtime/config/pvm/distproc.h	Tue Feb 26 14:23:04 2002
+++ klic-3.003-2002-03-02/runtime/config/pvm/distproc.h	Sat Mar  2 18:21:38 2002
@@ -5,18 +5,11 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 /* PVM dependent inter-pe communication library */
-/* $Id: distproc.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 
 #include <pvm3.h>
 
 /* Definition for command options for the distributed system */
 
-#ifdef MAIN
-/* following variables are set by parse_arg(),
-   and are used only in klic_main() */
-static int eager_transfer_all_flag;
-#endif
-
 Extern int useconfig_flag;
 
 #ifndef USE_REDUCTION_COUNT
@@ -117,5 +110,3 @@
 
 #define Tid_of(X)	(tid_table.child[X])
 #define Tid_of_io()	(tid_table.io)
-
-#define Node_type()     ( io_node_flag == 0 )
diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm-tcp/distpkt.c klic-3.003-2002-03-02/runtime/config/pvm-tcp/distpkt.c
--- klic-3.003-2002-02-26d/runtime/config/pvm-tcp/distpkt.c	Tue Feb 26 14:04:24 2002
+++ klic-3.003-2002-03-02/runtime/config/pvm-tcp/distpkt.c	Sat Mar  2 16:45:02 2002
@@ -1,4 +1,3 @@
-/* #define DEBUG */
 /* ---------------------------------------------------------- 
 %   (C)1994,1995 Institute for New Generation Computer Technology 
 %       (Read COPYRIGHT for detailed information.) 
@@ -6,7 +5,6 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 /* PVM-TCP dependent inter-pe communication library */
-/* distpkt.c,v 1.3 1997/06/06 10:41:13 sekita Exp */
 
 /* fatal, fatalf, debug_printf, debug_fprintf, klic_fprintf */
 #include <klic/basic.h>
@@ -34,11 +32,15 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <netdb.h>
+#include <errno.h>
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
 
 extern void switch_debugger_flag(void);  /* asyncio.c */
 extern void set_simple_interval_timer_handler();
-int receive_message();
-int add_signal_handler();
+extern int receive_message();
 
 #define SYNCID_CONN 0x3141
 #define SYNCID_CONN2 0x5926
@@ -50,15 +52,15 @@
 #else
 #define DEBUG_X(X)
 #endif
-#include <errno.h>
+
 #ifdef DECL_SYS_ERRLIST
 extern char *sys_errlist[];
 #endif
-extern int errno;
+
 /*
   Communication buffer management
   ALLOCATE COMBUF		combuf *alloc_combuf(bufsize)
-  FREE COMBUF			void *free_combuf(buf)
+  FREE COMBUF			void free_combuf(buf)
   BACKUP COMBUF			combuf *backup_combuf(buf)
   realloc combuf		static combuf *realloc_combuf(inbuf, bufsize)
   EXPAND OUTBUF			void expand_outbuf(outbuf)
@@ -75,9 +77,9 @@
 #define INITIAL_COMBUF_SIZE	0x10000	/* for inbuf and outbuf */
 
 /* Communication buffer management functions */
-combuf *
+static combuf*
 alloc_combuf(bufsize)
-long bufsize;
+  long bufsize;
 {
     combuf *buf = (combuf *)malloc(sizeof(combuf));
     long *newptr;
@@ -95,8 +97,8 @@
 
 static combuf *
 realloc_combuf(inbuf, bufsize)
-combuf *inbuf;
-long bufsize;
+  combuf* inbuf;
+  long bufsize;
 {
     long *bufp = inbuf->buffer - 1;
     bufp = (long *)realloc((char *)bufp, (bufsize+1) * sizeof(long));
@@ -107,17 +109,18 @@
     return inbuf;
 }
 
-void *
+extern void
 free_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
     free(buf->buffer - 1);
     free(buf);
 }
+
 /* backup_combuf() is called only within message_suspend() */
-combuf *
+extern combuf*
 backup_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
     combuf *retbuf;
 
@@ -132,9 +135,9 @@
 }
 
 /* expand_outbuf() is called only within the macro PUT_BUFFER() */
-void
+extern void
 expand_outbuf(outbuf)
-combuf *outbuf;
+  combuf* outbuf;
 {
     /* always double the size */
     /* expand_outbuf() must expand the buffer at least 4-words.
@@ -170,23 +173,24 @@
     DEBUG_X((void)debug_fprintf(stderr, "%d:done.\n", my_node));
     return s;
 }
-static
+
+static void
 infocheck(info)
-int info;
+  int info;
 {
     declare_globals;
     if (info >= 0)
       return;
-    (void)klic_fprintf(stderr, "%d:info returns error=%d\n", my_node, info);
+    klic_fprintf(stderr, "%d: info returns error=%d\n", my_node, info);
     for(;;);
 }
 
 /* Raw packet send/receive functions */
 static void
 forceread(fd, buffer, size)
-int fd;
-char *buffer;
-long size;
+  int fd;
+  char* buffer;
+  long size;
 {
     int r;
     declare_globals;
@@ -227,9 +231,9 @@
 
 static void
 forcewrite(fd, buffer, size)
-int fd;
-char *buffer;
-long size;
+  int fd;
+  char* buffer;
+  long size;
 {
     int r;
     declare_globals;
@@ -253,9 +257,10 @@
 	exit(4);
     }
 }
+
 static void
 make_connection(tbl)
-struct port_tbl *tbl;
+  struct port_tbl* tbl;
 {
     int my_portnum;
     int info;
@@ -373,7 +378,8 @@
 	forcewrite(csocket, &my_node, sizeof(my_node));
     }
 }
-void
+
+extern void
 io_init_comm()
 {
     int i;
@@ -412,14 +418,17 @@
 	DEBUG_X((void)debug_fprintf(stderr, "io:semaphore send\n"));
     }
 }
+
 static fd_set port_fds;
 static int max_port_fds;
+
+extern void
 init_comm()
 {
     int i;
     static char mybuffer[BUFSIZ];
     declare_globals;
-/*    freopen("/dev/pts/3", "w", stderr);*/
+    /* freopen("/dev/pts/3", "w", stderr); */
     setvbuf(stderr, mybuffer, _IOLBF, BUFSIZ);
     
     /* initialize out buffer */
@@ -441,11 +450,12 @@
 	}
     }
 }
+
 static int
 dist_sigio_stream_handler(fd, sigio_type, rfd, wfd)
-long fd;
-enum sigiotype sigio_type;
-fd_set *rfd, *wfd;
+  long fd;
+  enum sigiotype sigio_type;
+  fd_set *rfd, *wfd;
 {
     int i;
     int again;
@@ -461,7 +471,8 @@
     switch_debugger_flag();
     signal(SIGUSR2, dummy);
 }
-void
+
+extern void
 init_dist_signal_setup()
 {
     declare_globals;
@@ -517,10 +528,12 @@
 	DEBUG_X((void)debug_fprintf(stderr, "%d:semaphore receive\n", my_node));
     }
 }
+
 static struct timeval immediate = {0, 0};
-combuf *
+
+extern combuf*
 receive_packet(heap_neededp)
-long *heap_neededp;	/* this variable will be obsoleted in the future. */
+  long* heap_neededp;  /* this variable will be obsoleted in the future. */
 {
     int i;
     int r;
@@ -582,10 +595,10 @@
     return inbuf;
 }
 
-void
+extern void
 send_packet(node, sendbuf)
-long node;
-combuf *sendbuf;
+  long node;
+  combuf* sendbuf;
 {
     sendbuf->buffer[-1] = sendbuf->wt_index;
     forcewrite(port_tbl[node].fd,
@@ -594,6 +607,7 @@
     sendbuf->wt_index = 0;
 }
 
+extern void
 close_network()
 {
     combuf *buffer;
@@ -608,11 +622,12 @@
     }
     pvm_exit();
 }
+
 struct recv_int_stat recv_int_stat[NSIG];
 
-char *
+extern char*
 print_interrupt_statistics(ptr)
-char *ptr;
+  char* ptr;
 {
     sprintf(ptr, " sigalrm=(%d+%d)/%d, sigio=(%d+%d)/%d, sigusr1=(%d+%d)/%d\n",
 	    recv_int_stat[SIGALRM].usefull,
@@ -625,42 +640,4 @@
 	    recv_int_stat[SIGUSR1].useless,
 	    recv_int_stat[SIGUSR1].enter);
     return strlen(ptr)+ptr;
-}
-
-static void send_useless_message();
-static q *decode_useless_message(inbuf, allocp)
-combuf *inbuf;
-q *allocp;
-{
-    
-    declare_globals;
-    int the_fd;
-    long from = GET_BUFFER(inbuf);
-    ioprintf("useless:%d -> %d\n", from, my_node);
-    the_fd = port_tbl[from].fd;
-    if (fcntl(the_fd, F_SETOWN, getpid()) < 0)
-      fatalf("fcntl(setown) errno=%d\n", errno);
-#ifdef FASYNC
-    if (fcntl(the_fd, F_SETFL, FASYNC) < 0)
-      fatalf("fcntl(setfl) errno=%d\n", errno);
-#else
-    if (ioctl(the_fd, I_SETSIG, S_INPUT) < 0)
-      fatalf("ioctl(setsig) errno=%d\n", errno);
-#endif
-    if (from < my_node)
-      send_useless_message();
-    return allocp;
-}
-static void send_useless_message()
-{
-    declare_globals;
-    int i;
-    for (i = 0; i < tid_table.child_count; ++i) {
-	if (i != my_node) {
-	    combuf *to_buffer = NODE_TO_BUFFER(i);
-	    PUT_BUFFER(to_buffer, decode_useless_message);
-	    PUT_BUFFER(to_buffer, my_node);
-	    send_message_without_wtc_chk(i, to_buffer);
-	}
-    }
 }
diff -ruN klic-3.003-2002-02-26d/runtime/config/pvm-tcp/distpkt.h klic-3.003-2002-03-02/runtime/config/pvm-tcp/distpkt.h
--- klic-3.003-2002-02-26d/runtime/config/pvm-tcp/distpkt.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-03-02/runtime/config/pvm-tcp/distpkt.h	Sat Mar  2 16:47:42 2002
@@ -5,15 +5,11 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 /* PVM-TCP dependent inter-pe communication library */
-/* $Id: distpkt.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
+
 #include <pvm3.h>
 #include <sys/param.h>
 #include <netdb.h>
 
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
 /* Maximum ratio of the output KL1 words created by one communication word. */
 #define DECODE_MAX_OBJ_RATIO	(((6+3+1+5) + 2)/3)
 
@@ -32,7 +28,6 @@
 Extern combuf *pending_msg Init(0);
 
 /* Buffer I/O primitives and its associates */
-#define IS_BUFFER_EMPTY(inbuf)	((inbuf)->rd_index == (inbuf)->wt_index)
 #define NODE_TO_BUFFER(node)	kumon_outbuf
 #define GET_BUFFER(inbuf)	((inbuf)->buffer[(inbuf)->rd_index++])
 
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distio.c klic-3.003-2002-03-02/runtime/config/shm/distio.c
--- klic-3.003-2002-02-26d/runtime/config/shm/distio.c	Fri Jan 25 23:29:15 2002
+++ klic-3.003-2002-03-02/runtime/config/shm/distio.c	Sat Mar  2 17:34:44 2002
@@ -4,13 +4,6 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-/*
-  For io-node
-  IO NODE SERVER PROGRAM		void io_server(argc,argv)
-
-  For shoen and reduction node
-  WORKER NODE CLIENT ROUTINE	int io_client(enum io_tag msg_tag, ...)
-*/
 
 #include <stdio.h>
 #include <errno.h>
@@ -19,41 +12,34 @@
 #include <klic/struct.h>
 #include <klic/distio.h>
 
-int klic_gets(str,len,fp)
-  char* str;
-  int len;
-  FILE* fp;
+#define SystemReadSize  1024
+
+static FILE*
+io_tty(void)
 {
-  while (1) {
-    int r = (int)fgets(str,len,fp);
-    if ((r != EOF && r != 0) || errno != EINTR) {
-      return r;
+  static FILE* io_tty0 = NULL;
+
+  if (io_tty0 == NULL) {
+    io_tty0 = fopen("/dev/tty", "r");
+    if (io_tty0 == NULL) {
+      io_tty0 = stdin;
     }
-  } 
+  }
+  return io_tty0;
 }
 
-
+extern int
 SystemRead(Str)
   char* Str;
 {
-  if (!io_tty) {
-    io_tty = fopen("/dev/tty","r");
-    if (io_tty==NULL) {
-      io_tty = stdin;
-    }
-  }
-  klic_gets(Str,SystemReadSize,io_tty);
+  while(fgets(Str, SystemReadSize, io_tty()) != Str && errno == EINTR)
+    ;
   return 0;
 }
 
+extern int
 SystemGetc()
 {
-  if (!io_tty) {
-    io_tty = fopen("/dev/tty","r");
-    if (io_tty==NULL) {
-      io_tty = stdin;
-    }
-  }
-  klic_getc(io_tty);
+  klic_getc(io_tty());
   return 0;
 }
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distio.h klic-3.003-2002-03-02/runtime/config/shm/distio.h
--- klic-3.003-2002-02-26d/runtime/config/shm/distio.h	Mon Dec 31 12:04:47 2001
+++ klic-3.003-2002-03-02/runtime/config/shm/distio.h	Sat Mar  2 17:39:38 2002
@@ -9,49 +9,22 @@
 
 #include <klic/stdc.h>  /* VA_ARGS */
 #include <klic/distpkt.h>
+#include <klic/distproc.h>
 
-enum io_tag {
-    FinishTag,
-    AttachTag,
-    DetachTag,
-    System_putbTag,
-    System_getsTag,
-    System_putcTag,
-    System_getcTag,
-    System_writeTag,
-    System_fflushTag,
-    PutbTag,
-    EPutbTag,
-    GetsTag,
-    User_putcTag,
-    User_eputcTag,
-    User_getcTag,
-    User_ungetcTag,
-    User_writeTag,
-    User_ewriteTag,
-    User_fflushTag,
-    User_efflushTag,
-    Emergency_stopTag,
-    System_IsEOFTag
-};
-
-
-Extern FILE *io_tty Init(0);
 #define IO_Lock                 (s_lock  (&io_lockwds->lockwd))
 #define IO_Unlock               (s_unlock(&io_lockwds->lockwd))
-#define SystemReadSize          1024
 #define CloseIO()
 #define AttachIO()		{ if (!my_io_lock_flag) {IO_Lock; my_io_lock_flag=1;} }
 #define DetachIO()		{ IO_Unlock; my_io_lock_flag =0; }
 
 #define SystemPrint(Str)        (int)klic_fwrite(Str,strlen(Str),1,stderr)
-Extern int SystemRead();
+extern int SystemRead();
 #define SystemPutc(Char)	(int)klic_putc(Char,stderr)
-Extern int SystemGetc();
+extern int SystemGetc();
 #define SystemFflush()		(int)klic_fflush(stderr)
 #define Print(Str)		(int)klic_fwrite(Str,strlen(Str),1,stdout)
 #define EPrint(Str)		(int)klic_fwrite(Str,strlen(Str),1,stderr)
-#define Read(Str)		(int)klic_gets(Str)
+#define Read(Str)		(SystemRead(Str))
 #define UserPutc(Char)		(int)klic_putc(Char,stdout)
 #define UserEPutc(Char)		(int)klic_putc(Char,stderr)
 #define UserGetc()		(int)klic_getc(stdin)
@@ -68,8 +41,5 @@
 extern void iosprintf VA_ARGS((char *format, ...));
 
 #define io_server(argv,argc)
-
-#include <klic/distproc.h>
-#include <klic/distpkt.h>
 
 #endif /* _KLIC_DISTIO_H_ */
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distpkt.c klic-3.003-2002-03-02/runtime/config/shm/distpkt.c
--- klic-3.003-2002-02-26d/runtime/config/shm/distpkt.c	Mon Feb 18 16:45:01 2002
+++ klic-3.003-2002-03-02/runtime/config/shm/distpkt.c	Sat Mar  2 18:10:57 2002
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include <signal.h>
 
-#include <klic/sighndl.h>
+#include <klic/sighndl.h>  /* add_signal_handler */
 #include <klic/distio.h>
 #include "interpe.h"
 #include "rmon.h"
@@ -21,11 +21,12 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
+#include "timer.h"  /* call_at_time_intervals */
 
 /*
   Communication buffer management
   ALLOCATE COMBUF		combuf *alloc_combuf(bufsize)
-  FREE COMBUF			void *free_combuf(buf)
+  FREE COMBUF			void free_combuf(buf)
   BACKUP COMBUF			combuf *backup_combuf(buf)
   realloc combuf		static combuf *realloc_combuf(inbuf, bufsize)
   EXPAND OUTBUF			void expand_outbuf(outbuf)
@@ -42,12 +43,23 @@
 
 #define INITIAL_COMBUF_SIZE	0x10000	/* for inbuf and outbuf */
 
+#define LEFT_SHM_BUFF(pe) (shmp[pe]->buffer_size - shmp[pe]->wt_index)
+#define SHM_MSG_SIZE(pe) (shmp[pe]->wt_index - shmp[pe]->rd_index)
+#define SHM_WPTR(pe) (shmp[pe]->top_ptr + shmp[pe]->wt_index)
+#define SHM_RPTR(pe) (shmp[pe]->top_ptr + shmp[pe]->rd_index)
+#define SHM_WIDX(pe) (shmp[pe]->wt_index)
+#define SHM_RIDX(pe) (shmp[pe]->rd_index)
+#define ADD_SHM_WIDX(pe,n) (shmp[pe]->wt_index = shmp[pe]->wt_index + n)
+
 extern void set_simple_interval_timer_handler();
+extern int receive_message();
+extern int send_profile_trigger();
+extern void count_profile();
 
 /* Communication buffer management functions */
-combuf *
+static combuf*
 alloc_combuf(bufsize)
-long bufsize;
+  long bufsize;
 {
     combuf *buf = (combuf *)malloc(sizeof(combuf));
     if (!buf)
@@ -63,8 +75,8 @@
 
 static combuf *
 realloc_combuf(inbuf, bufsize)
-combuf *inbuf;
-long bufsize;
+  combuf* inbuf;
+  long bufsize;
 {
     inbuf->buffer = (long *)realloc((char *)inbuf->buffer,
 				    bufsize * sizeof(long));
@@ -74,17 +86,18 @@
     return inbuf;
 }
 
-void *
+extern void
 free_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
     free((char *)(buf->buffer));
     free(buf);
 }
+
 /* backup_combuf() is called only within message_suspend() */
-combuf *
+extern combuf*
 backup_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
     combuf *retbuf;
 
@@ -99,9 +112,9 @@
 }
 
 /* expand_outbuf() is called only within the macro PUT_BUFFER() */
-void
+extern void
 expand_outbuf(outbuf)
-combuf *outbuf;
+  combuf* outbuf;
 {
     /* always double the size */
     /* expand_outbuf() must expand the buffer at least 4-words.
@@ -111,12 +124,10 @@
     outbuf = realloc_combuf(outbuf, bufsize);
     if (!outbuf)
       fatal("realloc failed in expandeing outbuf");
-    /*
-    ioprintf("PE %d outbuf expanded to %d\n", my_node, bufsize);
-    */
+    /* ioprintf("PE %d outbuf expanded to %d\n", my_node, bufsize); */
 }
 
-void
+extern void
 init_comm()
 {
     /* initialize out buffer */
@@ -124,34 +135,27 @@
     /* initialize in buffer */
     kumon_inbuf = alloc_combuf(INITIAL_COMBUF_SIZE);
 }
-void
+
+extern void
 io_init_comm()
 {}
 
-void
+extern void
 init_dist_signal_setup()
 {
     declare_globals;
-    int add_signal_handler();
-    void call_at_time_intervals();
-    int receive_message();
-    int send_profile();
-    int send_profile_trigger();
-    void count_profile();
 
     add_signal_handler(SIGUSR1, receive_message);
 #ifdef USETIMER
     if(rmonnode){
 	if (IS_SHOEN_NODE(my_node)){
-	    struct itimerval interval;
-	    long isec, usec;
 	    set_simple_interval_timer_handler(
 						PROF_GATHER_INTERVAL_SEC,
 						0, send_profile_trigger );
 	}else {	
 	    call_at_time_intervals(0, PROF_SAMPLE_INTERVAL_uSEC, 
 				   count_profile);
-/*	    add_signal_handler(SIGUSR2, send_profile); */
+	    /* add_signal_handler(SIGUSR2, send_profile); */
 	}
     }
     if (!noitimer) {
@@ -167,9 +171,9 @@
 }
 
 /* Raw packet send/receive functions */
-combuf *
+extern combuf*
 receive_packet(heap_neededp)
-long *heap_neededp;	/* this variable will be obsoleted in the future. */
+  long* heap_neededp;  /* this variable will be obsoleted in the future. */
 {
   declare_globals;
   char *p;
@@ -180,7 +184,7 @@
   Lock(my_node);
   if ( SHM_WIDX(my_node) == SHM_RIDX(my_node) ) { /* no message */
     Unlock(my_node);
-    return 0;
+    return NULL;
   }
   buffsize = SHM_MSG_SIZE(my_node);
   last_index = buffsize / sizeof(long);
@@ -193,9 +197,7 @@
       fatal("expansion of inbuf failed");
     }
     inbuf->buf_size = newsize;
-    /*
-    ioprintf("PE %d inbuf expanded to %d\n", my_node, newsize);
-    */
+    /* ioprintf("PE %d inbuf expanded to %d\n", my_node, newsize); */
   }
 
   BCOPY(SHM_RPTR(my_node), (char *)(inbuf->buffer), buffsize);
@@ -210,7 +212,26 @@
   return inbuf;
 }
 
-void
+/*  shared memory version  1995-02-08 */
+static void
+sendsig(node, sig)
+  long node;
+  int sig;
+{
+  volatile struct global_variables* dest_glbl = &(shmp[node]->globals);
+  volatile struct klic_sgnl_flags* dest_sgnl_flags = &(shmp[node]->klic_sgnl_flags);
+
+  dest_sgnl_flags->done = 0;
+  store_barrier();
+  dest_sgnl_flags->flags[sig] = 1;
+  store_barrier();
+  dest_glbl->interrupt_off0 = 0;
+  store_barrier();
+  dest_glbl->heaplimit0 = 0;
+  store_barrier();
+}
+
+extern void
 send_packet(node, sendbuf)
      long node;
      combuf *sendbuf;
@@ -225,9 +246,7 @@
         fatal("no enough shared memory buffer\n");
       }
       Unlock(node);
-      /*
-      klic_fprintf(stderr, "buffer full. wait...");
-      */
+      /* klic_fprintf(stderr, "buffer full. wait..."); */
       while (LEFT_SHM_BUFF(node) >= sendbufsize) ;
     } else
       break;
@@ -236,24 +255,23 @@
   BCOPY((char *)(sendbuf->buffer), SHM_WPTR(node), sendbufsize);
   ADD_SHM_WIDX(node, sendbufsize);
   sendbuf->wt_index = 0;
-/*
-  Unlock(node);
-  */
+  /* Unlock(node); */
   /* alert(); */
   sendsig(node, SIGUSR1);
   Unlock(node);
 }
 
-void
+extern void
 close_network()
 {
-  wait((int *) 0);
+  wait(NULL);
 }
 
 struct recv_int_stat recv_int_stat[NSIG];
-char *
+
+extern char*
 print_interrupt_statistics(ptr)
-char *ptr;
+  char* ptr;
 {
     sprintf(ptr, " sigalrm=(%d+%d)/%d, sigio=(%d+%d)/%d, sigusr1=(%d+%d)/%d\n",
 	    recv_int_stat[SIGALRM].usefull,
@@ -266,25 +284,4 @@
 	    recv_int_stat[SIGUSR1].useless,
 	    recv_int_stat[SIGUSR1].enter);
     return strlen(ptr)+ptr;
-}
-
-/*  shared memory version  1995-02-08 */
-
-sendsig(node, sig)
-     long node;
-     int sig;
-{
-  volatile struct global_variables 
-    *dest_glbl = &(shmp[node]->globals);
-  volatile struct klic_sgnl_flags 
-    *dest_sgnl_flags = &(shmp[node]->klic_sgnl_flags);
-  
-  dest_sgnl_flags->done = 0;
-  store_barrier();
-  dest_sgnl_flags->flags[sig] = 1;
-  store_barrier();
-  dest_glbl->interrupt_off0 = 0;
-  store_barrier();
-  dest_glbl->heaplimit0 = 0;
-  store_barrier();
 }
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distpkt.h klic-3.003-2002-03-02/runtime/config/shm/distpkt.h
--- klic-3.003-2002-02-26d/runtime/config/shm/distpkt.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-03-02/runtime/config/shm/distpkt.h	Sat Mar  2 18:07:35 2002
@@ -27,7 +27,6 @@
 Extern combuf *pending_msg Init(0);
 
 /* Buffer I/O primitives and its associates */
-#define IS_BUFFER_EMPTY(inbuf)	((inbuf)->rd_index == (inbuf)->wt_index)
 #define NODE_TO_BUFFER(node)	kumon_outbuf
 #define GET_BUFFER(inbuf)	((inbuf)->buffer[(inbuf)->rd_index++])
 
@@ -95,24 +94,24 @@
 /* shared memory */
 
 #ifdef SPARC
-Extern void s_lock();
-Extern void s_unlock();
-Extern void store_barrier();
+extern void s_lock();
+extern void s_unlock();
+extern void store_barrier();
 #elif defined(ATT3600)
-Extern void s_lock();
-Extern void s_unlock();
+extern void s_lock();
+extern void s_unlock();
 #define store_barrier() {;}
 #elif defined(IRIX)
-Extern void s_lock();
-Extern void s_unlock();
+extern void s_lock();
+extern void s_unlock();
 #define store_barrier() {;}
 #elif defined(SPPUX)
-Extern void s_lock();
-Extern void s_unlock();
+extern void s_lock();
+extern void s_unlock();
 #define store_barrier() {;}
 #elif defined(INTEL)
-Extern void s_lock();
-Extern void s_unlock();
+extern void s_lock();
+extern void s_unlock();
 #define store_barrier() {;}
 #endif
 
@@ -143,13 +142,6 @@
 #define Lock(pe)   (s_lock  (&shmp[pe]->lockwd))
 #define Unlock(pe) (s_unlock(&shmp[pe]->lockwd))
 
-#define LEFT_SHM_BUFF(pe) (shmp[pe]->buffer_size - shmp[pe]->wt_index)
-#define SHM_MSG_SIZE(pe) (shmp[pe]->wt_index - shmp[pe]->rd_index)
-#define SHM_WPTR(pe) (shmp[pe]->top_ptr + shmp[pe]->wt_index)
-#define SHM_RPTR(pe) (shmp[pe]->top_ptr + shmp[pe]->rd_index)
-#define SHM_WIDX(pe) (shmp[pe]->wt_index)
-#define SHM_RIDX(pe) (shmp[pe]->rd_index)
-#define ADD_SHM_WIDX(pe,n) (shmp[pe]->wt_index = shmp[pe]->wt_index + n)
 #define CLEAR_SHM_RWIDX(pe) (shmp[pe]->wt_index = shmp[pe]->rd_index = 0)
 
 #endif /* _KLIC_DISTPKT_H_ */
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distproc.c klic-3.003-2002-03-02/runtime/config/shm/distproc.c
--- klic-3.003-2002-02-26d/runtime/config/shm/distproc.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-03-02/runtime/config/shm/distproc.c	Sat Mar  2 18:25:17 2002
@@ -30,7 +30,6 @@
 #include <klic/distpkt.h>
 #include <klic/distproc.h>
 
-#define SYNCID_SPAWN 0x3193
 /*
   char *expand_prog_name(buffer, progname)
   static void setup_send_args(opttable)
@@ -40,46 +39,48 @@
   int spawn_children(num_child, opttable, prog_name, argc, argv)
   */
 
-#define OPT_DEBUG(X) 
+#ifndef MAP_FAILED
+#define MAP_FAILED (-1)
+#endif
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#ifndef MAP_VARIABLE
+#define MAP_VARIABLE 0
+#endif
 
-void
+extern void
 kill_child()
 {
   kill(0, SIGINT);
 }
 
-void
+extern void
 child_sync(syncid)
-int syncid;
+  int syncid;
 {
 }
-void
+
+extern void
 io_wait_sync(syncid)
-int syncid;
+  int syncid;
 {
 }
-void
+
+extern void
 child_wait_sync(syncid)
-int syncid;
+  int syncid;
 {
 }
 
-void
+extern void
 io_sync(syncid)
-int syncid;
+  int syncid;
 {
 }
 
-static void
-sigint_handler()
-{
-    klic_fprintf(stdout, "kill tasks in children_spawn()\n");
-    kill_child();
-    exit(1);
-}
-
-
-int r_spawn_children(num_child, opttable, prog_name, argc, argv)
+extern int
+r_spawn_children(num_child, opttable, prog_name, argc, argv)
      long num_child; 
      const struct opttable* opttable;
      char *prog_name;
@@ -122,8 +123,8 @@
     close(fds);
     unlink(tmpfile);
 
-/*    IO_Unlock; */
-/*    io_lockwds->lockwd = 0; */
+    /* IO_Unlock; */
+    /* io_lockwds->lockwd = 0; */
     IO_Unlock;
     io_lockwds->syncwd = 1;
 
@@ -144,8 +145,8 @@
 	exit(1);
       }
 
-/*      Unlock(i); */
-/*      shmp[i]->lockwd = 0; */
+      /* Unlock(i); */
+      /* shmp[i]->lockwd = 0; */
       Unlock(i);
       shmp[i]->syncwd = 1;
       shmp[i]->buffer_size = shared_buffer_size;
@@ -231,7 +232,7 @@
   return my_penum;
 }
 
-void
+extern void
 count_profile()
 {
     perfmon_counter.intr_count++;
@@ -252,17 +253,3 @@
 	return;
     }
 }
-
-#if 0
-myexit(char *s, int *l, int *c)
-{
-    FILE *f;
-    char buf[10];
-    sprintf(buf,"/tmp/%d",getpid());
-    f=fopen(buf,"w");
-    klic_fprintf(f, "exit(pid=%d,my_node=%d) %s:%d\n",
-		 getpid(), my_node,  s, l);
-    fclose(f);
-    exit(c);
-}
-#endif
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distproc.h klic-3.003-2002-03-02/runtime/config/shm/distproc.h
--- klic-3.003-2002-02-26d/runtime/config/shm/distproc.h	Tue Feb 26 14:23:10 2002
+++ klic-3.003-2002-03-02/runtime/config/shm/distproc.h	Sat Mar  2 18:24:44 2002
@@ -9,12 +9,6 @@
 
 /* Definition for command options for the distributed system */
 
-#ifdef MAIN
-/* following variables are set by parse_arg(),
-   and are used only in klic_main() */
-static int eager_transfer_all_flag;
-#endif
-
 #ifdef USETIMER
 Extern unsigned long interval_usec;
 Extern unsigned int noitimer;
@@ -87,18 +81,6 @@
 
 Extern int io_node_flag;
 
-#define Node_type()     ( io_node_flag == 0 )
-
 #define spawn_children(n, t, p, c, v)  r_spawn_children(n,t,p,c,v); glbl = My_glbl;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (-1)
-#endif
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-#ifndef MAP_VARIABLE
-#define MAP_VARIABLE 0
-#endif
 
 #endif /* _KLIC_DISTPROC_H_ */
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/distrmon.c klic-3.003-2002-03-02/runtime/config/shm/distrmon.c
--- klic-3.003-2002-02-26d/runtime/config/shm/distrmon.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-03-02/runtime/config/shm/distrmon.c	Sat Mar  2 18:27:56 2002
@@ -27,7 +27,7 @@
 
 static FILE *rmonfile;
 
-void
+extern void
 output_profile_information()
 {
     declare_globals;
@@ -59,7 +59,7 @@
     fflush(rmonfile);
 }
 
-void
+static void
 profiling_ctr_tag(tag)
      long tag;
 {
@@ -80,7 +80,7 @@
     fflush(rmonfile);
 }
 
-void
+static void
 start_profiling()
 {
   declare_globals;
@@ -108,7 +108,7 @@
   profiling_ctr_tag(SHOEN_START_TAG);
 }
 
-void
+extern void
 terminate_profiling()
 {
     declare_globals;
@@ -116,7 +116,7 @@
     fclose(rmonfile);
 }
 
-void
+extern void
 init_rmonitor()
 {
   declare_globals;
diff -ruN klic-3.003-2002-02-26d/runtime/config/shm/rmon_server.c klic-3.003-2002-03-02/runtime/config/shm/rmon_server.c
--- klic-3.003-2002-02-26d/runtime/config/shm/rmon_server.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2002-03-02/runtime/config/shm/rmon_server.c	Sat Mar  2 18:31:12 2002
@@ -14,10 +14,6 @@
 #include <sys/socket.h>
 #include <unistd.h>
 
-/*#define SHOEN_START_TAG         0
-#define SHOEN_OUTPUT_PROF_TAG 100
-#define SHOEN_TERMINATE_TAG   200*/
-
 #define MAXNUM   256
 
 static int sock;
@@ -51,6 +47,7 @@
   return 0;
 }
 
+static void
 last_column(disp_nodes)
      int disp_nodes;
 {
@@ -65,6 +62,7 @@
   }
 }
 
+extern int
 main(argc,argv)
      int argc; char **argv;
 {
diff -ruN klic-3.003-2002-02-26d/runtime/debug.c klic-3.003-2002-03-02/runtime/debug.c
--- klic-3.003-2002-02-26d/runtime/debug.c	Tue Feb 26 14:24:08 2002
+++ klic-3.003-2002-03-02/runtime/debug.c	Sat Mar  2 18:22:30 2002
@@ -24,6 +24,8 @@
 #ifdef DIST
 #include <klic/distio.h>
 #include "interpe.h"
+
+#define Node_type()  (io_node_flag == 0)
 #endif
 
 #ifdef SHM
diff -ruN klic-3.003-2002-02-26d/runtime/kmain.c klic-3.003-2002-03-02/runtime/kmain.c
--- klic-3.003-2002-02-26d/runtime/kmain.c	Tue Feb 26 14:27:25 2002
+++ klic-3.003-2002-03-02/runtime/kmain.c	Sat Mar  2 15:58:47 2002
@@ -5,9 +5,6 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #define MAIN
-#ifdef DIST
-/*#define exit(X) myexit(__FILE__, __LINE__, X)*/
-#endif
 
 /* klic_interrupt, initalloc, register_gc_hook, register_after_gc_hook,
  * enqueue_goal
@@ -48,6 +45,8 @@
 void gc_exp_table(void);
 void gc_decode_stack(void);
 void scan_imp_table(void);
+
+static int eager_transfer_all_flag;
 #endif  /* DIST */
 
 #include "options.h"
diff -ruN klic-3.003-2002-02-26d/runtime/sendrecv.c klic-3.003-2002-03-02/runtime/sendrecv.c
--- klic-3.003-2002-02-26d/runtime/sendrecv.c	Mon Feb 25 15:01:15 2002
+++ klic-3.003-2002-03-02/runtime/sendrecv.c	Sat Mar  2 15:30:37 2002
@@ -33,6 +33,8 @@
 #define RECV_ON()  (perfmon_state.mr_on = 1)
 #define RECV_OFF() (perfmon_state.mr_on = 0)
 
+#define IS_BUFFER_EMPTY(inbuf)	((inbuf)->rd_index == (inbuf)->wt_index)
+
 extern combuf* backup_combuf();
 extern void send_packet();
 extern combuf* receive_packet();
