Ignore:
Timestamp:
Jun 19, 2018, 5:12:57 PM (6 years ago)
Author:
alain
Message:

miscelaneous...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_kill.c

    r440 r446  
    3737              uint32_t sig_id )
    3838{
    39     xptr_t      owner_xp;      // extended pointer on target process in owner cluster
    40     cxy_t       owner_cxy;     // target process in owner cluster
    41     process_t * owner_ptr;     // local pointer on target process in owner cluster
    42     uint32_t    retval;        // return value for the switch
     39    reg_t       save_sr;           // required to enable IRQs
     40    xptr_t      owner_xp;          // extended pointer on process in owner cluster
     41    cxy_t       owner_cxy;         // process owner cluster
     42    process_t * owner_ptr;         // local pointer on process in owner cluster
     43    uint32_t    retval;            // return value for the switch
     44    xptr_t      parent_xp;         // extended pointer on parent process
     45    cxy_t       parent_cxy;        // parent process cluster
     46    process_t * parent_ptr;        // local pointer on parent process
     47    xptr_t      children_lock_xp;  // extended pointer on children lock in parent
     48    thread_t  * parent_main_ptr;   // local pointer on parent main thread
     49    xptr_t      parent_main_xp;    // extended pointer on parent main thread
    4350
    4451    thread_t  * this    = CURRENT_THREAD;
     
    5966    owner_ptr = GET_PTR( owner_xp );
    6067   
     68#if (DEBUG_SYS_KILL & 1)
     69if( DEBUG_SYS_KILL < tm_start )
     70printk("\n[DBG] %s : thread %x found process %x in cluster %x\n",
     71__FUNCTION__ , this, owner_ptr, owner_cxy );
     72#endif
     73
    6174    // check process found
    6275    if( owner_xp == XPTR_NULL)
     
    92105    }
    93106
     107    // get parent process descriptor pointers
     108    parent_xp  = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     109    parent_cxy = GET_CXY( parent_xp );
     110    parent_ptr = GET_PTR( parent_xp );
     111
     112#if (DEBUG_SYS_KILL & 1)
     113if( DEBUG_SYS_KILL < tm_start )
     114printk("\n[DBG] %s : thread %x get parent process %x in cluster %x\n",
     115__FUNCTION__ , this, parent_ptr, parent_cxy );
     116#endif
     117
     118    // get extended pointer on lock protecting children list in parent process
     119    children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );
     120
     121    // get pointers on the parent process main thread
     122    parent_main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );
     123    parent_main_xp  = XPTR( parent_cxy , parent_main_ptr );
     124
    94125    // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL
    95126    switch( sig_id )
     
    108139            process_sigaction( pid , BLOCK_ALL_THREADS );
    109140
    110             // get pointer on target process main thread
     141            // block the main thread
    111142            xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
    112 
    113             // block main thread
    114143            thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
    115144
     
    117146            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    118147                                  PROCESS_TERM_STOP );
     148
     149            // take the children lock and unblock the parent process main thread
     150            remote_spinlock_lock( children_lock_xp );
     151            thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
     152            remote_spinlock_unlock( children_lock_xp );
     153
    119154            retval = 0;
    120155            break;
     
    137172            process_txt_detach( owner_xp );
    138173
    139             // mark for delete all process threads in all clusters, but the main
     174            // mark for delete all threads in all clusters, but the main
     175            hal_enable_irq( &save_sr );
    140176            process_sigaction( pid , DELETE_ALL_THREADS );
    141 
    142             // get pointer on target process main thread
     177            hal_restore_irq( save_sr );
     178
     179            // block main thread
    143180            xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] );
    144 
    145             // block main thread
    146181            thread_block( main_xp , THREAD_BLOCKED_GLOBAL );
    147182
     
    150185            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    151186                                  PROCESS_TERM_KILL );
     187
     188            // take the children lock and unblock the parent process main thread
     189            remote_spinlock_lock( children_lock_xp );
     190            thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
     191            remote_spinlock_unlock( children_lock_xp );
     192
    152193            retval = 0;
    153194            break;
Note: See TracChangeset for help on using the changeset viewer.