Index: /soft/giet_vm/dhrystone/dhry.h
===================================================================
--- /soft/giet_vm/dhrystone/dhry.h	(revision 270)
+++ /soft/giet_vm/dhrystone/dhry.h	(revision 271)
@@ -363,4 +363,5 @@
 #include <string.h>
 #include <malloc.h>
+#include <stdlib.h>
 
 typedef int     One_Thirty;
Index: /soft/giet_vm/giet_drivers/xcu_driver.c
===================================================================
--- /soft/giet_vm/giet_drivers/xcu_driver.c	(revision 270)
+++ /soft/giet_vm/giet_drivers/xcu_driver.c	(revision 271)
@@ -170,5 +170,5 @@
 ////////////////////////////////////////////////////////////////////////////////
 unsigned int _xcu_timer_start( unsigned int cluster_xy,
-                               unsigned int proc_id,
+                               unsigned int pti_index,
                                unsigned int period )
 {
@@ -178,10 +178,9 @@
     if (x >= X_SIZE)             return 1; 
     if (y >= Y_SIZE)             return 1; 
-    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
-    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
+    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
     return 0;
 #else
@@ -200,17 +199,16 @@
 //////////////////////////////////////////////////////////////////////////////
 unsigned int _xcu_timer_stop( unsigned int cluster_xy, 
-                              unsigned int proc_id) 
-{
-    // parameters checking 
-    unsigned int x = cluster_xy >> Y_WIDTH;
-    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
-    if (x >= X_SIZE)             return 1; 
-    if (y >= Y_SIZE)             return 1; 
-    if (proc_id >= NB_PROCS_MAX) return 1; 
+                              unsigned int pti_index) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
 
 #if USE_XICU
     unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
                                  (cluster_xy * (unsigned int)&vseg_cluster_increment));
-    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
+    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
     return 0;
 #else
@@ -231,19 +229,18 @@
 //////////////////////////////////////////////////////////////////////////////
 unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy, 
-                                   unsigned int proc_id ) 
-{
-    // parameters checking 
-    unsigned int x = cluster_xy >> Y_WIDTH;
-    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
-    if (x >= X_SIZE)             return 1; 
-    if (y >= Y_SIZE)             return 1; 
-    if (proc_id >= NB_PROCS_MAX) return 1; 
-
-#if USE_XICU
-    unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
-                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, proc_id)];
-    bloup++; // to avoid a warning 
+                                   unsigned int pti_index ) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+
+#if USE_XICU
+    volatile unsigned int * xcu_address =
+        (unsigned int *) ((unsigned int)&seg_xcu_base +
+        (cluster_xy * (unsigned int)&vseg_cluster_increment));
+
+    xcu_address[XICU_REG(XICU_PTI_ACK, pti_index)];
     return 0;
 #else
@@ -265,12 +262,11 @@
 /////////////////////////////////////////////////////////////////////////////
 unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy, 
-                                   unsigned int proc_id ) 
-{
-    // parameters checking 
-    unsigned int x = cluster_xy >> Y_WIDTH;
-    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
-    if (x >= X_SIZE)             return 1; 
-    if (y >= Y_SIZE)             return 1; 
-    if (proc_id >= NB_PROCS_MAX) return 1; 
+                                   unsigned int pti_index ) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
 
 #if USE_XICU
@@ -278,10 +274,10 @@
                                  (cluster_xy * (unsigned int)&vseg_cluster_increment));
 
-    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, proc_id)];
+    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, pti_index)];
 
     // we write 0 first because if the timer is currently running, 
     // the corresponding timer counter is not reset
-    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
-    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
+    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
+    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
     return 0;
 #else
Index: /soft/giet_vm/giet_kernel/ctx_handler.c
===================================================================
--- /soft/giet_vm/giet_kernel/ctx_handler.c	(revision 270)
+++ /soft/giet_vm/giet_kernel/ctx_handler.c	(revision 271)
@@ -119,7 +119,7 @@
         // reset timer counter
 #if USE_XICU
-        _xcu_timer_reset_cpt(cluster_id, local_id);
+        _xcu_timer_reset_cpt(cluster_id, NB_PROCS_MAX + local_id);
 #else
-        _timer_reset_cpt(cluster_id, local_id); 
+        _timer_reset_cpt(cluster_id, NB_PROCS_MAX + local_id); 
 #endif
 
Index: /soft/giet_vm/giet_kernel/kernel_init.c
===================================================================
--- /soft/giet_vm/giet_kernel/kernel_init.c	(revision 270)
+++ /soft/giet_vm/giet_kernel/kernel_init.c	(revision 271)
@@ -290,10 +290,24 @@
         }
 
+        // the ISR_SWITCH irq index must be NB_PROCS_MAX + local_pid because
+        // the first NB_PROCS_MAX irqs are used by the WAKEUP ones
+        if (isr_switch_index != (NB_PROCS_MAX + local_pid))
+        {
+            _tty_get_lock( 0 );
+            _puts("\n[GIET ERROR] ISR_SWITCH wrong index for processor ");
+            _putx(global_pid);
+            _puts("\n. It should be NB_PROCS_MAX + local_pid =");
+            _putd(NB_PROCS_MAX + local_pid);
+            _puts("\n");
+            _tty_release_lock( 0 );
+            _exit();
+        }
+
         // start system timer
         unsigned int ko;
 #if USE_XICU
-        ko = _xcu_timer_start( cluster_xy, local_pid, GIET_TICK_VALUE ); 
+        ko = _xcu_timer_start( cluster_xy, isr_switch_index, GIET_TICK_VALUE ); 
 #else
-        ko = _timer_start( cluster_xy, local_pid, GIET_TICK_VALUE ); 
+        ko = _timer_start( cluster_xy, isr_switch_index, GIET_TICK_VALUE ); 
 #endif
         if ( ko )
Index: /soft/giet_vm/giet_libs/srl.h
===================================================================
--- /soft/giet_vm/giet_libs/srl.h	(revision 270)
+++ /soft/giet_vm/giet_libs/srl.h	(revision 271)
@@ -10,5 +10,5 @@
 #include "mapping_info.h"
 #include "stdio.h"
-#include "utils.h"
+#include "stdlib.h"
 
 #include "libsrl/srl_public_types.h"
Index: /soft/giet_vm/giet_libs/stdio.c
===================================================================
--- /soft/giet_vm/giet_libs/stdio.c	(revision 270)
+++ /soft/giet_vm/giet_libs/stdio.c	(revision 271)
@@ -13,5 +13,4 @@
 #include <stdio.h>
 #include <giet_config.h>
-
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -823,34 +822,4 @@
     }
 }
-///////////////////////////////////////////////////////////////////////////////////
-// memcpy()
-///////////////////////////////////////////////////////////////////////////////////
-inline void* memcpy( void*        dest, 
-                     const void*  source,
-                     unsigned int size ) 
-{
-    unsigned int*       dst = dest;
-    const unsigned int* src = source;
-
-    // word-by-word copy
-    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3)) 
-    {
-        while (size > 3) 
-        {
-            *dst++ = *src++;
-            size -= 4;
-        }
-    }
-
-    unsigned char * cdst = (unsigned char *) dst;
-    unsigned char * csrc = (unsigned char *) src;
-
-    /* byte-by-byte copy */
-    while (size--) 
-    {
-        *cdst++ = *csrc++;
-    }
-    return dest;
-}
 
 // Local Variables:
Index: /soft/giet_vm/giet_libs/stdlib.c
===================================================================
--- /soft/giet_vm/giet_libs/stdlib.c	(revision 270)
+++ /soft/giet_vm/giet_libs/stdlib.c	(revision 271)
@@ -5,4 +5,6 @@
 // Copyright (c) UPMC-LIP6
 ///////////////////////////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
 
 ///////////////////////////////////////////////////////////////////////////////////
@@ -31,4 +33,39 @@
 }
         
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+void * memcpy(void *_dst, const void * _src, unsigned int size) {
+    unsigned int * dst = _dst;
+    const unsigned int * src = _src;
+    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3) )
+        while (size > 3) {
+            *dst++ = *src++;
+            size -= 4;
+        }
+
+    unsigned char *cdst = (unsigned char*)dst;
+    unsigned char *csrc = (unsigned char*)src;
+
+    while (size--) {
+        *cdst++ = *csrc++;
+    }
+    return _dst;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+inline void * memset(void * dst, int s, unsigned int count) {
+    char * a = (char *) dst;
+    while (count--){
+        *a++ = (char)s;
+    }
+    return dst;
+}
+
 // Local Variables:
 // tab-width: 4
Index: /soft/giet_vm/giet_libs/stdlib.h
===================================================================
--- /soft/giet_vm/giet_libs/stdlib.h	(revision 270)
+++ /soft/giet_vm/giet_libs/stdlib.h	(revision 271)
@@ -10,4 +10,16 @@
 
 int atoi (char * str);
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+void * memcpy(void *_dst, const void * _src, unsigned int size);
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+inline void * memset(void * dst, int s, unsigned int count);
 #endif
 
Index: /soft/giet_vm/mappings/4c_1p_iob_sort.xml
===================================================================
--- /soft/giet_vm/mappings/4c_1p_iob_sort.xml	(revision 270)
+++ /soft/giet_vm/mappings/4c_1p_iob_sort.xml	(revision 271)
@@ -281,23 +281,31 @@
             <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
                 <vobj name = "sort_stack0" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap0"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap1"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack4" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack5" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap2"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack6" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack7" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap3"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
 
-            <task name = "sort_0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
         </vspace>
     </vspaceset>
Index: /soft/giet_vm/mappings/4c_1p_sort.xml
===================================================================
--- /soft/giet_vm/mappings/4c_1p_sort.xml	(revision 270)
+++ /soft/giet_vm/mappings/4c_1p_sort.xml	(revision 271)
@@ -59,24 +59,24 @@
 
         <cluster x = "0" y = "1" >
+            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x0100000000" length = "0x0001000000" />
+            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x01B0000000" length = "0x0000002000" />
+            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x01B1000000" length = "0x0000008000" />
+            <pseg name = "PSEG_MMC"  type = "PERI" base = "0x01B8000000" length = "0x0000001000" />
+
+            <proc index = "0" >
+                <irq type = "SOFT" icuid = "0" isr = "ISR_WAKUP" />
+                <irq type = "TIME" icuid = "1" isr = "ISR_SWITCH" />
+            </proc>
+
+            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "1" />
+            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "1" />
+            <periph type = "MMC"  psegname = "PSEG_MMC"  channels = "1" />
+        </cluster>
+
+        <cluster x = "1" y = "0" >
             <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x1000000000" length = "0x0001000000" />
             <pseg name = "PSEG_XCU"  type = "PERI" base = "0x10B0000000" length = "0x0000002000" />
             <pseg name = "PSEG_DMA"  type = "PERI" base = "0x10B1000000" length = "0x0000008000" />
             <pseg name = "PSEG_MMC"  type = "PERI" base = "0x10B8000000" length = "0x0000001000" />
-
-            <proc index = "0" >
-                <irq type = "SOFT" icuid = "0" isr = "ISR_WAKUP" />
-                <irq type = "TIME" icuid = "1" isr = "ISR_SWITCH" />
-            </proc>
-
-            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "1" />
-            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "1" />
-            <periph type = "MMC"  psegname = "PSEG_MMC"  channels = "1" />
-        </cluster>
-
-        <cluster x = "1" y = "0" >
-            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x0100000000" length = "0x0001000000" />
-            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x01B0000000" length = "0x0000002000" />
-            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x01B1000000" length = "0x0000008000" />
-            <pseg name = "PSEG_MMC"  type = "PERI" base = "0x01B8000000" length = "0x0000001000" />
 
             <proc index = "0" >
@@ -255,23 +255,31 @@
             <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
                 <vobj name = "sort_stack0" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap0"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap1"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack4" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack5" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap2"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack6" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack7" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap3"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
 
-            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_1" trdid = "1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_2" trdid = "2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_3" trdid = "3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
         </vspace>
     </vspaceset>
Index: /soft/giet_vm/mappings/4c_1p_sort_chiplet.xml
===================================================================
--- /soft/giet_vm/mappings/4c_1p_sort_chiplet.xml	(revision 270)
+++ /soft/giet_vm/mappings/4c_1p_sort_chiplet.xml	(revision 271)
@@ -32,5 +32,5 @@
                 <irq type = "SOFT" icuid = "0"  isr = "ISR_WAKUP" /> 
                 <irq type = "TIME" icuid = "1"  isr = "ISR_SWITCH" /> 
-                <irq type = "HARD" icuid = "2"  isr = "ISR_IOC" /> 
+                <irq type = "HARD" icuid = "31" isr = "ISR_IOC" /> 
             </proc> 
 
@@ -208,23 +208,31 @@
             <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
                 <vobj name = "sort_stack0" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap0"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack1" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap1"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack2" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack4" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack5" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap2"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
             <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
-                <vobj name = "sort_stack3" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack6" type	 = "BUFFER" length = "0x00010000" /> 
+                <vobj name = "sort_stack7" type	 = "BUFFER" length = "0x00010000" /> 
                 <vobj name = "sort_heap3"  type	 = "BUFFER" length = "0x00010000" /> 
             </vseg>
 
-            <task name = "sort_0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
-            <task name = "sort_3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
+            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
+            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
+            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
+            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
         </vspace>
     </vspaceset>
Index: ft/giet_vm/mappings/4c_2p_40_sort.xml
===================================================================
--- /soft/giet_vm/mappings/4c_2p_40_sort.xml	(revision 270)
+++ 	(revision )
@@ -1,264 +1,0 @@
-<?xml version="1.0"?>
-
-<mapping_info signature    = "0xdeadbeef" 
-              name         = "4c_1p_40_sort" 
-              cluster_x    = "2" 
-              cluster_y    = "2" 
-              vspaces      = "1"
-              increment    = "0x0010000" >
-
-*** This first section describes an instance of the "tsar_generic_xbar" architecture
-*** with 4 clusters, 2 processor per cluster and 40 bits physical address.
-
-    <clusterset>
-
-        <cluster index = "0" >
-            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x0000000000" length = "0x0010000000" />
-            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x00B0000000" length = "0x0000002000" />
-            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x00B1000000" length = "0x0000008000" />
-
-*** Boot ROM and non replicated peripherals
-
-            <pseg name = "PSEG_FBF"  type = "PERI" base = "0x00B2000000" length = "0x0000004000" /> 
-            <pseg name = "PSEG_IOC"  type = "PERI" base = "0x00B3000000" length = "0x0000001000" /> 
-            <pseg name = "PSEG_TTY"  type = "PERI" base = "0x00B4000000" length = "0x0000001000" /> 
-            <pseg name = "PSEG_NIC"  type = "PERI" base = "0x00B5000000" length = "0x0000021000" />
-            <pseg name = "PSEG_CMA"  type = "PERI" base = "0x00B6000000" length = "0x0000004000" />
-            <pseg name = "PSEG_IOB"  type = "PERI" base = "0x00BE000000" length = "0x0000100000" />
-            <pseg name = "PSEG_ROM"  type = "ROM"  base = "0x00BFC00000" length = "0x0000100000" />
-
-            <proc index  = "0" >
-                <irq type = "HARD" icuid = "0"  isr = "ISR_SWITCH" /> 
-                <irq type = "HARD" icuid = "8"  isr = "ISR_DMA" channel = "0" /> 
-                <irq type = "HARD" icuid = "16" isr = "ISR_TTY" channel = "0" /> 
-                <irq type = "HARD" icuid = "17" isr = "ISR_TTY" channel = "1" /> 
-                <irq type = "HARD" icuid = "18" isr = "ISR_TTY" channel = "2" /> 
-                <irq type = "HARD" icuid = "19" isr = "ISR_TTY" channel = "3" /> 
-                <irq type = "HARD" icuid = "20" isr = "ISR_TTY" channel = "4" /> 
-                <irq type = "HARD" icuid = "21" isr = "ISR_TTY" channel = "5" /> 
-                <irq type = "HARD" icuid = "22" isr = "ISR_TTY" channel = "6" /> 
-                <irq type = "HARD" icuid = "23" isr = "ISR_TTY" channel = "7" /> 
-                <irq type = "HARD" icuid = "24" isr = "ISR_TTY" channel = "8" /> 
-                <irq type = "HARD" icuid = "25" isr = "ISR_TTY" channel = "9" />
-                <irq type = "HARD" icuid = "26" isr = "ISR_TTY" channel = "10" /> 
-                <irq type = "HARD" icuid = "27" isr = "ISR_TTY" channel = "11" /> 
-                <irq type = "HARD" icuid = "28" isr = "ISR_TTY" channel = "12" /> 
-                <irq type = "HARD" icuid = "29" isr = "ISR_TTY" channel = "13" /> 
-                <irq type = "HARD" icuid = "30" isr = "ISR_TTY" channel = "14" /> 
-                <irq type = "HARD" icuid = "31" isr = "ISR_IOC" channel = "0" /> 
-            </proc> 
-            <proc index = "1" >
-                <irq type = "HARD" icuid = "1"  isr = "ISR_SWITCH" />
-            </proc>
-
-            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "4" /> 
-            <periph type = "CMA"  psegname = "PSEG_CMA"  channels = "4" /> 
-            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "1" />
-            <periph type = "IOC"  psegname = "PSEG_IOC"  channels = "1" /> 
-            <periph type = "TTY"  psegname = "PSEG_TTY"  channels = "8" /> 
-            <periph type = "NIC"  psegname = "PSEG_NIC"  channels = "2" />
-            <periph type = "FBF"  psegname = "PSEG_FBF" />
-        </cluster>
-
-        <cluster index = "1" >
-            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x4000000000" length = "0x0010000000" />
-            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x40B0000000" length = "0x0000002000" />
-            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x40B1000000" length = "0x0000008000" />
-
-            <proc index = "0" >
-                <irq type = "HARD" icuid = "0"  isr = "ISR_SWITCH" />
-                <irq type = "HARD" icuid = "8"  isr = "ISR_DMA" channel = "0" />
-            </proc>
-            <proc index = "1" >
-                <irq type = "HARD" icuid = "1"  isr = "ISR_SWITCH" />
-            </proc>
-
-            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "4" />
-            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "2" />
-        </cluster>
-
-        <cluster index = "2" >
-            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x8000000000" length = "0x0010000000" />
-            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x80B0000000" length = "0x0000002000" />
-            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x80B1000000" length = "0x0000008000" />
-
-            <proc index = "0" >
-                <irq type = "HARD" icuid = "0" isr = "ISR_SWITCH" />
-                <irq type = "HARD" icuid = "8" isr = "ISR_DMA" channel = "0" />
-            </proc>
-            <proc index = "1" >
-                <irq type = "HARD" icuid = "1"  isr = "ISR_SWITCH" />
-            </proc>
-
-            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "4" />
-            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "2" />
-        </cluster>
-
-        <cluster index = "3" >
-            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0xC000000000" length = "0x0010000000" />
-            <pseg name = "PSEG_XCU"  type = "PERI" base = "0xC0B0000000" length = "0x0000002000" />
-            <pseg name = "PSEG_DMA"  type = "PERI" base = "0xC0B1000000" length = "0x0000008000" />
-
-            <proc index = "0" >
-                <irq type = "HARD" icuid = "0" isr = "ISR_SWITCH" />
-                <irq type = "HARD" icuid = "8" isr = "ISR_DMA" channel = "0" />
-            </proc>
-            <proc index = "1" >
-                <irq type = "HARD" icuid = "1"  isr = "ISR_SWITCH" />
-            </proc>
-
-            <periph  type = "DMA" psegname = "PSEG_DMA"  channels = "4" />
-            <periph  type = "XCU" psegname = "PSEG_XCU"  channels = "2" />
-        </cluster>
-    </clusterset>
-
-    <globalset> 
-
-*** segments used by the boot code / A[31:28] = 0xB / Identity mapping
-
-        <vseg name = "seg_boot_code"      vbase = "0xBFC00000" mode = "CXW_" clusterid = "0" psegname = "PSEG_ROM" ident = "1" >
-            <vobj name = "boot_code"      type = "ELF" length = "0x00008000" binpath	= "build/boot/boot.elf" />
-        </vseg>
-        <vseg name = "seg_boot_data"      vbase = "0x00000000" mode = "C_W_" clusterid = "0" psegname = "PSEG_RAM" ident = "1" >
-            <vobj name = "boot_data"      type = "ELF" length = "0x00001000" binpath	= "build/boot/boot.elf" />
-        </vseg>
-        <vseg name = "seg_boot_stack"     vbase = "0x00001000" mode = "C_W_" clusterid = "0" psegname = "PSEG_RAM" ident = "1" >
-            <vobj name = "boot_stack"     type = "BUFFER" length = "0x00003000" />
-        </vseg>
-        <vseg name = "seg_boot_mapping"   vbase = "0x00004000" mode = "C_W_" clusterid = "0" psegname = "PSEG_RAM" ident = "1" >
-            <vobj name = "boot_mapping"   type = "BLOB" length  = "0x00004000" binpath	= "map.bin" />
-        </vseg>
-
-*** Non replicated peripherals / A[31:28] = 0xB / Identity mapping
-
-        <vseg name = "seg_fbf"            vbase = "0xB2000000" mode = "C_W_" clusterid = "0" psegname = "PSEG_FBF" ident = "1" >
-            <vobj name = "fbf"            type = "PERI" length  = "0x00004000" /> 
-        </vseg>
-        <vseg name = "seg_ioc"            vbase = "0xB3000000" mode = "__W_" clusterid = "0" psegname = "PSEG_IOC" ident = "1" >
-            <vobj name = "ioc"            type = "PERI" length  = "0x00001000" /> 
-        </vseg>
-        <vseg name = "seg_tty"            vbase = "0xB4000000" mode = "__W_" clusterid = "0" psegname = "PSEG_TTY" ident = "1" >
-   			<vobj name = "tty"            type = "PERI" length  = "0x00001000" />
-        </vseg>
-        <vseg name = "seg_nic"            vbase = "0xB5000000" mode = "__W_" clusterid = "0" psegname = "PSEG_NIC" ident = "1" >
-            <vobj name = "nic"            type = "PERI" length  = "0x00021000" /> 
-        </vseg>
-
-*** segments used by the kernel / A[31:28] = 0x8 
-  
-        <vseg name = "seg_kernel_code"    vbase = "0x80000000" mode = "CX__" clusterid = "0" psegname = "PSEG_RAM" > 
-            <vobj name = "kernel_code"    type = "ELF" length = "0x00010000" binpath = "build/sys/sys.elf" />
-        </vseg>
-        <vseg name = "seg_kernel_data"    vbase = "0x80020000" mode = "C_W_" clusterid = "0" psegname = "PSEG_RAM" > 
-            <vobj name = "kernel_data"    type = "ELF" length = "0x00040000" binpath = "build/sys/sys.elf" />
-		</vseg>
-        <vseg name = "seg_kernel_uncdata" vbase = "0x80080000" mode = "__W_" clusterid = "0" psegname = "PSEG_RAM" > 
-            <vobj name = "kernel_uncdata" type = "ELF" length = "0x00010000" binpath = "build/sys/sys.elf" />
-        </vseg>
-        <vseg name = "seg_kernel_init"    vbase = "0x80090000" mode = "CX__" clusterid = "0" psegname = "PSEG_RAM" > 
-            <vobj name	= "kernel_init"   type = "ELF" length = "0x00010000" binpath	= "build/sys/sys.elf" />
-        </vseg>
-
-*** Replicated ICUS / A[31:28] = 0xE / Increment = 0x10000             
-
-        <vseg name = "seg_icu_0"          vbase = "0xE0000000" mode = "__W_" clusterid = "0" psegname = "PSEG_XCU"  > 
-            <vobj name = "icu_0"          type = "PERI" length  = "0x00001000" /> 
-        </vseg>
-        <vseg name = "seg_icu_1"          vbase = "0xE0010000" mode = "__W_" clusterid = "1" psegname = "PSEG_XCU"  > 
-            <vobj name = "icu_1"          type = "PERI" length  = "0x00001000" /> 
-        </vseg>
-        <vseg name = "seg_icu_2"          vbase = "0xE0020000" mode = "__W_" clusterid = "2" psegname = "PSEG_XCU"  > 
-            <vobj name = "icu_2"          type = "PERI" length  = "0x00001000" /> 
-        </vseg>
-        <vseg name = "seg_icu_3"          vbase = "0xE0030000" mode = "__W_" clusterid = "3" psegname = "PSEG_XCU"  > 
-            <vobj name = "icu_3"          type = "PERI" length  = "0x00001000" /> 
-        </vseg>
-
-*** Replicated DMAs / A[31:28] = 0xD / Increment = 0x10000
-
-        <vseg name = "seg_dma_0"          vbase = "0xD0000000" mode = "__W_" clusterid = "0" psegname = "PSEG_DMA" >
-            <vobj name = "dma_0"          type = "PERI" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_dma_1"          vbase = "0xD0010000" mode = "__W_" clusterid = "1" psegname = "PSEG_DMA" >
-            <vobj name = "dma_1"          type = "PERI" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_dma_2"          vbase = "0xD0020000" mode = "__W_" clusterid = "2" psegname = "PSEG_DMA" >
-            <vobj name = "dma_2"          type = "PERI" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_dma_3"          vbase = "0xD0030000" mode = "__W_" clusterid = "3" psegname = "PSEG_DMA" >
-            <vobj name = "dma_3"          type = "PERI" length  = "0x00008000" />
-        </vseg>
-
-*** Replicated schedulers / A[31:28] = 0xF / Increment = 0x10000
-
-        <vseg name = "seg_sched_0"        vbase = "0xF0000000" mode = "C_W_" clusterid = "0" psegname = "PSEG_RAM" >
-            <vobj name = "sched_0"        type = "SCHED" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_sched_1"        vbase = "0xF0010000" mode = "C_W_" clusterid = "1" psegname = "PSEG_RAM" >
-            <vobj name = "sched_1"        type = "SCHED" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_sched_2"        vbase = "0xF0020000" mode = "C_W_" clusterid = "2" psegname = "PSEG_RAM" >
-            <vobj name = "sched_2"        type = "SCHED" length  = "0x00008000" />
-        </vseg>
-        <vseg name = "seg_sched_3"        vbase = "0xF0030000" mode = "C_W_" clusterid = "3" psegname = "PSEG_RAM" >
-            <vobj name = "sched_3"        type = "SCHED" length  = "0x00008000" />
-        </vseg>
-***
-    </globalset> 
-
-    <vspaceset>
-        <vspace name = "sort" startname = "sort_data" > 
-            <vseg name = "seg_data"        vbase = "0x00800000" mode = "__WU" clusterid = "0" psegname = "PSEG_RAM" >
-                <vobj name = "sort_data"   type	= "ELF" length = "0x00010000" binpath = "build/sort/sort.elf" />
-            </vseg>
-            <vseg name = "seg_code"        vbase = "0x00400000" mode = "CX_U" clusterid = "0" psegname = "PSEG_RAM" > 
-                <vobj name = "sort_code"   type	= "ELF" length = "0x00010000" binpath = "build/sort/sort.elf" /> 
-            </vseg>
-            <vseg name = "seg_ptab"        vbase = "0x00300000" mode = "C___" clusterid = "0" psegname = "PSEG_RAM" > 
-                <vobj name = "ptab"        type	= "PTAB" length  = "0x00012000" align   = "13" />
-            </vseg>
-            <vseg name = "seg_stack_0"  vbase = "0x00010000" mode = "C_WU" clusterid = "0" psegname = "PSEG_RAM" >
-                <vobj name = "stack_0"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_0"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_1"  vbase = "0x00020000" mode = "C_WU" clusterid = "0" psegname = "PSEG_RAM" >
-                <vobj name = "stack_1"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_1"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_2"  vbase = "0x00030000" mode = "C_WU" clusterid = "1" psegname = "PSEG_RAM" >
-                <vobj name = "stack_2"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_2"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_3"  vbase = "0x00040000" mode = "C_WU" clusterid = "1" psegname = "PSEG_RAM" >
-                <vobj name = "stack_3"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_3"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_4"  vbase = "0x00050000" mode = "C_WU" clusterid = "2" psegname = "PSEG_RAM" >
-                <vobj name = "stack_4"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_4"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_5"  vbase = "0x00060000" mode = "C_WU" clusterid = "2" psegname = "PSEG_RAM" >
-                <vobj name = "stack_5"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_5"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_6"  vbase = "0x00070000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
-                <vobj name = "stack_6"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_6"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-            <vseg name = "seg_stack_7"  vbase = "0x00080000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
-                <vobj name = "stack_7"  type	= "BUFFER" length = "0x00008000" /> 
-                <vobj name = "heap_7"   type	= "BUFFER" length = "0x00008000" /> 
-            </vseg>
-
-            <task name = "task0" clusterid = "0" proclocid = "0" stackname = "stack_0" heapname = "heap_0" startid = "0" usetty = "1" />
-            <task name = "task1" clusterid = "0" proclocid = "1" stackname = "stack_1" heapname = "heap_1" startid = "0" />
-            <task name = "task2" clusterid = "1" proclocid = "0" stackname = "stack_2" heapname = "heap_2" startid = "0" />
-            <task name = "task3" clusterid = "1" proclocid = "1" stackname = "stack_3" heapname = "heap_3" startid = "0" />
-            <task name = "task4" clusterid = "2" proclocid = "0" stackname = "stack_4" heapname = "heap_4" startid = "0" />
-            <task name = "task5" clusterid = "2" proclocid = "1" stackname = "stack_5" heapname = "heap_5" startid = "0" />
-            <task name = "task6" clusterid = "3" proclocid = "0" stackname = "stack_6" heapname = "heap_6" startid = "0" />
-            <task name = "task7" clusterid = "3" proclocid = "1" stackname = "stack_7" heapname = "heap_7" startid = "0" />
-        </vspace>
-
-    </vspaceset>
-</mapping_info>
Index: /soft/giet_vm/sort/main.c
===================================================================
--- /soft/giet_vm/sort/main.c	(revision 270)
+++ /soft/giet_vm/sort/main.c	(revision 271)
@@ -38,10 +38,10 @@
 
 //////////////////////////////////////////////////////////////////////////
-// The NPROCS constant must be modified depending on the desired number of
+// The NTHREADS constant must be modified depending on the desired number of
 // threads
 
-#define NPROCS          4 
-#define ARRAY_LENGTH    (NPROCS * 128)
-#define IPP             (ARRAY_LENGTH / NPROCS) // ITEMS PER PROCESSOR
+#define NTHREADS        8
+#define ARRAY_LENGTH    (NTHREADS * 128)
+#define IPT             (ARRAY_LENGTH / NTHREADS) // ITEMS PER THREAD
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -89,5 +89,5 @@
 ///////////////////////////////////////////////////
 // This application support at most 256 processors
-// Number of barriers = log2(NPROCS)
+// Number of barriers = log2(NTHREADS)
 
 giet_barrier_t barrier[8];
@@ -101,12 +101,12 @@
     int i;
 
-    task0_printf("[ Thread 0 ] Starting SORT application\n");
+    printf("[ Thread %d ] Initializing vector and barriers...\n\r", thread_id);
 
     ///////////////////////////
     // Barriers Initialization
 
-    for (i = 0; i < __builtin_ctz(NPROCS); i++)
-    {
-        barrier_init(&barrier[i], NPROCS >> i);
+    for (i = 0; i < __builtin_ctz(NTHREADS); i++)
+    {
+        barrier_init(&barrier[i], NTHREADS >> i);
     }
 
@@ -114,5 +114,5 @@
     // Array Initialization
 
-    for (i = IPP * thread_id; i < IPP * (thread_id + 1); i++)
+    for (i = IPT * thread_id; i < IPT * (thread_id + 1); i++)
     {
         array0[i] = rand();
@@ -124,9 +124,9 @@
     printf("[ Thread %d ] Stage 0: Processor Sorting...\n\r", thread_id);
 
-    bubbleSort(array0, IPP, IPP * thread_id);
+    bubbleSort(array0, IPT, IPT * thread_id);
 
     printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id);
 
-    for (i = 0; i < __builtin_ctz(NPROCS); i++)
+    for (i = 0; i < __builtin_ctz(NTHREADS); i++)
     {
         asm volatile ("sync");
@@ -153,8 +153,8 @@
 
         merge(src_array, dst_array
-                , IPP << i
-                , IPP * thread_id
-                , IPP * (thread_id + (1 << i))
-                , IPP * thread_id
+                , IPT << i
+                , IPT * thread_id
+                , IPT * (thread_id + (1 << i))
+                , IPT * thread_id
                 );
 
