Index: soft/giet_vm/applications/mjpeg/mjpeg.py
===================================================================
--- soft/giet_vm/applications/mjpeg/mjpeg.py	(revision 736)
+++ soft/giet_vm/applications/mjpeg/mjpeg.py	(revision 741)
@@ -12,6 +12,5 @@
 #
 #  The mapping of threads on processors is the following:
-#    - the "main" thread, on P[0,0,0] launches all others threads and exit.
-#    - the "tg" thread is only running on P[0,0,0].
+#    - the "main" thread is running on P[0,0,0].
 #    - the "demux", "iqzz", "idct", "vld", and "libu" threads, implementing
 #      a block-level pipe-line, are replicated in all clusters.
@@ -83,5 +82,5 @@
 
     # stacks vsegs: local (one stack per thread => 5 stacks per cluster)
-    # ... plus main_stack and tg_stack in cluster[0][0]
+    # ... plus main_stack in cluster[0][0]
     base = stack_base
     mapping.addVseg( vspace, 'mjpeg_main_stack',
@@ -92,11 +91,4 @@
     base += stack_size
 
-    mapping.addVseg( vspace, 'mjpeg_tg_stack',
-                     base , stack_size, 'C_WU', vtype = 'BUFFER', 
-                     x = 0 , y = 0 , pseg = 'RAM',
-                     local = True )
-
-    base += stack_size
-
     for x in xrange (x_size):
         for y in xrange (y_size):
@@ -139,5 +131,5 @@
 
     # threads mapping: demux, vld, iqzz, idct, libu replicated in all clusters
-    # main & tg are mapped in cluster[0,0]
+    # main  mapped in cluster[0,0]
     mapping.addThread( vspace, 'main', True, 0, 0, 0,
                        'mjpeg_main_stack',
@@ -145,38 +137,56 @@
                        0 )                      # index in start_vector
 
-    if ( nprocs == 1 ):
-        p_tg    = 0
-        p_demux = 0
-        p_vld   = 0
-        p_iqzz  = 0
-        p_idct  = 0
-        p_libu  = 0
-    elif ( nprocs == 2 ):
-        p_tg    = 0
-        p_demux = 1
-        p_vld   = 1
-        p_iqzz  = 1
-        p_idct  = 1
-        p_libu  = 1
-    elif ( nprocs == 3 ):
-        p_tg    = 0
-        p_demux = 1
-        p_vld   = 2
-        p_iqzz  = 1
-        p_idct  = 1
-        p_libu  = 1
-    elif ( nprocs == 4 ):
-        p_tg    = 0
-        p_demux = 1
-        p_vld   = 3
-        p_iqzz  = 2
-        p_idct  = 3
-        p_libu  = 2
+    if ( x==0 and y==0 ):        # tasks mapping in cluster[0,0]
+        if ( nprocs == 1 ):
+            p_demux = 0
+            p_vld   = 0
+            p_iqzz  = 0
+            p_idct  = 0
+            p_libu  = 0
+        elif ( nprocs == 2 ):
+            p_demux = 1
+            p_vld   = 1
+            p_iqzz  = 1
+            p_idct  = 1
+            p_libu  = 1
+        elif ( nprocs == 3 ):
+            p_demux = 1
+            p_vld   = 2
+            p_iqzz  = 1
+            p_idct  = 1
+            p_libu  = 1
+        elif ( nprocs == 4 ):
+            p_demux = 1
+            p_vld   = 2
+            p_iqzz  = 1
+            p_idct  = 3
+            p_libu  = 1
+    else:                        # tasks mapping in other clusters
+        if ( nprocs == 1 ):
+            p_demux = 0
+            p_vld   = 0
+            p_iqzz  = 0
+            p_idct  = 0
+            p_libu  = 0
+        elif ( nprocs == 2 ):
+            p_demux = 0
+            p_vld   = 1
+            p_iqzz  = 0
+            p_idct  = 0
+            p_libu  = 0
+        elif ( nprocs == 3 ):
+            p_demux = 0
+            p_vld   = 1
+            p_iqzz  = 0
+            p_idct  = 2
+            p_libu  = 1
+        elif ( nprocs == 4 ):
+            p_demux = 0
+            p_vld   = 1
+            p_iqzz  = 2
+            p_idct  = 3
+            p_libu  = 2
+
     
-    mapping.addThread( vspace, 'tg', False, 0, 0, p_tg,
-                       'mjpeg_tg_stack',
-                       'mjpeg_heap_0_0',
-                       1 )                      # index in start_vector
-
     for x in xrange (x_size):
         for y in xrange (y_size):
@@ -186,25 +196,25 @@
                                    'mjpeg_demux_stack_%d_%d' % (x,y), 
                                    'mjpeg_heap_%d_%d' % (x,y),
-                                   2 )   # start_index  
+                                   1 )   # start_index  
 
                 mapping.addThread( vspace, 'vld_%d_%d' % (x,y), False , x, y, p_vld,
                                    'mjpeg_vld_stack_%d_%d' % (x,y), 
                                    'mjpeg_heap_%d_%d' % (x,y),
-                                   3 )   # start_index  
+                                   2 )   # start_index  
 
                 mapping.addThread( vspace, 'iqzz_%d_%d' % (x,y), False , x, y, p_iqzz,
                                    'mjpeg_iqzz_stack_%d_%d' % (x,y), 
                                    'mjpeg_heap_%d_%d' % (x,y),
-                                   4 )   # start_index  
+                                   3 )   # start_index  
 
                 mapping.addThread( vspace, 'idct_%d_%d' % (x,y), False , x, y, p_idct,
                                    'mjpeg_idct_stack_%d_%d' % (x,y), 
                                    'mjpeg_heap_%d_%d' % (x,y),
-                                   5 )   # start_index  
+                                   4 )   # start_index  
 
                 mapping.addThread( vspace, 'libu_%d_%d' % (x,y), False , x, y, p_libu,
                                    'mjpeg_libu_stack_%d_%d' % (x,y), 
                                    'mjpeg_heap_%d_%d' % (x,y),
-                                   6 )   # start_index  
+                                   5 )   # start_index  
 
     # extend mapping name
