Index: trunk/kernel/kern/signal.c
===================================================================
--- trunk/kernel/kern/signal.c	(revision 5)
+++ trunk/kernel/kern/signal.c	(revision 23)
@@ -23,18 +23,41 @@
 
 #include <hal_types.h>
-#include <errno.h>
+#include <hal_atomic.h>
+#include <printk.h>
 #include <thread.h>
-#include <process.h>
-#include <core.h>
+#include <spinlock.h>
 #include <signal.h>
+
+//////////////////////////////////////
+void signal_rise( process_t * process, 
+                  uint32_t    sig_id )
+{
+    // get the lock protecting the set of local threads
+	spinlock_lock( &process->th_lock );
+
+    // loop on local threads
+	thread_t * thread;
+	uint32_t   i;
+	for( i = 0 ; i < process->th_nr ; i++ )
+	{
+		thread = process->th_tbl[i];
+		hal_atomic_or( &thread->signals , (1 << sig_id) );
+
+        signal_dmsg("\n[INFO] %s : thread %x in process %x received signal %d\n",
+                    __FUNCTION__, thread->trdid , process->pid , sig_id );
+	}
+
+    // release the lock
+	spinlock_unlock( &process->th_lock );
+
+}  // end signal_rise()
+
+/*
 
 SIGNAL_HANDLER(kill_sigaction)
 {
-	struct thread_s *this;
-  
-	this = CURRENT_THREAD;
-	this->state = S_KERNEL;
+	thread_s * this = CURRENT_THREAD;
 
-	printk(INFO, "INFO: Recieved signal %d, pid %d, tid %x, core %d  [ KILLED ]\n",
+	printk("\n[INFO] %s : threadReceived signal %d, pid %d, tid %x, core %d  [ KILLED ]\n",
 	       sig,
 	       this->process->pid,
@@ -45,5 +68,5 @@
 }
 
-//////////////////////////////////////////////////
+///////////////////////////////////////////////
 void signal_manager_init( process_t * process )
 {
@@ -53,157 +76,14 @@
 }
 
-//////////////////////////////////////
-void signal_rise( process_t * process, 
-                  uint32_t    sig )
+
+/////////////////////////////////////
+void signal_notify( thread_t * this )
 {
-	thread_t     * thread;
-	uint32_t       i;
+	uint32_t     sig_state;
+	uint32_t     sig;
+	sig_mgr_t  * sig_mgr;
+	uint32_t     irq_state;
 
-	spinlock_lock( &process->th_lock );
-
-	for( i = 0 ; i < process->th_nr ; i++ )
-	{
-		thread = process->th_tbl[i];
-		hal_atomic_or( &thread->signals , (1 << sig) );
-	}
-
-	spinlock_unlock( &process->th_lock );
-
-	sig_dmsg("\n[INFO] %s : %d threads have been signaled for process %d\n",
-                        __FUNCTION__, process->th_nr , process->pid );
-
-}  // end signal_rise()
-
-///////////////////////////////////////////
-RPC_DECLARE( __signal_rise,                             \
-                RPC_RET( RPC_RET_PTR(error_t, err)),    \
-                RPC_ARG( RPC_ARG_VAL(pid_t,   pid),     \
-                         RPC_ARG_VAL(uint32_t,  sig))     \
-           )
-{
-         process_t   * process;
-        struct hnode_s  *hnode;
-
-        /* Avoid killing process0 and init */
-        /* FIXME: Zero should not be hard-coded but obtains with something like MAIN_KERN */
-        if( ((pid == PID_MIN_GLOBAL) || (pid == PID_MIN_GLOBAL+1))
-                        && (current_cid == 0) )
-        {
-                *err = EPERM;
-                sig_dmsg(1, "%s: can't kill process %u on cluster %u\n",           \
-                                __FUNCTION__, PID_GET_LOCAL(pid), current_cid);
-                goto SYS_RISE_ERR_PID;
-        }
-
-        /* Step 1 : lock the process manager */
-        processs_manager_lock();
-
-        /* Step 2 : Get the process' address */
-        /* Case 1 : current cluster is the anchor and the owner. */
-        if ( PID_GET_CLUSTER(pid) == current_cid )
-        {
-                sig_dmsg(1, "%s: process %u is in the processs manager array of cluster  %u\n",       \
-                                __FUNCTION__, pid, current_cid);
-                process = process_lookup(pid)->process;
-
-        }
-        else /* Case 2 : current cluster is not the anchor, so the struct
-              * process_s is in its hash table.
-              */
-        {
-                sig_dmsg(1, "%s: process %u is in the processs manager hash table of cluster  %u\n",  \
-                                __FUNCTION__, pid, current_cid);
-                hnode = hfind(processs_manager_get_htable(), (void*)pid);
-                process    = ( process_t*) container_of(hnode,          \
-                                 process_t, t_hnode);
-        }
-
-        /* Step 4 : check process' address */
-        if ( process == NULL )
-        {
-                *err = ESRCH;
-                goto SYS_RISE_ERR;
-        }
-
-        /* Step 5 : deliver signal */
-        if((sig == SIGTERM) || (sig == SIGKILL))
-                *err = signal_rise_all(process, sig);
-        else
-                *err = signal_rise_one(process, sig);
-
-        /* Step 6 : unlock processs manager */
-        processs_manager_unlock();
-
-        return;
-
-SYS_RISE_ERR:
-        processs_manager_unlock();
-SYS_RISE_ERR_PID:
-        sig_dmsg(1, "%s: Cluster %u has not deliver signal %u to process %u (err %u)\n",  \
-                        __FUNCTION__, current_cid, sig, err );
-
-        return;
-}
-
-///////////////////////////////
-error_t sys_kill( pid_t    pid, 
-                  uint32_t sig)
-{
-    cxy_t       owner_cxy;    // process owner cluster
-    lpid_t      owner_lpid;   // local process identifier 
-    xptr_t      root_xp;      // extended pointer on root of xlist of process copies
-    xptr_t      lock_xp;      // extended pointer on remote_spinlock protecting this list
-    xptr_t      iter_xp;      // iterator for process copies list
-    xptr_t      process_xp;   // local pointer on process copy 
-    cxy_t       process_cxy;  // cluster of process copy
-    process_t * process_ptr;  // local pointer on process copy 
-	error_t     error;
-
-    // get local pointer on local cluster manager
-    cluster_t * cluster = LOCAL_CLUSTER;
-
-    // get owner process cluster and lpid
-    owner_cxy  = CXY_FROM_PID( pid );
-    owner_lpid = LPID_FROM_PID( pid );
-
-    // get extended pointers on copies root and lock
-    root_xp = XPTR( owner_cxy , &cluster->copies_root[lpid] );
-    lock_xp = XPTR( owner_cxy , &cluster->copies_lock[lpid] );
-
-    // take the lock protecting the copies
-    remote_spinlock_lock( lock_xp );
-
-    // TODO the loop below sequencialize the RPCs
-    // they could be pipelined...
- 
-    // traverse the list of copies
-    XLIST_FOREACH( root_xp , iter_xp )
-    {
-        process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
-        process_cxy = GET_CXY( process_xp );
-        process_ptr = (process_t *)GET_PTR( process_xp );
-
-        if( process_xy == local_cxy )   // process copy is local
-        {
-            error = signal_rise( process_ptr , sig );
-        }
-        else                           // process copy is remote
-        {
-            rpc_signal_rise_client( process_cxy , process_ptr , sig );
-        }
-    }
-
-	return 0;
-}
-
-////////////////////////////////////
-void signal_notify( thread_s * this)
-{
-	register uint32_t sig_state;
-	register uint32_t sig;
-	register struct sig_mgr_s *sig_mgr;
-	uint32_t irq_state;
-
-	sig_state = this->info.sig_state & this->info.sig_mask;
+	sig_state = this->signals;
 	sig       = 0;
  
@@ -242,2 +122,3 @@
 	}
 }
+*/
