Index: trunk/kernel/libk/remote_barrier.c
===================================================================
--- trunk/kernel/libk/remote_barrier.c	(revision 619)
+++ trunk/kernel/libk/remote_barrier.c	(revision 623)
@@ -245,5 +245,22 @@
 }  // end generic_barrier_wait()
 
-
+/////////////////////////////////////////////////////
+void generic_barrier_display( xptr_t gen_barrier_xp )
+{
+    // get cluster and local pointer
+    generic_barrier_t * gen_barrier_ptr = GET_PTR( gen_barrier_xp );
+    cxy_t               gen_barrier_cxy = GET_CXY( gen_barrier_xp );
+
+    // get barrier type and extend pointer
+    bool_t  is_dqt = hal_remote_l32( XPTR( gen_barrier_cxy , &gen_barrier_ptr->is_dqt ) );
+    void  * extend = hal_remote_lpt( XPTR( gen_barrier_cxy , &gen_barrier_ptr->extend ) );
+
+    // buil extended pointer on the implementation specific barrier descriptor
+    xptr_t barrier_xp = XPTR( gen_barrier_cxy , extend );
+
+    // display barrier state
+    if( is_dqt ) dqt_barrier_display( barrier_xp );
+    else         simple_barrier_display( barrier_xp );
+}
 
 
@@ -454,4 +471,22 @@
 
 }  // end simple_barrier_wait()
+
+/////////////////////////////////////////////////
+void simple_barrier_display( xptr_t  barrier_xp )
+{
+    // get cluster and local pointer on simple barrier 
+    simple_barrier_t * barrier_ptr = GET_PTR( barrier_xp );
+    cxy_t              barrier_cxy = GET_CXY( barrier_xp );
+
+    // get barrier global parameters
+    uint32_t current  = hal_remote_l32( XPTR( barrier_cxy , &barrier_ptr->current ) );
+    uint32_t arity    = hal_remote_l32( XPTR( barrier_cxy , &barrier_ptr->arity   ) );
+
+    printk("\n***** simple barrier : %d arrived threads on %d *****\n",
+    current, arity );
+
+}   // end simple_barrier_display()
+
+
 
 
@@ -493,5 +528,5 @@
 
 // check x_size and y_size arguments
-assert( (z <= 16) , "DQT dqth larger than (16*16)\n");
+assert( (z <= 16) , "DQT mesh size larger than (16*16)\n");
 
 // check RPC descriptor size
@@ -973,141 +1008,6 @@
 }  // end dqt_barrier_wait()
 
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//          DQT static functions 
-////////////////////////////////////////////////////////////////////////////////////////////
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// This recursive function decrements the distributed "count" variables,
-// traversing the DQT from bottom to root.
-// The last arrived thread reset the local node before returning.
-//////////////////////////////////////////////////////////////////////////////////////////
-static void dqt_barrier_increment( xptr_t  node_xp )
-{
-    uint32_t   expected;
-    uint32_t   sense;
-    uint32_t   arity;
-
-    thread_t * this = CURRENT_THREAD;
-
-    // get node cluster and local pointer
-    dqt_node_t * node_ptr = GET_PTR( node_xp );
-    cxy_t        node_cxy = GET_CXY( node_xp );
-
-    // build relevant extended pointers
-    xptr_t  arity_xp   = XPTR( node_cxy , &node_ptr->arity );
-    xptr_t  sense_xp   = XPTR( node_cxy , &node_ptr->sense );
-    xptr_t  current_xp = XPTR( node_cxy , &node_ptr->current );
-    xptr_t  lock_xp    = XPTR( node_cxy , &node_ptr->lock );
-    xptr_t  root_xp    = XPTR( node_cxy , &node_ptr->root );
-
-#if DEBUG_BARRIER_WAIT
-uint32_t   cycle = (uint32_t)hal_get_cycles();
-uint32_t   level = hal_remote_l32( XPTR( node_cxy, &node_ptr->level ) );
-if( cycle > DEBUG_BARRIER_WAIT )
-printk("\n[%s] thread[%x,%x] increments DQT node(%d,%d,%d) / cycle %d\n",
-__FUNCTION__ , this->process->pid, this->trdid, 
-HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
-#endif
-
-    // get extended pointer on parent node
-    xptr_t  parent_xp  = hal_remote_l64( XPTR( node_cxy , &node_ptr->parent_xp ) );
-
-    // take busylock
-    remote_busylock_acquire( lock_xp );
-    
-    // get sense and arity values from barrier descriptor
-    sense = hal_remote_l32( sense_xp );
-    arity = hal_remote_l32( arity_xp );
-
-    // compute expected value 
-    expected = (sense == 0) ? 1 : 0;
-
-    // increment current number of arrived threads / get value before increment
-    uint32_t current = hal_remote_atomic_add( current_xp , 1 );
-
-    // last arrived thread reset the local node, makes the recursive call 
-    // on parent node, and reactivates all waiting thread when returning.
-    // other threads block, register in queue, and deschedule.
-
-    if ( current == (arity - 1) )                        // last thread  
-    {
-
-#if DEBUG_BARRIER_WAIT
-if( cycle > DEBUG_BARRIER_WAIT )
-printk("\n[%s] thread[%x,%x] reset DQT node(%d,%d,%d)\n",
-__FUNCTION__ , this->process->pid, this->trdid,
-HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
-#endif
-        // reset the current node
-        hal_remote_s32( sense_xp   , expected );
-        hal_remote_s32( current_xp , 0 );
-
-        // release busylock protecting the current node
-        remote_busylock_release( lock_xp );
-
-        // recursive call on parent node when current node is not the root
-        if( parent_xp != XPTR_NULL) dqt_barrier_increment( parent_xp );
-
-        // unblock all waiting threads on this node
-        while( xlist_is_empty( root_xp ) == false )
-        {
-            // get pointers on first waiting thread
-            xptr_t     thread_xp  = XLIST_FIRST( root_xp , thread_t , wait_list );
-            cxy_t      thread_cxy = GET_CXY( thread_xp );
-            thread_t * thread_ptr = GET_PTR( thread_xp );
-
-#if (DEBUG_BARRIER_WAIT & 1)
-trdid_t     trdid   = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
-process_t * process = hal_remote_lpt( XPTR( thread_cxy , &thread_ptr->process ) );
-pid_t       pid     = hal_remote_l32( XPTR( thread_cxy , &process->pid ) ); 
-if( cycle > DEBUG_BARRIER_WAIT )
-printk("\n[%s] thread[%x,%x] unblock thread[%x,%x]\n",
-__FUNCTION__, this->process->pid, this->trdid, pid, trdid );
-#endif
-            // remove waiting thread from queue
-            xlist_unlink( XPTR( thread_cxy , &thread_ptr->wait_list ) );
-
-            // unblock waiting thread
-            thread_unblock( thread_xp , THREAD_BLOCKED_USERSYNC );
-        }
-    }
-    else                                               // not the last thread
-    {
-        // get extended pointer on xlist entry from thread
-        xptr_t  entry_xp = XPTR( local_cxy , &this->wait_list );
-        
-        // register calling thread in barrier waiting queue
-        xlist_add_last( root_xp , entry_xp );
-
-        // block calling thread
-        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_USERSYNC );
-
-        // release busylock protecting the remote_barrier
-        remote_busylock_release( lock_xp );
-
-#if DEBUG_BARRIER_WAIT
-if( cycle > DEBUG_BARRIER_WAIT )
-printk("\n[%s] thread[%x,%x] blocks on node(%d,%d,%d)\n",
-__FUNCTION__ , this->process->pid, this->trdid,
-HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
-#endif
-        // deschedule
-        sched_yield("blocked on barrier");
-    }
-
-    return;
-
-} // end dqt_barrier_decrement()
-
-#if DEBUG_BARRIER_CREATE 
-
-////////////////////////////////////////////////////////////////////////////////////////////
-// This debug function displays all DQT nodes in all clusters.
-////////////////////////////////////////////////////////////////////////////////////////////
-// @ barrier_xp   : extended pointer on DQT barrier descriptor.
-////////////////////////////////////////////////////////////////////////////////////////////
-static void dqt_barrier_display( xptr_t  barrier_xp )
+//////////////////////////////////////////////
+void dqt_barrier_display( xptr_t  barrier_xp )
 {
     // get cluster and local pointer on DQT barrier 
@@ -1147,4 +1047,5 @@
                      uint32_t level = hal_remote_l32( XPTR( node_cxy , &node_ptr->level       ));
                      uint32_t arity = hal_remote_l32( XPTR( node_cxy , &node_ptr->arity       ));
+                     uint32_t count = hal_remote_l32( XPTR( node_cxy , &node_ptr->current     ));
                      xptr_t   pa_xp = hal_remote_l32( XPTR( node_cxy , &node_ptr->parent_xp   ));
                      xptr_t   c0_xp = hal_remote_l32( XPTR( node_cxy , &node_ptr->child_xp[0] ));
@@ -1153,7 +1054,7 @@
                      xptr_t   c3_xp = hal_remote_l32( XPTR( node_cxy , &node_ptr->child_xp[3] ));
 
-                     printk("   . level %d : (%x,%x) / arity %d / P(%x,%x) / C0(%x,%x)"
+                     printk("   . level %d : (%x,%x) / %d on %d / P(%x,%x) / C0(%x,%x)"
                             " C1(%x,%x) / C2(%x,%x) / C3(%x,%x)\n",
-                     level, node_cxy, node_ptr, arity, 
+                     level, node_cxy, node_ptr, count, arity, 
                      GET_CXY(pa_xp), GET_PTR(pa_xp),
                      GET_CXY(c0_xp), GET_PTR(c0_xp),
@@ -1167,3 +1068,128 @@
 }   // end dqt_barrier_display()
 
-#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// This static (recursive) function is called by the dqt_barrier_wait() function.
+// It traverses the DQT from bottom to root, and decrements the "current" variables.
+// For each traversed node, it blocks and deschedules if it is not the last expected
+//  thread. The last arrived thread reset the local node before returning.
+//////////////////////////////////////////////////////////////////////////////////////////
+static void dqt_barrier_increment( xptr_t  node_xp )
+{
+    uint32_t   expected;
+    uint32_t   sense;
+    uint32_t   arity;
+
+    thread_t * this = CURRENT_THREAD;
+
+    // get node cluster and local pointer
+    dqt_node_t * node_ptr = GET_PTR( node_xp );
+    cxy_t        node_cxy = GET_CXY( node_xp );
+
+    // build relevant extended pointers
+    xptr_t  arity_xp   = XPTR( node_cxy , &node_ptr->arity );
+    xptr_t  sense_xp   = XPTR( node_cxy , &node_ptr->sense );
+    xptr_t  current_xp = XPTR( node_cxy , &node_ptr->current );
+    xptr_t  lock_xp    = XPTR( node_cxy , &node_ptr->lock );
+    xptr_t  root_xp    = XPTR( node_cxy , &node_ptr->root );
+
+#if DEBUG_BARRIER_WAIT
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+uint32_t   level = hal_remote_l32( XPTR( node_cxy, &node_ptr->level ) );
+if( cycle > DEBUG_BARRIER_WAIT )
+printk("\n[%s] thread[%x,%x] increments DQT node(%d,%d,%d) / cycle %d\n",
+__FUNCTION__ , this->process->pid, this->trdid, 
+HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
+#endif
+
+    // get extended pointer on parent node
+    xptr_t  parent_xp  = hal_remote_l64( XPTR( node_cxy , &node_ptr->parent_xp ) );
+
+    // take busylock
+    remote_busylock_acquire( lock_xp );
+    
+    // get sense and arity values from barrier descriptor
+    sense = hal_remote_l32( sense_xp );
+    arity = hal_remote_l32( arity_xp );
+
+    // compute expected value 
+    expected = (sense == 0) ? 1 : 0;
+
+    // increment current number of arrived threads / get value before increment
+    uint32_t current = hal_remote_atomic_add( current_xp , 1 );
+
+    // last arrived thread reset the local node, makes the recursive call 
+    // on parent node, and reactivates all waiting thread when returning.
+    // other threads block, register in queue, and deschedule.
+
+    if ( current == (arity - 1) )                        // last thread  
+    {
+
+#if DEBUG_BARRIER_WAIT
+if( cycle > DEBUG_BARRIER_WAIT )
+printk("\n[%s] thread[%x,%x] reset DQT node(%d,%d,%d)\n",
+__FUNCTION__ , this->process->pid, this->trdid,
+HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
+#endif
+        // reset the current node
+        hal_remote_s32( sense_xp   , expected );
+        hal_remote_s32( current_xp , 0 );
+
+        // release busylock protecting the current node
+        remote_busylock_release( lock_xp );
+
+        // recursive call on parent node when current node is not the root
+        if( parent_xp != XPTR_NULL) dqt_barrier_increment( parent_xp );
+
+        // unblock all waiting threads on this node
+        while( xlist_is_empty( root_xp ) == false )
+        {
+            // get pointers on first waiting thread
+            xptr_t     thread_xp  = XLIST_FIRST( root_xp , thread_t , wait_list );
+            cxy_t      thread_cxy = GET_CXY( thread_xp );
+            thread_t * thread_ptr = GET_PTR( thread_xp );
+
+#if (DEBUG_BARRIER_WAIT & 1)
+trdid_t     trdid   = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
+process_t * process = hal_remote_lpt( XPTR( thread_cxy , &thread_ptr->process ) );
+pid_t       pid     = hal_remote_l32( XPTR( thread_cxy , &process->pid ) ); 
+if( cycle > DEBUG_BARRIER_WAIT )
+printk("\n[%s] thread[%x,%x] unblock thread[%x,%x]\n",
+__FUNCTION__, this->process->pid, this->trdid, pid, trdid );
+#endif
+            // remove waiting thread from queue
+            xlist_unlink( XPTR( thread_cxy , &thread_ptr->wait_list ) );
+
+            // unblock waiting thread
+            thread_unblock( thread_xp , THREAD_BLOCKED_USERSYNC );
+        }
+    }
+    else                                               // not the last thread
+    {
+        // get extended pointer on xlist entry from thread
+        xptr_t  entry_xp = XPTR( local_cxy , &this->wait_list );
+        
+        // register calling thread in barrier waiting queue
+        xlist_add_last( root_xp , entry_xp );
+
+        // block calling thread
+        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_USERSYNC );
+
+        // release busylock protecting the remote_barrier
+        remote_busylock_release( lock_xp );
+
+#if DEBUG_BARRIER_WAIT
+if( cycle > DEBUG_BARRIER_WAIT )
+printk("\n[%s] thread[%x,%x] blocks on node(%d,%d,%d)\n",
+__FUNCTION__ , this->process->pid, this->trdid,
+HAL_X_FROM_CXY(node_cxy), HAL_Y_FROM_CXY(node_cxy), level );
+#endif
+        // deschedule
+        sched_yield("blocked on barrier");
+    }
+
+    return;
+
+} // end dqt_barrier_decrement()
+
+
