Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 428)
+++ trunk/kernel/kern/rpc.c	(revision 433)
@@ -42,4 +42,31 @@
 #include <rpc.h>
 
+
+/////////////////////////////////////////////////////////////////////////////////////////
+//        Debug macros for marshalling functions
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#if CONFIG_DEBUG_RPC_MARSHALING
+
+#define RPC_DEBUG_ENTER                                                                \
+uint32_t cycle = (uint32_t)hal_get_cycles();                                           \
+if( cycle > CONFIG_DEBUG_RPC_MARSHALING )                                              \
+printk("\n[DBG] %s : enter thread %x on core[%x,%d] / cycle %d\n",                     \
+__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, CURRENT_THREAD->core->lid , cycle );
+
+#define RPC_DEBUG_EXIT                                                                 \
+cycle = (uint32_t)hal_get_cycles();                                                    \
+if( cycle > CONFIG_DEBUG_RPC_MARSHALING )                                              \
+printk("\n[DBG] %s : exit thread %x on core[%x,%d] / cycle %d\n",                      \
+__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, CURRENT_THREAD->core->lid , cycle );
+
+#else
+
+#define RPC_DEBUG_ENTER
+
+#define RPC_DEBUG_EXIT
+
+#endif
+
 /////////////////////////////////////////////////////////////////////////////////////////
 //      array of function pointers  (must be consistent with enum in rpc.h) 
@@ -50,7 +77,7 @@
     &rpc_pmem_get_pages_server,         // 0
     &rpc_pmem_release_pages_server,     // 1
-    &rpc_process_make_exec_server,      // 2
+    &rpc_undefined,                     // 2    unused slot
     &rpc_process_make_fork_server,      // 3
-    &rpc_process_make_exit_server,      // 4
+    &rpc_undefined,                     // 4    unused slot
     &rpc_process_make_kill_server,      // 5
     &rpc_thread_user_create_server,     // 6
@@ -68,5 +95,5 @@
     &rpc_vfs_mapper_load_all_server,    // 17
     &rpc_fatfs_get_cluster_server,      // 18
-    &rpc_undefined,                     // 19
+    &rpc_undefined,                     // 19   unused slot
 
     &rpc_vmm_get_vseg_server,           // 20
@@ -497,71 +524,6 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [2]           Marshaling functions attached to RPC_PROCESS_MAKE_EXEC (blocking)
-/////////////////////////////////////////////////////////////////////////////////////////
-
-/////////////////////////////////////////////////////
-void rpc_process_make_exec_client( cxy_t         cxy,
-                                   exec_info_t * info,     // in
-                                   error_t     * error )   // out
-{
-rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_PROCESS_MAKE_EXEC;
-    rpc.response = 1;
-    rpc.blocking = true;
-
-    // set input arguments in RPC descriptor  
-    rpc.args[0] = (uint64_t)(intptr_t)info;
-
-    // register RPC request in remote RPC fifo (blocking function)
-    rpc_send( cxy , &rpc );
-
-    // get output arguments from RPC descriptor
-    *error  = (error_t)rpc.args[1];     
-
-rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-}
-
-//////////////////////////////////////////////
-void rpc_process_make_exec_server( xptr_t xp )
-{
-rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-    exec_info_t * ptr;       // local pointer on remote exec_info structure
-    exec_info_t   info;      // local copy of exec_info structure
-    error_t       error;     // local error error status
-
-    // get client cluster identifier and pointer on RPC descriptor
-    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
-    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
-
-    // get pointer on exec_info structure in client cluster from RPC descriptor
-    ptr = (exec_info_t*)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
-
-    // copy exec_info structure from client buffer to server buffer
-    hal_remote_memcpy( XPTR( client_cxy , ptr ),
-                       XPTR( local_cxy , &info ),
-                       sizeof(exec_info_t) );
-
-    // call local kernel function
-    error = process_make_exec( &info ); 
-
-    // set output argument into client RPC descriptor
-    hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
-
-rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-}
+// [2]      undefined slot
+/////////////////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -644,10 +606,15 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [4]      Marshaling functions attached to RPC_PROCESS_MAKE_EXIT (blocking)
+// [4]      undefined slot
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [5]      Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking)
 /////////////////////////////////////////////////////////////////////////////////////////
 
 ///////////////////////////////////////////////////
-void rpc_process_make_exit_client( cxy_t       cxy,
-                                   pid_t       pid,
+void rpc_process_make_kill_client( cxy_t       cxy,
+                                   process_t * process,
+                                   bool_t      is_exit,
                                    uint32_t    status ) 
 {
@@ -656,15 +623,14 @@
 CURRENT_THREAD->core->lid , hal_time_stamp() );
 
-    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_PROCESS_MAKE_EXIT;
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_PROCESS_MAKE_KILL;
     rpc.response = 1;
     rpc.blocking = true;
 
     // set input arguments in RPC descriptor  
-    rpc.args[0] = (uint64_t)pid;
-    rpc.args[1] = (uint64_t)status;
+    rpc.args[0] = (uint64_t)(intptr_t)process;
+    rpc.args[1] = (uint64_t)is_exit;
+    rpc.args[2] = (uint64_t)status;
 
     // register RPC request in remote RPC fifo (blocking function)
@@ -677,5 +643,5 @@
 
 //////////////////////////////////////////////
-void rpc_process_make_exit_server( xptr_t xp )
+void rpc_process_make_kill_server( xptr_t xp )
 {
 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
@@ -683,6 +649,7 @@
 CURRENT_THREAD->core->lid , hal_time_stamp() );
 
-    pid_t     pid;
-    uint32_t  status;  
+    process_t * process;
+    bool_t      is_exit;
+    uint32_t    status;
 
     // get client cluster identifier and pointer on RPC descriptor
@@ -691,9 +658,10 @@
 
     // get arguments from RPC descriptor
-    pid    = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
-    status = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+    process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    is_exit = (bool_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+    status  = (uint32_t)             hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
 
     // call local kernel function
-    process_make_exit( pid , status ); 
+    process_make_kill( process , is_exit , status ); 
 
 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
@@ -703,64 +671,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [5]      Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking)
-/////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////
-void rpc_process_make_kill_client( cxy_t       cxy,
-                                   pid_t       pid,
-                                   uint32_t    sig_id ) 
-{
-rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_PROCESS_MAKE_KILL;
-    rpc.response = 1;
-    rpc.blocking = true;
-
-    // set input arguments in RPC descriptor  
-    rpc.args[0] = (uint64_t)pid;
-    rpc.args[1] = (uint64_t)sig_id;
-
-    // register RPC request in remote RPC fifo (blocking function)
-    rpc_send( cxy , &rpc );
-
-rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-}  
-
-//////////////////////////////////////////////
-void rpc_process_make_kill_server( xptr_t xp )
-{
-rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-    pid_t       pid;
-    uint32_t    sig_id;
-
-    // get client cluster identifier and pointer on RPC descriptor
-    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
-    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
-
-    // get arguments from RPC descriptor
-    pid    = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
-    sig_id = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
-
-    // call local kernel function
-    process_make_exit( pid , sig_id ); 
-
-rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 
-CURRENT_THREAD->core->lid , hal_time_stamp() );
-} 
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// [6]           Marshaling functions attached to RPC_THREAD_USER_CREATE (blocking)               
+// [6]           Marshaling functions attached to RPC_THREAD_USER_CREATE (blocking)  
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -1036,7 +945,7 @@
 
     // call relevant kernel function
-    if      (action == DELETE_ALL_THREADS  ) process_delete_threads ( process , client_xp ); 
-    else if (action == BLOCK_ALL_THREADS   ) process_block_threads  ( process , client_xp ); 
-    else if (action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process             );
+    if      (action == DELETE_ALL_THREADS  ) process_delete_threads ( process ); 
+    else if (action == BLOCK_ALL_THREADS   ) process_block_threads  ( process ); 
+    else if (action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process );
 
     // decrement the responses counter in RPC descriptor,
