Index: trunk/hal/tsar_mips32/core/hal_exception.c
===================================================================
--- trunk/hal/tsar_mips32/core/hal_exception.c	(revision 440)
+++ trunk/hal/tsar_mips32/core/hal_exception.c	(revision 457)
@@ -22,5 +22,5 @@
  */
 
-#include <hal_types.h>
+#include <hal_kernel_types.h>
 #include <hal_irqmask.h>
 #include <hal_special.h>
@@ -134,19 +134,30 @@
 	core_t   * core = this->core; 
 
-    // enable FPU  
+    // enable FPU (in core SR)  
 	hal_fpu_enable();
 
-    // save FPU context in current owner thread if required 
+    // save FPU register values in current owner thread if required 
 	if( core->fpu_owner != NULL )
     {
         if( core->fpu_owner != this )
 	    {
+            // save the FPU registers to current owner thread context
 		    hal_fpu_context_save( XPTR( local_cxy , core->fpu_owner ) );
+
+            // restore FPU registers from requesting thread context
+	        hal_fpu_context_restore( this->fpu_context );
+
+            // attach the FPU to the requesting thread
+	        core->fpu_owner = this;
         }
 	}
-
-    // attach the FPU to the requesting thread
-	hal_fpu_context_restore( this->fpu_context );
-	core->fpu_owner = this;
+    else
+    {
+        // restore FPU registers from requesting thread context
+	    hal_fpu_context_restore( this->fpu_context );
+
+        // attach the FPU to the requesting thread
+	    core->fpu_owner = this;
+    }
 
 	return EXCP_NON_FATAL;
@@ -206,6 +217,6 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_HAL_EXCEPTIONS < cycle )
-printk("\n[DBG] %s : thread %x enter / is_ins %d / %s / vaddr %x / cycle %d\n",
-__FUNCTION__, this, is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle );
+printk("\n[DBG] %s : thread %x in process %x enter / is_ins %d / %s / vaddr %x / cycle %d\n",
+__FUNCTION__, this->trdid, process->pid, is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle);
 #endif
 
@@ -235,6 +246,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_HAL_EXCEPTIONS < cycle )
-printk("\n[DBG] %s : thread %x exit / page-fault handled for vaddr = %x\n",
-__FUNCTION__ , this , bad_vaddr );
+printk("\n[DBG] %s : thread %x in process %x exit / page-fault handled for vaddr = %x\n",
+__FUNCTION__, this->trdid, process->pid, bad_vaddr );
 #endif
   
@@ -275,6 +286,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_HAL_EXCEPTIONS < cycle )
-printk("\n[DBG] %s : thread %x exit / copy-on-write handled for vaddr = %x\n",
-__FUNCTION__ , this , bad_vaddr );
+printk("\n[DBG] %s : thread %x in process %x exit / copy-on-write handled for vaddr = %x\n",
+__FUNCTION__, this->trdid, process->pid, bad_vaddr );
 #endif
 
@@ -300,6 +311,7 @@
         {
             assert( false , __FUNCTION__ ,
-            "thread %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n",
-            this, local_cxy, this->core->lid, excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
+            "thread %x in process %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n",
+            this->trdid, this->process->pid, local_cxy, this->core->lid,
+            excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
 
             return EXCP_KERNEL_PANIC;
@@ -398,6 +410,6 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_HAL_EXCEPTIONS < cycle )
-printk("\n[DBG] %s : thread %x enter / core[%x,%d] / pid %x / epc %x / xcode %x / cycle %d\n",
-__FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );
+printk("\n[DBG] %s : thread %x in process %x enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
+__FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle );
 #endif
 
@@ -458,6 +470,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_HAL_EXCEPTIONS < cycle )
-printk("\n[DBG] %s : thread %x exit / core[%x,%d] / pid %x / epc %x / xcode %x / cycle %d\n",
-__FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );
+printk("\n[DBG] %s : thread %x in process %x exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
+__FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle );
 #endif
 
