Index: trunk/kernel/kern/thread.c
===================================================================
--- trunk/kernel/kern/thread.c	(revision 580)
+++ trunk/kernel/kern/thread.c	(revision 581)
@@ -190,5 +190,8 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot get TRDID\n", __FUNCTION__ );
+        printk("\n[ERROR] in %s : thread %x in process %x cannot get TRDID in cluster %x\n"
+        "    for thread %s in process %x / cycle %d\n",
+        __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,
+        local_cxy, thread_type_str(type), process->pid, (uint32_t)hal_get_cycles() );
         return EINVAL;
     }
@@ -710,8 +713,8 @@
 
     assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) ,
-        "illegal thread type" );
+    "illegal thread type" );
 
     assert( (core_lid < LOCAL_CLUSTER->cores_nr) ,
-            "illegal core_lid" );
+    "illegal core_lid" );
 
 #if DEBUG_THREAD_KERNEL_CREATE
@@ -725,5 +728,11 @@
     thread = thread_alloc();
 
-    if( thread == NULL ) return ENOMEM;
+    if( thread == NULL )
+    {
+        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 );
+        return ENOMEM;
+    }
 
     // initialize thread descriptor
@@ -738,4 +747,7 @@
     if( error ) // release allocated memory for thread descriptor
     {
+        printk("\n[ERROR] in %s : thread %x in process %x\n"
+        "   cannot initialize thread descriptor\n",
+        __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
         thread_release( thread );
         return ENOMEM;
@@ -744,9 +756,14 @@
     // allocate & initialize CPU context
 	error = hal_cpu_context_alloc( thread );
+
     if( error )
     {
+        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 );
         thread_release( thread );
         return EINVAL;
     }
+
     hal_cpu_context_init( thread );
 
@@ -1364,59 +1381,62 @@
 void thread_display_busylocks( xptr_t  thread_xp )
 {
-    if( DEBUG_BUSYLOCK )
-    {
-        xptr_t    iter_xp;
-
-        // get cluster and local pointer of target thread
-        cxy_t      thread_cxy = GET_CXY( thread_xp );
-        thread_t * thread_ptr = GET_PTR( thread_xp );
-
-        // get target thread TRDID and busylocks
-        trdid_t  trdid = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->trdid ));
-        uint32_t locks = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->busylocks ));
-
-        // get target thread process and PID;
-        process_t * process = hal_remote_lpt(XPTR( thread_cxy , &thread_ptr->process ));
-        pid_t       pid     = hal_remote_l32(XPTR( thread_cxy , &process->pid ));
-
-        // get extended pointer on root of busylocks
-        xptr_t    root_xp = XPTR( thread_cxy , &thread_ptr->busylocks_root );
-
-        // 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  txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
-
-        // get TXT0 lock 
-        remote_busylock_acquire( txt0_lock_xp );
-
-        // display header 
-        nolock_printk("\n***** thread %x in process %x : %d busylocks at cycle %d\n",
-        trdid, pid, locks, (uint32_t)hal_get_cycles() );
-
-        // scan the xlist of busylocks when required
-        if( locks )
+    // get cluster and local pointer of target thread
+    cxy_t      thread_cxy = GET_CXY( thread_xp );
+    thread_t * thread_ptr = GET_PTR( thread_xp );
+
+#if( DEBUG_BUSYLOCK )
+
+    xptr_t    iter_xp;
+
+    // get target thread TRDID and busylocks
+    trdid_t  trdid = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->trdid ));
+    uint32_t locks = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->busylocks ));
+
+    // get target thread process and PID;
+    process_t * process = hal_remote_lpt(XPTR( thread_cxy , &thread_ptr->process ));
+    pid_t       pid     = hal_remote_l32(XPTR( thread_cxy , &process->pid ));
+
+    // get extended pointer on root of busylocks
+    xptr_t    root_xp = XPTR( thread_cxy , &thread_ptr->busylocks_root );
+
+    // 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  txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
+
+    // get TXT0 lock 
+    remote_busylock_acquire( txt0_lock_xp );
+
+    // display header 
+    nolock_printk("\n***** thread %x in process %x : %d busylocks at cycle %d\n",
+    trdid, pid, locks, (uint32_t)hal_get_cycles() );
+
+    // scan the xlist of busylocks when required
+    if( locks )
+    {
+        XLIST_FOREACH( root_xp , iter_xp )
         {
-            XLIST_FOREACH( root_xp , iter_xp )
-            {
-                xptr_t       lock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
-                cxy_t        lock_cxy  = GET_CXY( lock_xp );
-                busylock_t * lock_ptr  = GET_PTR( lock_xp );
-                uint32_t     lock_type = hal_remote_l32(XPTR( lock_cxy , &lock_ptr->type ));
-                nolock_printk(" - %s in cluster %x\n", lock_type_str[lock_type] , lock_cxy );
-            }
+            xptr_t       lock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
+            cxy_t        lock_cxy  = GET_CXY( lock_xp );
+            busylock_t * lock_ptr  = GET_PTR( lock_xp );
+            uint32_t     lock_type = hal_remote_l32(XPTR( lock_cxy , &lock_ptr->type ));
+            nolock_printk(" - %s in cluster %x\n", lock_type_str[lock_type] , lock_cxy );
         }
-
-        // release TXT0 lock
-        remote_busylock_release( txt0_lock_xp );
-    }
-    else
-    {
-        // display a warning
-        printk("\n[WARNING] set the DEBUG_BUSYLOCK parmeter in kernel_config.h"
-        " to use the %s function\n", __FUNCTION__ );
-    }
+    }
+
+    // release TXT0 lock
+    remote_busylock_release( txt0_lock_xp );
+
+    return;
+
+#endif
+
+    // display a warning
+    printk("\n[WARNING] set the DEBUG_BUSYLOCK parmeter in kernel_config.h"
+    " to display busylocks for thread %x/%x\n", thread_cxy, thread_ptr );
+
 }  // end thread_display_busylock()
+
