Index: soft/giet_vm/giet_common/utils.c
===================================================================
--- soft/giet_vm/giet_common/utils.c	(revision 345)
+++ soft/giet_vm/giet_common/utils.c	(revision 351)
@@ -494,28 +494,29 @@
 // betwween two successive retry.
 ///////////////////////////////////////////////////////////////////////////////////
-inline void _get_lock(unsigned int * plock) 
-{
+inline void _get_lock(giet_lock_t* lock) 
+{
+    register unsigned int* plock = &(lock->value);
+
 #if NO_HARD_CC
 
-    register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF;
-
-    if (delay == 0) delay++;
+    register unsigned int delay  = (_get_proctime() ^ _get_procid() << 4) & 0xFF;
+    if (delay == 0) delay = 0x80;
 
     asm volatile (
             "_lock_llsc:             \n"
-            "ll   $2,    0(%0)       \n" /* $2 <= _ioc_lock current value */
-            "bnez $2,    _lock_delay \n" /* delay if _ioc_lock already taken */
-            "li   $3,    1           \n" /* $3 <= argument for sc */
-            "sc   $3,    0(%0)       \n" /* try to set _ioc_lock */
-            "bnez $3,    _lock_ok    \n" /* exit if atomic */
-            "_lock_delay:            \n"
-            "move $4,    %1          \n" /* $4 <= delay */
-            "_lock_loop:             \n"
-            "addi $4,    $4,    -1   \n" /* $4 <= $4 - 1 */
-            "bnez $4,    _lock_loop  \n" /* test end delay */
-            "nop                     \n"
-            "j           _lock_llsc  \n" /* retry */
-            "nop                     \n"
-            "_lock_ok:               \n"
+            "    ll   $2,    0(%0)       \n" /* $2 <= lock current value         */
+            "    bnez $2,    _lock_delay \n" /* delay if lock already taken      */
+            "    li   $3,    1           \n" /* $3 <= argument for sc            */
+            "    sc   $3,    0(%0)       \n" /* try to set lock                  */
+            "    bnez $3,    _lock_ok    \n" /* exit if atomic                   */
+            "    _lock_delay:            \n"
+            "    move $4,    %1          \n" /* $4 <= delay                      */
+            "    _lock_loop:             \n"
+            "    addi $4,    $4,    -1   \n" /* $4 <= $4 - 1                     */
+            "    bnez $4,    _lock_loop  \n" /* test end delay                   */
+            "    nop                     \n"
+            "    j           _lock_llsc  \n" /* retry                            */
+            "    nop                     \n"
+            "    _lock_ok:               \n"
             :
             :"r"(plock), "r"(delay)
@@ -525,12 +526,12 @@
     asm volatile (
             "_lock_llsc:                 \n"
-            "    lw   $2,    0(%0)       \n" /* dcache <= _ioc_lock current value    */
-            "    bnez $2,    _lock_llsc  \n" /* retry if lock already taken          */
+            "    lw   $2,    0(%0)       \n" /* $2 <= lock current value         */
+            "    bnez $2,    _lock_llsc  \n" /* retry if lock already taken      */
             "    nop                     \n"
-            "    ll   $2,    0(%0)       \n" /* ll_buffer <= _ioc_lock current value */
-            "    bnez $2,    _lock_llsc  \n" /* retry if _ioc_lock already taken     */
-            "    li   $3,    1           \n" /* $3 <= argument for sc                */
-            "    sc   $3,    0(%0)       \n" /* try to set _ioc_lock                 */
-            "    beqz $3,    _lock_llsc  \n" /* retry if sc failure                  */
+            "    ll   $2,    0(%0)       \n" /* ll_buffer <= lock current value  */
+            "    bnez $2,    _lock_llsc  \n" /* retry if lock already taken      */
+            "    li   $3,    1           \n" /* $3 <= argument for sc            */
+            "    sc   $3,    0(%0)       \n" /* try to set lock                  */
+            "    beqz $3,    _lock_llsc  \n" /* retry if sc failure              */
             "    nop                     \n"
             :
@@ -539,28 +540,4 @@
 #endif
 
-//  register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF;
-
-//  if (delay == 0) delay++;
-
-//  asm volatile (
-//          "_lock_llsc:             \n"
-//          "ll   $2,    0(%0)       \n" /* $2 <= _ioc_lock current value */
-//          "bnez $2,    _lock_delay \n" /* delay if _ioc_lock already taken */
-//          "li   $3,    1           \n" /* $3 <= argument for sc */
-//          "sc   $3,    0(%0)       \n" /* try to set _ioc_lock */
-//          "bnez $3,    _lock_ok    \n" /* exit if atomic */
-//          "_lock_delay:            \n"
-//          "move $4,    %1          \n" /* $4 <= delay */
-//          "_lock_loop:             \n"
-//          "addi $4,    $4,    -1   \n" /* $4 <= $4 - 1 */
-//          "bnez $4,    _lock_loop  \n" /* test end delay */
-//          "nop                     \n"
-//          "j           _lock_llsc  \n" /* retry */
-//          "nop                     \n"ache
-//          "_lock_ok:               \n"
-//          :
-//          :"r"(plock), "r"(delay)
-//          :"$2", "$3", "$4");
-
 }
 
@@ -568,9 +545,9 @@
 // Release a previouly taken lock.
 ///////////////////////////////////////////////////////////////////////////////////
-inline void _release_lock(unsigned int * plock) 
+inline void _release_lock(giet_lock_t* lock) 
 {
     asm volatile ( "sync\n" ::: "memory" ); 
     // sync is necessary because of the TSAR consistency model 
-    *plock = 0;
+    lock->value = 0;
 }
 
@@ -653,14 +630,17 @@
     char buf[11];
     unsigned int i;
-    unsigned int first;
+    unsigned int first = 0;
 
     buf[10] = 0;
 
-    for (i = 0; i < 10; i++) {
-        if ((val != 0) || (i == 0)) {
+    for (i = 0; i < 10; i++) 
+    {
+        if ((val != 0) || (i == 0)) 
+        {
             buf[9 - i] = DecTab[val % 10];
             first = 9 - i;
         }
-        else {
+        else 
+        {
             break;
         }
