Index: soft/giet_vm/sys/ctx_handler.c
===================================================================
--- soft/giet_vm/sys/ctx_handler.c	(revision 218)
+++ soft/giet_vm/sys/ctx_handler.c	(revision 228)
@@ -30,12 +30,12 @@
 // - CP2 registers : PTPR 
 // It contains some general informations associated to the task:
-// - TTY	: terminal global index
-// - FBDMA	: DMA channel global index
-// - NIC	: NIC channel global index
+// - TTY    : terminal global index
+// - FBDMA    : DMA channel global index
+// - NIC    : NIC channel global index
 // - TIMER  : Timer global index
 // - PTAB   : page table virtual base address 
-// - LTID	: Task local index (in scheduler)
+// - LTID    : Task local index (in scheduler)
 // - VSID   : Virtual space index
-// - RUN	: Task state (0 => sleeping / 1 => runable ) 
+// - RUN    : Task state (0 => sleeping / 1 => runable ) 
 //
 // ctx[0]<- ***|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC  |ctx[40]<- TTY
@@ -49,8 +49,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////
 
-extern void _task_switch(unsigned int*, unsigned int*);
+extern void _task_switch(unsigned int *, unsigned int *);
 
 /////////////////////////////////////////////////////////////////////////////////
-//	_ctx_switch()
+//    _ctx_switch()
 // This function performs a context switch between the running task
 // and  another task, using a round-robin sheduling policy between all
@@ -68,66 +68,61 @@
 //   contained in the ctx[31] slot of the next task context.
 /////////////////////////////////////////////////////////////////////////////////
-void _ctx_switch()
-{
+void _ctx_switch() {
     // get scheduler physical address
-    static_scheduler_t*	psched = (static_scheduler_t*)_get_sched();
+    static_scheduler_t * psched = (static_scheduler_t *) _get_sched();
 
     // get number of tasks allocated to scheduler
-    unsigned int	tasks = _get_tasks_number();
+    unsigned int tasks = _get_tasks_number();
 
     // get current task index
-    unsigned int 	curr_task_id = _get_current_task_id();
+    unsigned int curr_task_id = _get_current_task_id();
 
     // select the next task using a round-robin policy
-    unsigned int 	next_task_id;
-    unsigned int	tid;
-    unsigned int	found = 0;
+    unsigned int next_task_id;
+    unsigned int tid;
+    unsigned int found = 0;
 
-    for ( tid = curr_task_id + 1 ; 
-          tid < curr_task_id + 1 + tasks ;
-          tid++ )
-    {
+    for (tid = curr_task_id + 1; tid < curr_task_id + 1 + tasks; tid++) {
         next_task_id = tid % tasks;
 
         // test if the task is runable
-        if ( _get_context_slot( next_task_id, CTX_RUN_ID ) )	
-        {
+        if (_get_context_slot(next_task_id, CTX_RUN_ID)) {
             found = 1;
-           	break;
+            break;
         }
     }
 
     // launch "idle" task if no runable task
-    if ( found == 0 )
-    {
+    if (found == 0) {
         next_task_id = IDLE_TASK_INDEX;
     }
 
     // no switch if no change
-    if ( curr_task_id != next_task_id )
-    {
-        unsigned int*	curr_ctx_paddr = &(psched->context[curr_task_id][0]);
-        unsigned int*	next_ctx_paddr = &(psched->context[next_task_id][0]);
+    if (curr_task_id != next_task_id) {
+        unsigned int * curr_ctx_paddr = &(psched->context[curr_task_id][0]);
+        unsigned int * next_ctx_paddr = &(psched->context[next_task_id][0]);
 
-        _set_current_task_id( next_task_id );
-        _task_switch( curr_ctx_paddr, next_ctx_paddr );
+        _set_current_task_id(next_task_id);
+        //_timer_reset_irq_cpt(cluster_id, local_id); // commented until not properly supported in soclib
+        // (the function is not yet present in drivers.c)
+        _task_switch(curr_ctx_paddr, next_ctx_paddr);
 
 #if GIET_DEBUG_SWITCH
-_get_lock( &_tty_put_lock );
-_puts( "\n[GIET DEBUG] Context switch for processor ");
-_putd( _procid() );
-_puts( " at cycle ");
-_putd( _proctime() );
-_puts("\n");
-_puts( " - tasks        = ");
-_putd( tasks );
-_puts("\n");
-_puts( " - curr_task_id = ");
-_putd( curr_task_id );
-_puts("\n");
-_puts( " - next_task_id = ");
-_putd( next_task_id );
-_puts("\n");
-_release_lock( &_tty_put_lock );
+        _get_lock(&_tty_put_lock);
+        _puts("\n[GIET DEBUG] Context switch for processor ");
+        _putd(_procid());
+        _puts(" at cycle ");
+        _putd(_proctime());
+        _puts("\n");
+        _puts(" - tasks        = ");
+        _putd(tasks);
+        _puts("\n");
+        _puts(" - curr_task_id = ");
+        _putd( curr_task_id );
+        _puts("\n");
+        _puts(" - next_task_id = ");
+        _putd(next_task_id);
+        _puts("\n");
+        _release_lock( &_tty_put_lock);
 #endif
 
@@ -138,29 +133,29 @@
 // This function is executed as the"idle" task when no other task can be executed 
 /////////////////////////////////////////////////////////////////////////////////////
-void _ctx_idle()
-{
+void _ctx_idle() {
     unsigned int delay = 1000000;
 
-    while(1)
-    {
-        asm volatile("move  $3,   %0		\n"
-                     "loop:					\n"
-                     "addi	$3, $3, -1		\n"
-                     "bnez  $3,	loop		\n"
-                     "nop					\n"
-                     :
-                     : "r"(delay)
-                     : "$3" ); 
+    while (1) {
+        asm volatile(
+                "move   $3,   %0          \n"
+                "loop:                    \n"
+                "addi   $3,   $3,   -1    \n"
+                "bnez   $3,   loop        \n"
+                "nop                      \n"
+                :
+                : "r"(delay)
+                : "$3" ); 
 
-        _get_lock( &_tty_put_lock );
-        _puts( "\n[GIET WARNING] Processor ");
-        _putd( _procid() );
-        _puts( " still idle at cycle ");
-        _putd( _proctime() );
+        _get_lock(&_tty_put_lock);
+        _puts("\n[GIET WARNING] Processor ");
+        _putd(_procid());
+        _puts(" still idle at cycle ");
+        _putd(_proctime());
         _puts("\n");
-        _release_lock( &_tty_put_lock );
-   
+        _release_lock(&_tty_put_lock);
+
     }
 } // end ctx_idle()
+
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -168,8 +163,15 @@
 // in the "idle" task context.
 /////////////////////////////////////////////////////////////////////////////////
-void _ctx_eret()
-{
+void _ctx_eret() {
     asm volatile("eret");
 }
 
 
+// Local Variables:
+// tab-width: 4
+// c-basic-offset: 4
+// c-file-offsets:((innamespace . 0)(inline-open . 0))
+// indent-tabs-mode: nil
+// End:
+// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
+
