Index: trunk/kernel/kern/process.c
===================================================================
--- trunk/kernel/kern/process.c	(revision 124)
+++ trunk/kernel/kern/process.c	(revision 172)
@@ -1,5 +1,5 @@
 /*
  * process.c - process related management
- * 
+ *
  * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
  *          Mohamed Lamine Karaoui (2015)
@@ -10,9 +10,9 @@
  * This file is part of ALMOS-MKH..
  *
- * ALMOS-MKH. is free software; you can redistribute it and/or modify it
+ * ALMOS-MKH is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
  * the Free Software Foundation; version 2.0 of the License.
  *
- * ALMOS-MKH. is distributed in the hope that it will be useful, but
+ * ALMOS-MKH is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -20,5 +20,5 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
+ * along with ALMOS-MKH; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
@@ -95,5 +95,5 @@
     // get parent process cluster, local pointer, and pid
     // for all processes other than process_zero
-    if( process == &process_zero ) 
+    if( process == &process_zero )
     {
         assert( (pid == 0) , __FUNCTION__ , "process_zero must have PID = 0\n");
@@ -113,5 +113,5 @@
     if( pid ) vmm_init( process );
 
-    // reset reference process file descriptors array 
+    // reset reference process file descriptors array
 	process_fd_init( process );
 
@@ -140,5 +140,5 @@
         xlist_add_first( root , entry );
     }
-    
+
     // reset th_tbl[] array as empty
     uint32_t i;
@@ -154,5 +154,5 @@
     process->ppid  = parent_pid;
 
-    // set ref_xp field 
+    // set ref_xp field
     process->ref_xp = XPTR( local_cxy , process );
 
@@ -163,5 +163,5 @@
     cluster_process_copies_link( process );
 
-    // initalise signal manager TODO [AG]
+    // initialize signal manager TODO [AG]
 
 	hal_fence();
@@ -169,6 +169,5 @@
     process_dmsg("\n[INFO] %s : exit for process %x in cluster %x\n",
                  __FUNCTION__ , pid );
-
-} // end process_reference_init()
+}
 
 /////////////////////////////////////////////////////
@@ -180,8 +179,8 @@
     process_t * ref_ptr = (process_t *)GET_PTR( reference_process_xp );
 
-    // reset local process vmm 
+    // reset local process vmm
     vmm_init( local_process );
 
-    // reset process file descriptors array 
+    // reset process file descriptors array
 	process_fd_init( local_process );
 
@@ -198,5 +197,5 @@
     // reset children list root (not used in a process descriptor copy)
     xlist_root_init( XPTR( local_cxy , &local_process->children_root ) );
-    local_process->children_nr   = 0;           
+    local_process->children_nr   = 0;
 
     // reset brothers list (not used in a process descriptor copy)
@@ -224,16 +223,15 @@
     cluster_process_copies_link( local_process );
 
-    // initalise signal manager TODO [AG]
+    // initialize signal manager TODO [AG]
 
 	hal_fence();
 
     return 0;
-
-}  // end process_copy_init()
+}
 
 ///////////////////////////////////////////
 void process_destroy( process_t * process )
 {
-	if( process->th_nr != 0 )  
+	if( process->th_nr != 0 )
     {
 	    printk("\n[PANIC] in %s : process %x in cluster %x has still active threads\n",
@@ -248,5 +246,5 @@
     remote_spinlock_lock( XPTR( local_cxy , &pmgr->local_lock ) );
 
-    // remove the process descriptor from local_list in local cluster manager 
+    // remove the process descriptor from local_list in local cluster manager
     xlist_unlink( XPTR( local_cxy , &process->local_list ) );
 
@@ -263,9 +261,9 @@
     xlist_unlink( XPTR( local_cxy , &process->copies_list ) );
     remote_spinlock_unlock( copies_lock );
-    
+
     // synchronize memory
 	hal_fence();
 
-    // From this point, the process descriptor is unreachable 
+    // From this point, the process descriptor is unreachable
 
     // close all open files and update dirty TODO [AG]
@@ -283,6 +281,5 @@
 	process_dmsg("\n[INFO] %s for pid %d / page_faults = %d\n",
 	         __FUNCTION__ , process->pid, process->vmm.pgfault_nr );
-
-}  // end process_destroy()
+}
 
 ////////////////////////////////////////
@@ -298,6 +295,6 @@
     // first loop on threads to send the THREAD_SIG_KILL signal to all process threads
     // we use both "ltid" and "count" indexes, because it can exist "holes" in th_tbl
-    for( ltid = 0 , count = 0  ; 
-         (ltid < CONFIG_THREAD_MAX_PER_CLUSTER) && (count < process->th_nr) ; 
+    for( ltid = 0 , count = 0  ;
+         (ltid < CONFIG_THREAD_MAX_PER_CLUSTER) && (count < process->th_nr) ;
          ltid++ )
     {
@@ -309,11 +306,11 @@
             count++;
         }
-    }   
-    
+    }
+
     volatile uint32_t ko;
 
     // second loop on threads to wait acknowledge from scheduler,
     // unlink thread from process and parent thread, and release thread descriptor
-    for( ltid = 0 , count = 0  ; 
+    for( ltid = 0 , count = 0  ;
          (ltid < CONFIG_THREAD_MAX_PER_CLUSTER) && (count < process->th_nr) ;
          ltid++ )
@@ -327,5 +324,5 @@
 
             // unlink thread from brothers list if required
-            if( (thread->flags & THREAD_FLAG_DETACHED) == 0 ) 
+            if( (thread->flags & THREAD_FLAG_DETACHED) == 0 )
             xlist_unlink( XPTR( local_cxy , &thread->brothers_list ) );
 
@@ -345,8 +342,5 @@
     // release memory allocated for process descriptor
     process_destroy( process );
-
-}  // end process_kill()
-
-
+}
 
 ///////////////////////////////////////////////
@@ -354,5 +348,5 @@
 {
     error_t        error;
-    process_t    * process_ptr;   // local pointer on process 
+    process_t    * process_ptr;   // local pointer on process
     xptr_t         process_xp;    // extended pointer on process
     pid_t          process_pid;   // process identifier
@@ -370,5 +364,5 @@
         process_xp  = XLIST_ELEMENT( iter , process_t , local_list );
         process_ptr = (process_t *)GET_PTR( process_xp );
-        process_pid = hal_remote_lw( XPTR( local_cxy , &process_ptr->pid ) ); 
+        process_pid = hal_remote_lw( XPTR( local_cxy , &process_ptr->pid ) );
         if( process_ptr->pid == pid )
         {
@@ -381,5 +375,5 @@
     remote_spinlock_unlock( XPTR( local_cxy , &cluster->pmgr.local_lock ) );
 
-    // allocate memory for a new local process descriptor 
+    // allocate memory for a new local process descriptor
     // and initialise it from reference cluster if required
     if( !found )
@@ -400,6 +394,5 @@
 
     return process_ptr;
-} // end process_get_local_copy()
-
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -423,9 +416,8 @@
 }
 
-
 //////////////////////////////
 bool_t process_fd_array_full()
 {
-    // get extended pointer on reference process 
+    // get extended pointer on reference process
     xptr_t ref_xp = CURRENT_THREAD->process->ref_xp;
 
@@ -437,9 +429,9 @@
     uint32_t current = hal_remote_lw( XPTR( ref_cxy , &ref_ptr->fd_array.current ) );
 
-	return ( current >= CONFIG_PROCESS_FILE_MAX_NR );  
+	return ( current >= CONFIG_PROCESS_FILE_MAX_NR );
 }
 
 /////////////////////////////////////////////////
-error_t process_fd_register(  xptr_t     file_xp, 
+error_t process_fd_register(  xptr_t     file_xp,
                               uint32_t * file_id )
 {
@@ -448,5 +440,5 @@
     xptr_t    xp;
 
-    // get extended pointer on reference process 
+    // get extended pointer on reference process
     xptr_t ref_xp = CURRENT_THREAD->process->ref_xp;
 
@@ -478,8 +470,7 @@
     if ( !found ) return EMFILE;
     else          return 0;
-
-}  // end process_fd_register()
-
-//////////////////////////////////////////////// 
+}
+
+////////////////////////////////////////////////
 xptr_t process_fd_get_xptr( process_t * process,
                             uint32_t    file_id )
@@ -508,6 +499,5 @@
 
     return file_xp;
-
-}  // end process_fd_get_xptr()
+}
 
 ///////////////////////////////////////////
@@ -529,5 +519,5 @@
 	remote_spinlock_lock( XPTR( src_cxy , &src_ptr->lock ) );
 
-    // loop on all entries in source process fd_array        
+    // loop on all entries in source process fd_array
     for( fd = 0 ; fd < CONFIG_PROCESS_FILE_MAX_NR ; fd++ )
 	{
@@ -546,7 +536,5 @@
     // release lock on source process fd_array
 	remote_spinlock_unlock( XPTR( src_cxy , &src_ptr->lock ) );
-} 
-
-
+}
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -588,7 +576,5 @@
 
     return (found) ? 0 : ENOMEM;
-
-}  // process_register_thread()
-    
+}
 ///////////////////////////////////////////////
 void process_remove_thread( thread_t * thread )
@@ -599,5 +585,5 @@
         hal_core_sleep();
     }
-    
+
     process_t * process = thread->process;
 
@@ -608,7 +594,5 @@
     process->th_tbl[ltid] = NULL;
     process->th_nr--;
-
-}  // process_remove_thread()
-
+}
 
 /////////////////////////////////////////////////////
@@ -616,5 +600,5 @@
 {
     char           * path;                            // pathname to .elf file
-    process_t      * process;                         // local pointer on new process 
+    process_t      * process;                         // local pointer on new process
     pid_t            pid;                             // new process pid
     xptr_t           parent_xp;                       // extended pointer on parent process
@@ -626,5 +610,5 @@
     core_t         * core;                            // pointer on selected core
     lid_t            lid;                             // selected core local index
-	error_t          error; 
+	error_t          error;
 
 	// get parent and .elf pathname from exec_info
@@ -636,5 +620,5 @@
     parent_ptr = (process_t *)GET_PTR( parent_xp );
     parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
-    
+
     exec_dmsg("\n[INFO] %s enters in cluster %x for path = %s\n",
                 __FUNCTION__ , local_cxy , path );
@@ -650,21 +634,21 @@
     }
 
-    // get a pid from the local cluster 
+    // get a pid from the local cluster
     error = cluster_pid_alloc( XPTR( local_cxy , process ) , &pid );
 
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot get PID / cluster = %x / ppid = %x / path = %s\n", 
+        printk("\n[ERROR] in %s : cannot get PID / cluster = %x / ppid = %x / path = %s\n",
                __FUNCTION__ , local_cxy , parent_pid , path );
 		return ENOMEM;
     }
- 
+
     // initialize the process descriptor as the reference
     process_reference_init( process , pid , parent_xp );
-                                
+
     exec_dmsg("\n[INFO] %s created process %x cluster %x / path = %s\n",
                 __FUNCTION__, parent_pid , local_cxy , path );
 
-    // initializes vfs_root and vfs_cwd from parent process
+    // initialize vfs_root and vfs_cwd from parent process
     xptr_t  vfs_root_xp = hal_remote_lwd( XPTR( parent_cxy , &parent_ptr->vfs_root_xp ) );
 	vfs_file_count_up( vfs_root_xp );
@@ -688,11 +672,11 @@
                 __FUNCTION__ , local_cxy , pid , path );
 
-    // register "code" and "data" vsegs as well a the process entry-point in VMM,
-    // using informations contained in the elf file.
+    // register "code" and "data" vsegs as well as the process entry-point in VMM,
+    // using information contained in the elf file.
 	error = elf_load_process( path , process );
 
 	if( error )
 	{
-		printk("\n[ERROR] in %s : failed to access elf file for process %x / path = %s\n", 
+		printk("\n[ERROR] in %s : failed to access elf file for process %x / path = %s\n",
 		       __FUNCTION__, pid , path );
         process_destroy( process );
@@ -722,10 +706,10 @@
     attr.lid        = lid;
 
-    // create and initialise thread descriptor
+    // create and initialize thread descriptor
 	error = thread_user_create( pid,
                                 (void *)process->vmm.entry_point,
                                 exec_info->args_pointers,
                                 &attr,
-                                &thread ); 
+                                &thread );
 	if( error )
 	{
@@ -741,5 +725,5 @@
 	hal_remote_atomic_add( XPTR( parent_cxy , &parent_ptr->children_nr) , 1 );
 
-	// Register thread in scheduler 
+	// register thread in scheduler
 	sched_register_thread( core , thread );
 
@@ -747,10 +731,9 @@
                __FUNCTION__ , pid , core->lid , local_cxy );
 
-    // activate new thread 
+    // activate new thread
 	thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
 
 	return 0;
-
-} // end process_make_exec()
+}
 
 //////////////////////////
@@ -765,7 +748,7 @@
     xptr_t    stdout_xp;
     xptr_t    stderr_xp;
-    uint32_t  stdin_id; 
-    uint32_t  stdout_id; 
-    uint32_t  stderr_id; 
+    uint32_t  stdin_id;
+    uint32_t  stdout_id;
+    uint32_t  stderr_id;
 
 	process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );
@@ -816,6 +799,4 @@
 		
     hal_fence();
-
-} // end process_init_create()
-
-
+}
+
