Index: trunk/kernel/kern/cluster.c
===================================================================
--- trunk/kernel/kern/cluster.c	(revision 635)
+++ trunk/kernel/kern/cluster.c	(revision 637)
@@ -76,7 +76,7 @@
 
     // initialize the cluster_info[][] array
-    for (x = 0; x < CONFIG_MAX_CLUSTERS_X; x++) 
-    {
-        for (y = 0; y < CONFIG_MAX_CLUSTERS_Y;y++) 
+    for( x = 0 ; x < CONFIG_MAX_CLUSTERS_X ; x++ ) 
+    {
+        for( y = 0; y < CONFIG_MAX_CLUSTERS_Y ; y++ ) 
         {
             cluster->cluster_info[x][y] = info->cluster_info[x][y];
@@ -95,8 +95,49 @@
     }
 
-    // initialize number of cores
+    // initialize number of local cores
 	cluster->cores_nr  = info->cores_nr;
 
 }  // end cluster_info_init()
+
+//////////////////////////////////////
+void cluster_info_display( cxy_t cxy )
+{
+    uint32_t  x;
+    uint32_t  y;
+    uint32_t  ncores;
+
+    cluster_t * cluster = LOCAL_CLUSTER;
+
+    // get x_size & y_size from target cluster
+    uint32_t  x_size = hal_remote_l32( XPTR( cxy , &cluster->x_size ) );
+    uint32_t  y_size = hal_remote_l32( XPTR( cxy , &cluster->y_size ) );
+
+    // get pointers on TXT0 chdev
+    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
+    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
+    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
+
+    // get extended pointer on remote TXT0 lock
+    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
+
+    // get TXT0 lock 
+    remote_busylock_acquire( lock_xp );
+
+    nolock_printk("\n***** cluster_info in cluster %x / x_size %d / y_size %d\n",
+    cxy, x_size, y_size );
+  
+    for( x = 0 ; x < x_size ; x++ )
+    {
+        for( y = 0 ; y < y_size ; y++ )
+        {
+            ncores = (uint32_t)hal_remote_lb( XPTR( cxy , &cluster->cluster_info[x][y] ) );
+            nolock_printk(" - ncores[%d][%d] = %d\n", x, y, ncores );
+        }
+    }
+
+    // release TXT0 lock
+    remote_busylock_release( lock_xp );
+
+}  // end cluster_info_display()
 
 /////////////////////////////////////////////////////////
@@ -115,4 +156,8 @@
 printk("\n[%s] thread[%x,%x] enters for cluster %x / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, local_cxy , cycle );
+#endif
+
+#if (DEBUG_CLUSTER_INIT & 1)
+cluster_info_display( local_cxy );
 #endif
 
@@ -243,21 +288,6 @@
 }
 
-////////////////////////////////////////
-bool_t cluster_is_undefined( cxy_t cxy )
-{
-    uint32_t  x_size = LOCAL_CLUSTER->x_size;
-    uint32_t  y_size = LOCAL_CLUSTER->y_size;
-
-    uint32_t  x      = HAL_X_FROM_CXY( cxy );
-    uint32_t  y      = HAL_Y_FROM_CXY( cxy );
-
-    if( x >= x_size ) return true;
-    if( y >= y_size ) return true;
-
-    return false;
-}
-
-//////////////////////////////////////
-bool_t cluster_is_active ( cxy_t cxy )
+/////////////////////////////////////////////
+inline bool_t cluster_is_active ( cxy_t cxy )
 {
     uint32_t x = HAL_X_FROM_CXY( cxy );
@@ -271,19 +301,21 @@
 ////////////////////////////////////////////////////////////////////////////////////
 
-///////////////////////////////////////
-lid_t cluster_select_local_core( void )
-{
-    uint32_t      min = 1000;
+/////////////////////////////////////////////
+lid_t cluster_select_local_core( cxy_t  cxy )
+{
+    uint32_t      min = 1000000;
     lid_t         sel = 0;
     uint32_t      nthreads;
     lid_t         lid;
     scheduler_t * sched;
-
-    cluster_t * cluster = LOCAL_CLUSTER;
-
-    for( lid = 0 ; lid < cluster->cores_nr ; lid++ )
-    {
-        sched    = &cluster->core_tbl[lid].scheduler;
-        nthreads = sched->u_threads_nr + sched->k_threads_nr;
+    cluster_t   * cluster = LOCAL_CLUSTER;
+    uint32_t      ncores = hal_remote_l32( XPTR( cxy , &cluster->cores_nr ) );
+
+    for( lid = 0 ; lid < ncores ; lid++ )
+    {
+        sched  = &cluster->core_tbl[lid].scheduler;
+
+        nthreads = hal_remote_l32( XPTR( cxy , &sched->u_threads_nr ) ) +
+                   hal_remote_l32( XPTR( cxy , &sched->k_threads_nr ) );
 
         if( nthreads < min )
@@ -700,5 +732,5 @@
     uint32_t      pref_nr;       // number of owned processes in cluster cxy
 
-assert( (cluster_is_undefined( cxy ) == false), "illegal cluster index" );
+assert( (cluster_is_active( cxy ) ), "illegal cluster index" );
 
     // get extended pointer on root and lock for local process list in cluster
