Ignore:
Timestamp:
Apr 26, 2017, 2:11:56 PM (7 years ago)
Author:
alain
Message:

Introduce the chdev_t structure in place of the device_t structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/signal.c

    r1 r5  
    22 * signal.c - signal-management related operations implementation
    33 *
    4  * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *         Mohamed Lamine Karaoui (2015)
    6  *         Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017)
    75 *
    86 * Copyright (c) UPMC Sorbonne Universites
     
    5553}
    5654
    57 ////////////////////////////////////////
    58 error_t signal_init( thread_t * thread )
    59 {
    60         thread->info.sig_state = 0;
    61         thread->info.sig_mask  = CURRENT_THREAD->info.sig_mask;
    62         return 0;
    63 }
    64 
    65 ////////////////////////////////////////////////////
    66 static error_t signal_rise_all( process_t * process,
    67                                 uint32_t    sig )
     55//////////////////////////////////////
     56void signal_rise( process_t * process,
     57                  uint32_t    sig )
    6858{
    6959        thread_t     * thread;
     
    8373                        __FUNCTION__, process->th_nr , process->pid );
    8474
    85         return 0;
    86 }
    87 
    88 ////////////////////////////////////////////////////
    89 static error_t signal_rise_one( process_t * process,
    90                                 uint32_t    sig )
    91 {
    92         thread_t * thread;
    93 
    94         spinlock_lock( &process->th_lock );
    95 
    96 //mdify to current_thread, not the one pointed by the sig_mgr ?
    97         if(process->sig_mgr.handler == NULL)
    98                 thread = list_first(&process->th_root, struct thread_s, rope);
    99         else
    100                 thread = process->sig_mgr.handler;
    101 
    102         spinlock_lock( &thread->lock );
    103         thread->info.sig_state |= (1 << sig);
    104         spinlock_unlock( &thread->lock );
    105 
    106         spinlock_unlock( &process->th_lock );
    107 
    108     sig_dmsg("\n[INFO] %s : Thread %u of process %u has received signal %u. sig_state = %x\n",        \
    109                         __FUNCTION__, thread_current_cpu(thread)->gid,                          \
    110                         process->pid, sig, thread->info.sig_state);
    111 
    112         return 0;
    113 }
    114 
     75}  // end signal_rise()
     76
     77///////////////////////////////////////////
    11578RPC_DECLARE( __signal_rise,                             \
    11679                RPC_RET( RPC_RET_PTR(error_t, err)),    \
     
    183146}
    184147
    185 //////////////////////////////////
    186 error_t signal_rise( pid_t    pid,
    187                      cxy_t    location,
    188                      uint32_t sig)
    189 {
    190         error_t err;
    191 
    192         /* Check location error */
    193         if ( location == CID_NULL )
    194         {
    195                 err = ESRCH;
    196                 printk(WARNING, "%s: there is no process with pid %u\n", \
    197                                 __FUNCTION__, pid);
    198                 return err;
    199         }
    200 
    201         err = EAGAIN;
    202         RCPC( location, RPC_PRIO_SIG_RISE, __signal_rise,       \
    203                         RPC_RECV( RPC_RECV_OBJ(err) ),          \
    204                         RPC_SEND( RPC_SEND_OBJ(pid),            \
    205                                   RPC_SEND_OBJ(sig))            \
    206             );
    207 
    208         return err;
     148///////////////////////////////
     149error_t sys_kill( pid_t    pid,
     150                  uint32_t sig)
     151{
     152    cxy_t       owner_cxy;    // process owner cluster
     153    lpid_t      owner_lpid;   // local process identifier
     154    xptr_t      root_xp;      // extended pointer on root of xlist of process copies
     155    xptr_t      lock_xp;      // extended pointer on remote_spinlock protecting this list
     156    xptr_t      iter_xp;      // iterator for process copies list
     157    xptr_t      process_xp;   // local pointer on process copy
     158    cxy_t       process_cxy;  // cluster of process copy
     159    process_t * process_ptr;  // local pointer on process copy
     160        error_t     error;
     161
     162    // get local pointer on local cluster manager
     163    cluster_t * cluster = LOCAL_CLUSTER;
     164
     165    // get owner process cluster and lpid
     166    owner_cxy  = CXY_FROM_PID( pid );
     167    owner_lpid = LPID_FROM_PID( pid );
     168
     169    // get extended pointers on copies root and lock
     170    root_xp = XPTR( owner_cxy , &cluster->copies_root[lpid] );
     171    lock_xp = XPTR( owner_cxy , &cluster->copies_lock[lpid] );
     172
     173    // take the lock protecting the copies
     174    remote_spinlock_lock( lock_xp );
     175
     176    // TODO the loop below sequencialize the RPCs
     177    // they could be pipelined...
     178 
     179    // traverse the list of copies
     180    XLIST_FOREACH( root_xp , iter_xp )
     181    {
     182        process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
     183        process_cxy = GET_CXY( process_xp );
     184        process_ptr = (process_t *)GET_PTR( process_xp );
     185
     186        if( process_xy == local_cxy )   // process copy is local
     187        {
     188            error = signal_rise( process_ptr , sig );
     189        }
     190        else                           // process copy is remote
     191        {
     192            rpc_signal_rise_client( process_cxy , process_ptr , sig );
     193        }
     194    }
     195
     196        return 0;
    209197}
    210198
Note: See TracChangeset for help on using the changeset viewer.