diff -ruN klic-3.003-2002-01-04/runtime/debug.c klic-3.003-2002-01-05/runtime/debug.c
--- klic-3.003-2002-01-04/runtime/debug.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-05/runtime/debug.c	Sat Jan  5 12:30:48 2002
@@ -43,7 +43,6 @@
   ioeXXXX: equivalent to klic_fprintf(stderr, ...)
   */
 
-extern struct predicate topsucceed_pred;
 extern jmp_buf klic_topmost;
 
 extern void
diff -ruN klic-3.003-2002-01-04/runtime/interpe.h klic-3.003-2002-01-05/runtime/interpe.h
--- klic-3.003-2002-01-04/runtime/interpe.h	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-05/runtime/interpe.h	Sat Jan  5 12:29:37 2002
@@ -36,15 +36,19 @@
 #endif
 
 /*********** for bsd libraries */
+#ifndef BCOPY
 #ifdef USEBCOPY
 #  define BCOPY(from,to,len)	bcopy((from), (to), (len))
 #else
 #  define BCOPY(from,to,len)	memcpy((to), (from), (len))
 #endif
+#endif
+#ifndef BZERO
 #ifdef USEBZERO
 #  define BZERO(from,len)		bzero((from), (len))
 #else
 #  define BZERO(from,len)		memset((from), 0, (len))
+#endif
 #endif
 
 /*********** Some convenient macros **************/
diff -ruN klic-3.003-2002-01-04/runtime/kmain.c klic-3.003-2002-01-05/runtime/kmain.c
--- klic-3.003-2002-01-04/runtime/kmain.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-05/runtime/kmain.c	Sat Jan  5 12:42:25 2002
@@ -105,7 +105,6 @@
 {
   declare_globals;
   q *initiate_prioq();
-  q *reinitiate_prioq();
 #ifdef USESIG
   void init_klic_signal_handling();
 #endif
diff -ruN klic-3.003-2002-01-04/runtime/sched.c klic-3.003-2002-01-05/runtime/sched.c
--- klic-3.003-2002-01-04/runtime/sched.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-05/runtime/sched.c	Sat Jan  5 14:05:41 2002
@@ -4,6 +4,8 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
+#include <assert.h>
 #include <klic/basic.h>  /* fatal, fatalf */
 #include <klic/struct.h>
 
@@ -13,137 +15,167 @@
 #include <klic/primitives.h>
 
 #include <stdio.h>
+
 #ifdef DEBUGLIB
 #include "trace.h"  /* enqueue_trace_rec, trace_enqueued_goals, trace_flag */
 #endif
+
 #ifdef SHM
 #include <setjmp.h>
 #include "shm.h"
+
 extern jmp_buf klic_topmost;
+
+static module mastersucceed(struct global_variables* glbl, struct goalrec* qp,
+  q* allocp, const struct predicate* toppred );
+
+static module childsucceed(struct global_variables* glbl, struct goalrec* qp,
+  q* allocp, const struct predicate* toppred );
+
+static const struct predicate mastersucceed_pred = { mastersucceed, 0, 0 };
+static const struct predicate childsucceed_pred = { childsucceed, 0, 0 };
+#endif  /* SHM */
+
+#define new_prioqrec(pqr) \
+do{ \
+  struct prioqrec* temp; \
+  while( (temp = prioqrec_free) == NULL ){ \
+    prioqrec_free = more_prioqrec(); \
+  } \
+  prioqrec_free = temp->next; \
+  (pqr) = temp; \
+}while(0)
+
+#define free_prioqrec(pqr) \
+do{ \
+  pqr->next = prioqrec_free; \
+  prioqrec_free = pqr; \
+}while(0)
+
+
+extern char* calloc();
+extern module topsucceed();
+
+#ifdef DIST
+extern struct goalrec* send_throw_goal();
+#endif
+#ifdef SHM
+extern struct goalrec* throw_goal_routine();
 #endif
 
-#define new_prioqrec(pqr)			\
-{						\
-  struct prioqrec *temp;			\
-  while ((temp = prioqrec_free) == 0) {		\
-    prioqrec_free = more_prioqrec();		\
-  }						\
-  prioqrec_free = temp->next;			\
-  (pqr) = temp;					\
-}
+/* temp */
+extern struct ex_goalrec** shm_qp;
 
-#define free_prioqrec(pqr)			\
-{						\
-  pqr->next = prioqrec_free;			\
-  prioqrec_free = pqr;				\
-}
 
-struct prioqrec *prioqrec_free = 0;
+extern module wait_prio_routine(struct global_variables* glbl,
+  struct goalrec* qp, q* allocp, const struct predicate* toppred );
+
+extern module wait_penum_routine(struct global_variables* glbl,
+  struct goalrec* qp, q* allocp, const struct predicate* toppred );
+
+static module queue_empty(struct global_variables* glbl, struct goalrec* qp,
+  q* allocp, struct goalrec* fg, const struct predicate* toppred);
+
+const struct predicate queue_empty_pred = { queue_empty, 0, 0 };
+const struct predicate topsucceed_pred = { topsucceed, 0, 0 };
+
+struct goalrec goal_queue_tail = { 0, &queue_empty_pred, { 0 } };
 
-struct prioqrec *more_prioqrec()
+
+static struct prioqrec* prioqrec_free = NULL;
+
+static struct prioqrec*
+more_prioqrec()
 {
   unsigned long k;
-  extern char *calloc();
-  struct prioqrec *bulk =
-    (struct prioqrec *)
-      calloc(PRIOQRECBULK, sizeof(struct prioqrec));
-  for (k = PRIOQRECBULK-1; k != 0; k--) {
+  struct prioqrec* bulk =
+    (struct prioqrec*) calloc(PRIOQRECBULK, sizeof(struct prioqrec));
+  for( k = PRIOQRECBULK-1; k > 0; k-- ){
     bulk[k-1].next = &bulk[k];
   }
+  assert( k==0 );
+
   bulk[PRIOQRECBULK-1].next = 0;
   return bulk;
 }
 
-module queue_empty();
-extern module topsucceed();
-
-const struct predicate queue_empty_pred = { queue_empty, 0, 0 };
-const struct predicate topsucceed_pred = { topsucceed, 0, 0 };
-#ifdef SHM
-module mastersucceed();
-const struct predicate mastersucceed_pred = { mastersucceed, 0, 0 };
-module childsucceed();
-const struct predicate childsucceed_pred = { childsucceed, 0, 0 };
-#endif
-
-struct goalrec
-  goal_queue_tail = { 0, &queue_empty_pred, { 0 } };
-
 static struct predicate wait_prio_preds[MAXSTDARGS+1];
-module wait_prio_routine();
-
-struct predicate wait_penum_preds[MAXSTDARGS+1]; /* for inter nodes */
-module wait_penum_routine();
+static struct predicate wait_penum_preds[MAXSTDARGS+1]; /* for inter nodes */
 
-q *reinitiate_prioq(allocp)
-     q *allocp;
+static q*
+reinitiate_prioq(allocp)
+  q* allocp;
 {
   declare_globals;
-  static struct prioqrec
-    *pq,
-    tail_sentinel = { 0, -1, 0 };
+  static struct prioqrec* pq;
+  static struct prioqrec tail_sentinel = { 0, -1, 0 };
 
   new_prioqrec(pq);
-  /*
-    The tail of the lowest priority level is top level succeed goal.
-  */
+
+  /* The tail of the lowest priority level is top level succeed goal. */
   pq->next = &tail_sentinel;
   pq->prio = 0;
+
 #ifdef SHM
-  if (my_node == MASTER) {
-    allocp[0] = (q)&goal_queue_tail;
-    allocp[1] = (q)&mastersucceed_pred;
-    pq->q = (struct goalrec *)allocp;
-  } else {
-    allocp[0] = (q)&goal_queue_tail;
-    allocp[1] = (q)&childsucceed_pred;
-    pq->q = (struct goalrec *)allocp;
+  if( my_node == MASTER ){
+    allocp[0] = (q) &goal_queue_tail;
+    allocp[1] = (q) &mastersucceed_pred;
+    pq->q = (struct goalrec*) allocp;
+  }else{
+    allocp[0] = (q) &goal_queue_tail;
+    allocp[1] = (q) &childsucceed_pred;
+    pq->q = (struct goalrec*) allocp;
   }
   allocp += 2;
 #else
-  allocp[0] = (q)&goal_queue_tail;
-  allocp[1] = (q)&topsucceed_pred;
-  pq->q = (struct goalrec *)allocp;
+  allocp[0] = (q) &goal_queue_tail;
+  allocp[1] = (q) &topsucceed_pred;
+  pq->q = (struct goalrec*) allocp;
   allocp += 2;
 #endif
+
   prioq.next = pq;
 
   return allocp;
 }
 
-q *initiate_prioq(allocp)
-     q *allocp;
+extern q*
+initiate_prioq(allocp)
+  q* allocp;
 {
   int k;
+
   /* Prepare for creating goals that wait for priority value */
-  for (k=0; k<=MAXSTDARGS; k++) {
+  for( k=0; k<=MAXSTDARGS; k++ ){
     wait_prio_preds[k].func = wait_prio_routine;
     wait_prio_preds[k].pred = k;
     wait_prio_preds[k].arity = k+3;
   }
+
   /* Prepare for creating goals that wait for node value */
-  for (k=0; k<=MAXSTDARGS; k++) {
+  for( k=0; k<=MAXSTDARGS; k++ ){
     wait_penum_preds[k].func = wait_penum_routine;
     wait_penum_preds[k].pred = k;
     wait_penum_preds[k].arity = k+2;
   }
+
   return reinitiate_prioq(allocp);
 }
 
 extern struct goalrec*
 enqueue_goal(qp, prio, gp, glbl)
-     struct goalrec *qp;
-     long prio;
-     struct goalrec *gp;
-     struct global_variables *glbl;
+  struct goalrec* qp;
+  long prio;
+  struct goalrec* gp;
+  struct global_variables* glbl;
 {
-  if (prio<0) prio = 0;
-  if (current_prio == prio) {
+  if( prio<0 ) prio = 0;
+  if( current_prio == prio ){
     gp->next = qp;
     qp = gp;
-  } else {
+  }else{
 #ifdef DEBUGLIB
-    if (trace_flag) {
+    if( trace_flag ){
       struct enqueue_trace_rec* tr;
       tr = (struct enqueue_trace_rec*)
 	malloc_check(sizeof(struct enqueue_trace_rec));
@@ -151,22 +183,22 @@
       tr->g = gp;
       tr->prio = prio;
       trace_enqueued_goals = tr;
-    } else
+    }else
 #endif
     {
-      struct prioqrec *pq = &prioq;
-      while (pq->next->prio > prio) {
+      struct prioqrec* pq = &prioq;
+      while( pq->next->prio > prio ){
 	pq = pq->next;
       }
-      if (pq->next->prio == prio) {
+      if( pq->next->prio == prio ){
 	/* there already are some active goals with the same priority */
 	pq = pq->next;
 	gp->next = pq->q;
 	pq->q = gp;
-      } else {
+      }else{
 	/* there are no active goals with the same priority */
 	/* must allocate a new prioqrec entry */
-	struct prioqrec *newpq;
+	struct prioqrec* newpq;
 	new_prioqrec(newpq);
 	newpq->next = pq->next;
 	pq->next = newpq;
@@ -174,8 +206,9 @@
 	newpq->q = gp;
 	gp->next = &goal_queue_tail;
       }
+
       /* interrupt for higher priority goal */
-      if (current_prio < prio){
+      if( current_prio < prio ){
 	higher_priority_goal = 1;
 	heaplimit = 0;
       }
@@ -186,51 +219,53 @@
 
 static void
 priority_type_error(gp)
-     struct goalrec *gp;
+  struct goalrec* gp;
 {
   fatal("Non-integer priority specified");
 }
 
 extern struct goalrec*
 enqueue_after_waiting(qp, prio, gp, allocp, is_relative)
-     struct goalrec *qp;
-     q prio;
-     struct goalrec *gp;
-     q *allocp;
-     int is_relative;
+  struct goalrec* qp;
+  q prio;
+  struct goalrec* gp;
+  q* allocp;
+  int is_relative;
 {
   declare_globals;
-  struct goalrec *ng;
+  struct goalrec* ng;
   int k;
  again:
-  if (isint(prio)) {
+  if( isint(prio) ){
     return
       enqueue_goal(qp,
 		   (is_relative ? current_prio-intval(prio) : intval(prio)),
 		   gp, glbl);
   }
-  if (!isref(prio)) priority_type_error(qp);
+  if( !isref(prio) ) priority_type_error(qp);
   {
     q value = derefone(prio);
-    if (value != prio && (!isref(value) || derefone(value) != prio)) {
+    if( value != prio && (!isref(value) || derefone(value) != prio) ){
       prio = value;
       goto again;
     }
   }
-  heapalloc(ng, gp->pred->arity+(2+3), (struct goalrec *));
-  for (k=0; k!=gp->pred->arity; k++) {
+  heapalloc(ng, gp->pred->arity+(2+3), (struct goalrec*));
+  for( k=0; k < gp->pred->arity; k++ ){
     ng->args[k] = gp->args[k];
   }
+  assert(k == gp->pred->arity);
+
   ng->args[k] = makecons(gp->pred);
   ng->args[k+1] = prio;
   ng->args[k+2] = (is_relative ? makeint(1) : makeint(0));
   ng->pred = &wait_prio_preds[gp->pred->arity];
   {
-    struct goalrec *rsmg = resumed_goals;
-    if (rsmg == 0) {
+    struct goalrec* rsmg = resumed_goals;
+    if( rsmg == 0 ){
       rsmg = ng;
       ng->next = ng;
-    } else {
+    }else{
       ng->next = rsmg->next;
       rsmg->next = ng;
     }
@@ -240,44 +275,38 @@
   return qp;
 }
 
-module wait_prio_routine(glbl, qp, allocp, toppred)
-  struct global_variables *glbl;
-  struct goalrec *qp;
-  q *allocp;
+extern module
+wait_prio_routine(glbl, qp, allocp, toppred)
+  struct global_variables* glbl;
+  struct goalrec* qp;
+  q* allocp;
   const struct predicate* toppred;
 {
   int arity = toppred->pred;
   q prio = qp->args[arity+1];
   int is_relative = intval(qp->args[arity+2]);
 
-  qp->pred = (struct predicate *)consp(qp->args[arity]);
+  qp->pred = (struct predicate*) consp(qp->args[arity]);
   qp = enqueue_after_waiting(qp->next, prio, qp, allocp, is_relative);
   heapp = allocp;
   current_queue = qp;
-  return (module)qp->pred->func;
+  return (module) qp->pred->func;
 }
 
-#ifdef DIST
-struct goalrec *send_throw_goal();
-#endif
-#ifdef SHM
-struct goalrec *throw_goal_routine();
-#endif
-
 extern struct goalrec*
 enqueue_throw_goal(penum, gp, qp, allocp)
-     q penum;
-     struct goalrec *gp;
-     struct goalrec *qp;
-     q *allocp;
+  q penum;
+  struct goalrec* gp;
+  struct goalrec* qp;
+  q* allocp;
 {
   declare_globals;
-  struct goalrec *ng;
+  struct goalrec* ng;
   int k;
  again:
-  if (isint(penum)) {
+  if( isint(penum) ){
     int pn = intval(penum);
-    if ( pn != my_node ) {
+    if( pn != my_node ){
 #ifdef DIST
       return send_throw_goal(intval(penum), gp, qp);
 #else
@@ -287,29 +316,31 @@
       return enqueue_goal(qp, current_prio, gp, glbl);
 # endif
 #endif
-    } else return enqueue_goal(qp, current_prio, gp, glbl);
+    }else return enqueue_goal(qp, current_prio, gp, glbl);
   }
-  if (!isref(penum)) fatal("inter cluster pragma error");
+  if( !isref(penum) ) fatal("inter cluster pragma error");
   {
     q value = derefone(penum);
-    if (value != penum && (!isref(value) || derefone(value) != penum)) {
+    if( value != penum && (!isref(value) || derefone(value) != penum) ){
       penum = value;
       goto again;
     }
   }
-  heapalloc(ng, gp->pred->arity+(2+2), (struct goalrec *));
-  for (k=0; k!=gp->pred->arity; k++) {
+  heapalloc(ng, gp->pred->arity+(2+2), (struct goalrec*));
+  for( k=0; k < gp->pred->arity; k++ ){
     ng->args[k] = gp->args[k];
   }
+  assert(k == gp->pred->arity);
+
   ng->args[k] = makecons(gp->pred);
   ng->args[k+1] = penum;
   ng->pred = &wait_penum_preds[gp->pred->arity];
   {
-    struct goalrec *rsmg = resumed_goals;
-    if (rsmg == 0) {
+    struct goalrec* rsmg = resumed_goals;
+    if( rsmg == NULL ){
       rsmg = ng;
       ng->next = ng;
-    } else {
+    }else{
       ng->next = rsmg->next;
       rsmg->next = ng;
     }
@@ -317,32 +348,31 @@
   }
   heaplimit = 0;
   return qp;
-
 }
 
-module
+extern module
 wait_penum_routine(glbl, qp, allocp, toppred)
-  struct global_variables *glbl;
-  struct goalrec *qp;
-  q *allocp;
+  struct global_variables* glbl;
+  struct goalrec* qp;
+  q* allocp;
   const struct predicate* toppred;
 {
   int arity = toppred->pred;
   q penum = qp->args[arity+1];
 
-  qp->pred = (struct predicate *)consp(qp->args[arity]);
+  qp->pred = (struct predicate*) consp(qp->args[arity]);
   qp = enqueue_throw_goal(penum, qp, qp->next, allocp);
   heapp = allocp;
   current_queue = qp;
-  return (module)qp->pred->func;
+  return (module) qp->pred->func;
 }
 
-struct goalrec *
+extern struct goalrec*
 get_top_priority_queue()
 {
   declare_globals;
-  struct goalrec *newqp;
-  struct prioqrec *newprioq;
+  struct goalrec* newqp;
+  struct prioqrec* newprioq;
 
   newqp = prioq.next->q;
   current_prio = prioq.next->prio;
@@ -352,25 +382,25 @@
   return newqp;
 }
 
-void
+extern void
 put_priority_queue(qp, prio)
-     struct goalrec *qp;
-     long prio;
+  struct goalrec* qp;
+  long prio;
 {
   declare_globals;
-  struct prioqrec *pq = &prioq;
+  struct prioqrec* pq = &prioq;
 
-  while(pq->next->prio >= prio) {
+  while( pq->next->prio >= prio ){
     pq = pq->next;
   }
-  if (pq->next->prio == prio) {
+  if( pq->next->prio == prio ){
     /* there are some active goals with the same priority */
     pq = pq->next;
     qp->next = pq->q;
     pq->q = qp;
-  } else {
-    /* there a no goals with the same priority */
-    struct prioqrec *newpq;
+  }else{
+    /* there are no goals with the same priority */
+    struct prioqrec* newpq;
     new_prioqrec(newpq);
     newpq->next = pq->next;
     pq->next = newpq;
@@ -380,25 +410,25 @@
 }
 
 #ifdef SHM
-void
+static void
 put_priority_goal(qp, prio)
-     struct goalrec *qp;
-     long prio;
+  struct goalrec* qp;
+  long prio;
 {
   declare_globals;
-  struct prioqrec *pq = &prioq;
+  struct prioqrec* pq = &prioq;
 
-  while(pq->next->prio > prio) {
+  while( pq->next->prio > prio ){
     pq = pq->next;
   }
-  if (pq->next->prio == prio) {
+  if( pq->next->prio == prio ){
     /* there are some active goals with the same priority */
     pq = pq->next;
     qp->next = pq->q;
     pq->q = qp;
-  } else {
-    /* there a no goals with the same priority */
-    struct prioqrec *newpq;
+  }else{
+    /* there are no goals with the same priority */
+    struct prioqrec* newpq;
     new_prioqrec(newpq);
     newpq->next = pq->next;
     pq->next = newpq;
@@ -416,175 +446,177 @@
   becomes empty.  The call is automatic by having a dummy goal
   "goal_queue_tail" as the common tail of queues, instead of NULL.
 */
-/* temp */
-extern struct ex_goalrec** shm_qp;
 
-module queue_empty(glbl, qp, allocp, fg, toppred)
-     struct global_variables *glbl;
-     struct goalrec *qp;
-     struct goalrec *fg;
-     q *allocp;
-     const struct predicate* toppred;
+static module
+queue_empty(glbl, qp, allocp, fg, toppred)
+  struct global_variables* glbl;
+  struct goalrec* qp;
+  q* allocp;
+  struct goalrec* fg;
+  const struct predicate* toppred;
 {
 #ifdef SHM
-  if ( ext_queued ) {
-     ext_queued = 0;
-     qp = get_invoked_goals(&goal_queue_tail);
-     heapp = allocp;
-     current_queue = qp;
-     return (module)qp->pred->func;
+  if( ext_queued ){
+    ext_queued = 0;
+    qp = get_invoked_goals(&goal_queue_tail);
+    heapp = allocp;
+    current_queue = qp;
+    return (module) qp->pred->func;
   }
 #endif
   qp = get_top_priority_queue();
   heapp = allocp;
   current_queue = qp;
-  return (module)qp->pred->func;
+  return (module) qp->pred->func;
 }
 
 #ifdef SHM
-struct goalrec *get_invoked_goals(qp)
-struct goalrec *qp;
+extern struct goalrec*
+get_invoked_goals(qp)
+  struct goalrec* qp;
 {
-    declare_globals;
-    int key = p_key(my_node);
+  declare_globals;
+  int key = p_key(my_node);
 
-    struct ex_goalrec *sqp, *eqp;
+  struct ex_goalrec *sqp, *eqp;
 
-    s_lock(key);
-    if ( !(sqp = ex_qp->next) ) { s_unlock(key); return(qp); }
-    eqp = sqp;
-    while ( eqp->next )  { eqp = eqp->next; }
-    ex_qp = eqp;
-    s_unlock(key);
-
-    put_priority_queue(qp,current_prio);
-    eqp = sqp;
-    while(1) {
-      put_priority_goal(&eqp->goal,eqp->prio);
-      if ( eqp == ex_qp )  break;
-      eqp = eqp->next;
-    }
+  s_lock(key);
+  sqp = ex_qp->next;
+  if( sqp == NULL ){ s_unlock(key); return qp; }
+  eqp = sqp;
+  while( eqp->next != NULL ){ eqp = eqp->next; }
+  ex_qp = eqp;
+  s_unlock(key);
 
-    return( get_top_priority_queue() );
+  put_priority_queue(qp, current_prio);
+  eqp = sqp;
+  for(;;){
+    put_priority_goal(&eqp->goal, eqp->prio);
+    if( eqp == ex_qp )  break;
+    eqp = eqp->next;
   }
 
+  return get_top_priority_queue();
+}
+
+
+static module
+mastersucceed(glbl, qp, allocp, toppred)
+  struct global_variables* glbl;
+  struct goalrec* qp;
+  q* allocp;
+  const struct predicate* toppred;
+{
+  int first, i;
+
+  /* printf("Wait master.\n"); */
+
+ WLoop:
+  if( !(ex_qp->next) ){
+    heapp = klic_interrupt(allocp, qp);
+    if( current_queue != qp ){
+      *cur_status = 1;
+      qp = current_queue;
+      toppred = qp->pred;
+      return (module) toppred->func;
+    }
 
-module mastersucceed(glbl, qp, allocp, toppred)
-struct global_variables *glbl;
-struct goalrec *qp;
-q *allocp;
-const struct predicate* toppred;
-{
-    int first,i;
-
-/*    printf("Wait master.\n");*/
-
-  WLoop:
-    if ( !(ex_qp->next) ) {
-         heapp = klic_interrupt(allocp,qp);
-         if ( current_queue != qp ) {
-             *cur_status = 1;
-              qp = current_queue;
-             {
-               module func = (module)(toppred = qp->pred)->func;
-               return func;
-             }
-           }
-
-        {
-           struct global_variables* tglbl;
-           for (i=1;i<total_node;i++) {
-             tglbl = get_otherPE_glbl(i);
-             if ( top_shm_qp[i] != tglbl->par.aux.shm.ex_qp0 ) goto WLoop;
-             if ( pe_status[i] ) goto WLoop;
-           }
-           if ( ex_qp->next ) goto WLoop;
-           for (i=0;i<total_node;i++) { s_lock(p_key(i)); }
-	   *cur_status = 0;
-           for (i=0;i<total_node;i++) {
-             tglbl = get_otherPE_glbl(i);
-             if ( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
-		 !pe_status[i] )  continue;
-             for (i=0;i<total_node;i++) { s_unlock(p_key(i)); }
-             goto WLoop;
-           }
-	   for (i=0;i<total_node;i++) { /* One more */
-             tglbl = get_otherPE_glbl(i);
-             if ( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
-		 !pe_status[i] )  continue;
-             for (i=0;i<total_node;i++) { s_unlock(p_key(i)); }
-             goto WLoop;
-	   }
-	   for (i=total_node-1;i>=0;i--) { /* One more */
-             tglbl = get_otherPE_glbl(i);
-             if ( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
-		 !pe_status[i] ) continue;
-             for (i=0;i<total_node;i++) { s_unlock(p_key(i)); }
-             goto WLoop;
-	   }
-        }
-
-	for (i=0;i<total_node;i++) { s_unlock(p_key(i)); }
-
-        if ( suspensions - resumes ) {
-            fatalf(" %d perpetual suspending goals.",(suspensions-resumes));
-          }
-         {
-          struct ex_goalrec *eqp;
-          struct goalrec *qp;
-
-          for (i=1;i<total_node;i++) {
-             eqp = (struct ex_goalrec*)galloc(4);
-             eqp->prio = HIGHESTPRIO-1;
-             qp = &eqp->goal;
-             qp->next = 0;
-             qp->pred = &topsucceed_pred;
-             shm_goal_stack(eqp,i);
-           }
-          longjmp(klic_topmost, 0);
-        }
-       }
-    qp = get_invoked_goals(qp);
     {
-      module func = (module)(toppred = qp->pred)->func;
-      heapp = allocp;
-      current_queue = qp;
-      return func;
+      struct global_variables* tglbl;
+      for( i=1; i<total_node; i++ ){
+	tglbl = get_otherPE_glbl(i);
+	if( top_shm_qp[i] != tglbl->par.aux.shm.ex_qp0 ) goto WLoop;
+	if( pe_status[i] ) goto WLoop;
+      }
+      if( ex_qp->next ) goto WLoop;
+      for( i=0; i<total_node; i++ ){ s_lock(p_key(i)); }
+      *cur_status = 0;
+      for( i=0; i<total_node; i++ ){
+	tglbl = get_otherPE_glbl(i);
+	if( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
+	    !pe_status[i] )  continue;
+	for( i=0; i<total_node; i++ ){ s_unlock(p_key(i)); }
+	goto WLoop;
+      }
+      for( i=0; i<total_node; i++ ){  /* One more */
+	tglbl = get_otherPE_glbl(i);
+	if( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
+	    !pe_status[i] )  continue;
+	for( i=0; i<total_node; i++ ){ s_unlock(p_key(i)); }
+	goto WLoop;
+      }
+      for( i=total_node-1; i>=0; i-- ){  /* One more */
+	tglbl = get_otherPE_glbl(i);
+	if( ( top_shm_qp[i] == tglbl->par.aux.shm.ex_qp0 ) &&
+	    !pe_status[i] ) continue;
+	for( i=0; i<total_node; i++ ){ s_unlock(p_key(i)); }
+	goto WLoop;
+      }
     }
-  }
 
+    for( i=0; i<total_node; i++ ){ s_unlock(p_key(i)); }
 
-module childsucceed(glbl, qp, allocp, toppred)
-struct global_variables *glbl;
-struct goalrec *qp;
-q *allocp;
-const struct predicate* toppred;
-{
-
-    while ( !(ex_qp->next) ) {
-       heapp = klic_interrupt(allocp,qp);
-       if ( current_queue != qp ) {
-           *cur_status = 1;
-           qp = current_queue;
-           {
-             module func = (module)(toppred = qp->pred)->func;
-             return func;
-           }
-         }
-       *cur_status = 0;
-     }
+    if( suspensions != resumes ){
+      fatalf(" %d perpetual suspending goals.", (suspensions-resumes));
+    }
+    {
+      struct ex_goalrec* eqp;
+      struct goalrec* qp;
 
-    *cur_status = 1;
-    klic_barrier();
+      for( i=1; i<total_node; i++ ){
+	eqp = (struct ex_goalrec*) galloc(4);
+	eqp->prio = HIGHESTPRIO-1;
+	qp = &eqp->goal;
+	qp->next = 0;
+	qp->pred = &topsucceed_pred;
+	shm_goal_stack(eqp, i);
+      }
+      longjmp(klic_topmost, 0);
+    }
+  }
+  qp = get_invoked_goals(qp);
+  {
+    module func;
+    toppred = qp->pred;
+    func = (module) toppred->func;
+    heapp = allocp;
+    current_queue = qp;
+    return func;
+  }
+}
 
-    qp = get_invoked_goals(qp);
-/*    dump_queue(qp); */
 
-    {
-      module func = (module)(toppred = qp->pred)->func;
-      heapp = allocp;
-      current_queue = qp;
-      return func;
+static module
+childsucceed(glbl, qp, allocp, toppred)
+  struct global_variables* glbl;
+  struct goalrec* qp;
+  q* allocp;
+  const struct predicate* toppred;
+{
+  while( !(ex_qp->next) ){
+    heapp = klic_interrupt(allocp, qp);
+    if( current_queue != qp ){
+      *cur_status = 1;
+      qp = current_queue;
+      toppred = qp->pred;
+      return (module) toppred->func;
     }
+    *cur_status = 0;
   }
-#endif
+
+  *cur_status = 1;
+  klic_barrier();
+
+  qp = get_invoked_goals(qp);
+  /* dump_queue(qp); */
+
+  {
+    module func;
+    toppred = qp->pred;
+    func = (module) toppred->func;
+    heapp = allocp;
+    current_queue = qp;
+    return func;
+  }
+}
+#endif  /* SHM */
diff -ruN klic-3.003-2002-01-04/runtime/schedule.h klic-3.003-2002-01-05/runtime/schedule.h
--- klic-3.003-2002-01-04/runtime/schedule.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-01-05/runtime/schedule.h	Sat Jan  5 14:06:20 2002
@@ -10,9 +10,6 @@
 
 
 /* runtime/sched.c */
-
-extern struct prioqrec* more_prioqrec(void);
-
 extern struct goalrec* get_top_priority_queue(void);
 extern void put_priority_queue(struct goalrec* qp, long prio);
 
