Index: trunk/kernel/kern/thread.c
===================================================================
--- trunk/kernel/kern/thread.c	(revision 583)
+++ trunk/kernel/kern/thread.c	(revision 593)
@@ -124,6 +124,6 @@
 // It updates the local DQDT.
 /////////////////////////////////////////////////////////////////////////////////////
-// @ thread       : pointer on thread descriptor
-// @ process      : pointer on process descriptor.
+// @ thread       : pointer on local thread descriptor
+// @ process      : pointer on local process descriptor.
 // @ type         : thread type.
 // @ func         : pointer on thread entry function.
@@ -148,9 +148,9 @@
 
 #if DEBUG_THREAD_INIT
-uint32_t cycle = (uint32_t)hal_get_cycles();
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
 if( DEBUG_THREAD_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x enter fot thread %x in process %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
- thread, process->pid , cycle );
+printk("\n[%s] thread[%x,%x] enter for thread %x in process %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, thread, process->pid , cycle );
 #endif
 
@@ -229,7 +229,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x exit for thread %x in process %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
-thread, process->pid , cycle );
+printk("\n[%s] thread[%x,%x] exit for thread %x in process %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );
 #endif
 
@@ -251,11 +250,12 @@
     vseg_t       * vseg;         // stack vseg
 
-    assert( (attr != NULL) , "pthread attributes must be defined" );
+assert( (attr != NULL) , "pthread attributes must be defined" );
 
 #if DEBUG_THREAD_USER_CREATE
-uint32_t cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
+uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : thread %x in process %x enter in cluster %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, pid , local_cxy , cycle );
+printk("\n[%s] thread[%x,%x] enter in cluster %x for process %x / cycle %d\n",
+__FUNCTION__, this->process->pid , this->trdid , local_cxy , pid , cycle );
 #endif
 
@@ -272,5 +272,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : process descriptor = %x for process %x in cluster %x\n",
+printk("\n[%s] process descriptor = %x for process %x in cluster %x\n",
 __FUNCTION__, process , pid , local_cxy );
 #endif
@@ -294,5 +294,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : core[%x,%d] selected\n",
+printk("\n[%s] core[%x,%d] selected\n",
 __FUNCTION__, local_cxy , core_lid );
 #endif
@@ -316,5 +316,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : stack vseg created / vpn_base %x / %d pages\n",
+printk("\n[%s] stack vseg created / vpn_base %x / %d pages\n",
 __FUNCTION__, vseg->vpn_base, vseg->vpn_size );
 #endif
@@ -332,5 +332,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : new thread descriptor %x allocated\n",
+printk("\n[%s] new thread descriptor %x allocated\n",
 __FUNCTION__, thread );
 #endif
@@ -355,5 +355,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : new thread descriptor initialised / trdid %x\n",
+printk("\n[%s] new thread descriptor initialised / trdid %x\n",
 __FUNCTION__, thread->trdid );
 #endif
@@ -387,5 +387,5 @@
 #if( DEBUG_THREAD_USER_CREATE & 1)
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : CPU & FPU contexts created\n",
+printk("\n[%s] CPU & FPU contexts created\n",
 __FUNCTION__, thread->trdid );
 vmm_display( process , true );
@@ -395,6 +395,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_CREATE < cycle )
-printk("\n[DBG] %s : thread %x in process %x exit / new_thread %x / core %d / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid , pid, thread->trdid, core_lid, cycle );
+printk("\n[%s] thread[%x,%x] exit / new_thread %x / core %d / cycle %d\n",
+__FUNCTION__, this->process->pid , this->trdid , thread->trdid, core_lid, cycle );
 #endif
 
@@ -430,8 +430,9 @@
 
 #if DEBUG_THREAD_USER_FORK
-uint32_t cycle = (uint32_t)hal_get_cycles();
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x enter / child_process %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_process->pid, cycle );
+printk("\n[%s] thread[%x,%x] enter / child_process %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, child_process->pid, cycle );
 #endif
 
@@ -487,7 +488,6 @@
 #if (DEBUG_THREAD_USER_FORK & 1)
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x / initialised thread %x in process %x\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
-child_ptr->trdid, child_process->pid );
+printk("\n[%s] thread[%x,%x] initialised thread %x in process %x\n",
+__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
 #endif
 
@@ -522,6 +522,6 @@
 #if (DEBUG_THREAD_USER_FORK & 1)
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x / created CPU & FPU contexts\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
+printk("\n[%s] thread[%x,%x] created CPU & FPU contexts for thread %x in process %x\n",
+__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
 #endif
 
@@ -542,6 +542,6 @@
 #if (DEBUG_THREAD_USER_FORK & 1)
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x / created stack vseg\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
+printk("\n[%s] thread[%x,%x] created stack vseg for thread %x in process %x\n",
+__FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid );
 #endif
 
@@ -591,7 +591,7 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x copied one PTE to child GPT : vpn %x / forks %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, vpn,
-hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) );
+printk("\n[%s] thread[%x,%x] copied one PTE to child GPT : vpn %x / forks %d\n",
+__FUNCTION__, this->process->pid, this->trdid, 
+vpn, hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) );
 #endif
 
@@ -607,6 +607,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_FORK < cycle )
-printk("\n[DBG] %s : thread %x in process %x exit / child_thread %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_ptr, cycle );
+printk("\n[%s] thread[%x,%x] exit / child_thread %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, child_ptr, cycle );
 #endif
 
@@ -626,6 +626,6 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_EXEC < cycle )
-printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
-__FUNCTION__, thread->trdid, process->pid, cycle );
+printk("\n[%s] thread[%x,%x] enter / cycle %d\n",
+__FUNCTION__, process->pid, thread->trdid, cycle );
 #endif
 
@@ -688,6 +688,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_USER_EXEC < cycle )
-printk("\n[DBG] %s : thread %x in process %x set CPU context & jump to user code / cycle %d\n",
-__FUNCTION__, thread->trdid, process->pid, cycle );
+printk("\n[%s] thread[%x,%x] set CPU context & jump to user code / cycle %d\n",
+__FUNCTION__, process->pid, thread->trdid, cycle );
 vmm_display( process , true );
 #endif
@@ -712,15 +712,17 @@
 	thread_t     * thread;       // pointer on new thread descriptor
 
-    assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
-    "illegal thread type" );
-
-    assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
-    "illegal core_lid" );
+    thread_t * this = CURRENT_THREAD; 
+
+assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
+"illegal thread type" );
+
+assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
+"illegal core_lid" );
 
 #if DEBUG_THREAD_KERNEL_CREATE
-uint32_t cycle = (uint32_t)hal_get_cycles();
+uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_KERNEL_CREATE < cycle )
-printk("\n[DBG] %s : thread %x enter / requested_type %s / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
+printk("\n[%s] thread[%x,%x] enter / requested_type %s / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, thread_type_str(type), cycle );
 #endif
 
@@ -732,5 +734,5 @@
         printk("\n[ERROR] in %s : thread %x in process %x\n"
         "   no memory for thread descriptor\n",
-        __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
+        __FUNCTION__, this->trdid, this->process->pid );
         return ENOMEM;
     }
@@ -749,5 +751,5 @@
         printk("\n[ERROR] in %s : thread %x in process %x\n"
         "   cannot initialize thread descriptor\n",
-        __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
+        __FUNCTION__, this->trdid, this->process->pid );
         thread_release( thread );
         return ENOMEM;
@@ -760,6 +762,6 @@
     {
         printk("\n[ERROR] in %s : thread %x in process %x\n"
-        "   cannot cannot create CPU context\n",
-        __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
+        "    cannot create CPU context\n",
+        __FUNCTION__, this->trdid, this->process->pid );
         thread_release( thread );
         return EINVAL;
@@ -774,6 +776,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_KERNEL_CREATE < cycle )
-printk("\n[DBG] %s : thread %x exit / new_thread %x / type %s / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );
+printk("\n[%s] thread[%x,%x] exit / new_thread %x / type %s / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, thread, thread_type_str(type), cycle );
 #endif
 
@@ -830,5 +832,5 @@
 thread_t * this  = CURRENT_THREAD;
 if( DEBUG_THREAD_DESTROY < cycle )
-printk("\n[DBG] %s : thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n",
+printk("\n[%s] thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
 #endif
@@ -862,5 +864,5 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_DESTROY < cycle )
-printk("\n[DBG] %s : thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n",
+printk("\n[%s] thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle );
 #endif
@@ -944,7 +946,8 @@
 uint32_t    cycle   = (uint32_t)hal_get_cycles();
 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) );
+thread_t  * this    = CURRENT_THREAD;
 if( DEBUG_THREAD_BLOCK < cycle )
-printk("\n[DBG] %s : thread %x in process %x blocked thread %x in process %x / cause %x\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
+printk("\n[%s] thread[%x,%x] blocked thread %x in process %x / cause %x\n",
+__FUNCTION__, this->process->pid, this->trdid,
 ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause );
 #endif
@@ -967,7 +970,8 @@
 uint32_t    cycle   = (uint32_t)hal_get_cycles();
 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) );
+thread_t  * this    = CURRENT_THREAD;
 if( DEBUG_THREAD_BLOCK < cycle )
-printk("\n[DBG] %s : thread %x in process %x unblocked thread %x in process %x / cause %x\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
+printk("\n[%s] thread[%x,%x] unblocked thread %x in process %x / cause %x\n",
+__FUNCTION__, this->process->pid, this->trdid,
 ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause );
 #endif
@@ -1016,5 +1020,5 @@
 uint32_t cycle  = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_DELETE < cycle )
-printk("\n[DBG] %s : killer[%x,%x] enters / target[%x,%x] / cycle %d\n",
+printk("\n[%s] killer[%x,%x] enters / target[%x,%x] / cycle %d\n",
 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,  
 target_ptr->process->pid, target_ptr->trdid, cycle );
@@ -1075,5 +1079,5 @@
 cycle  = (uint32_t)hal_get_cycles;
 if( DEBUG_THREAD_DELETE < cycle )
-printk("\n[DBG] %s : killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
+printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
 target_ptr->process->pid, target_ptr->trdid, cycle );
@@ -1098,5 +1102,5 @@
 cycle  = (uint32_t)hal_get_cycles;
 if( DEBUG_THREAD_DELETE < cycle )
-printk("\n[DBG] %s : killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n",
+printk("\n[%s] killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n",
 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
 target_ptr->process->pid, target_ptr->trdid, cycle );
@@ -1117,5 +1121,5 @@
 cycle  = (uint32_t)hal_get_cycles;
 if( DEBUG_THREAD_DELETE < cycle )
-printk("\n[DBG] %s : killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
+printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",
 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
 target_ptr->process->pid, target_ptr->trdid, cycle );
@@ -1135,5 +1139,5 @@
 cycle  = (uint32_t)hal_get_cycles;
 if( DEBUG_THREAD_DELETE < cycle )
-printk("\n[DBG] %s : killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n",
+printk("\n[%s] killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n",
 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid,
 target_ptr->process->pid, target_ptr->trdid, cycle );
@@ -1141,5 +1145,4 @@
 
     }
-
 }  // end thread_delete()
 
@@ -1162,5 +1165,5 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_IDLE < cycle )
-printk("\n[DBG] %s : idle thread on core[%x,%d] goes to sleep / cycle %d\n",
+printk("\n[%s] idle thread on core[%x,%d] goes to sleep / cycle %d\n",
 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle );
 }
@@ -1173,5 +1176,5 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_IDLE < cycle )
-printk("\n[DBG] %s : idle thread on core[%x,%d] wake up / cycle %d\n",
+printk("\n[%s] idle thread on core[%x,%d] wake up / cycle %d\n",
 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle );
 }
@@ -1237,5 +1240,5 @@
 thread_t * this = CURRENT_THREAD;
 if( DEBUG_THREAD_GET_XPTR < cycle )
-printk("\n[DBG] %s : thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",
+printk("\n[%s] thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",
 __FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
 #endif
@@ -1262,5 +1265,5 @@
 #if( DEBUG_THREAD_GET_XPTR & 1 )
 if( DEBUG_THREAD_GET_XPTR < cycle )
-printk("\n[DBG]  %s : scan processes in cluster %x :\n", __FUNCTION__, target_cxy );
+printk("\n[%s] scan processes in cluster %x :\n", __FUNCTION__, target_cxy );
 #endif
 
@@ -1295,5 +1298,5 @@
 #if( DEBUG_THREAD_GET_XPTR & 1 )
 if( DEBUG_THREAD_GET_XPTR < cycle )
-printk("\n[DBG] %s : pid %x not found in cluster %x\n",
+printk("\n[%s] pid %x not found in cluster %x\n",
 __FUNCTION__, pid, target_cxy );
 #endif
@@ -1310,5 +1313,5 @@
 #if( DEBUG_THREAD_GET_XPTR & 1 )
 if( DEBUG_THREAD_GET_XPTR < cycle )
-printk("\n[DBG] %s : thread %x not registered in process %x in cluster %x\n",
+printk("\n[%s] thread %x not registered in process %x in cluster %x\n",
 __FUNCTION__, trdid, pid, target_cxy );
 #endif
@@ -1319,5 +1322,5 @@
 cycle  = (uint32_t)hal_get_cycles();
 if( DEBUG_THREAD_GET_XPTR < cycle )
-printk("\n[DBG] %s : thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",
+printk("\n[%s] thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",
 __FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
 #endif
@@ -1347,7 +1350,7 @@
 
         // display error message on TXT0
-        nolock_printk("\n[PANIC] in %s / thread %x in process %x [%x] cannot yield : "
+        nolock_printk("\n[PANIC] in %s / thread[%x,%x] cannot yield : "
         "hold %d busylock(s) / cycle %d\n",
-        func_str, thread->trdid, thread->process->pid, thread,
+        func_str, thread->process->pid, thread->trdid,
         thread->busylocks, (uint32_t)hal_get_cycles() );
 
