Changeset 446 for trunk/kernel/syscalls/sys_kill.c
- Timestamp:
- Jun 19, 2018, 5:12:57 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_kill.c
r440 r446 37 37 uint32_t sig_id ) 38 38 { 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 43 50 44 51 thread_t * this = CURRENT_THREAD; … … 59 66 owner_ptr = GET_PTR( owner_xp ); 60 67 68 #if (DEBUG_SYS_KILL & 1) 69 if( DEBUG_SYS_KILL < tm_start ) 70 printk("\n[DBG] %s : thread %x found process %x in cluster %x\n", 71 __FUNCTION__ , this, owner_ptr, owner_cxy ); 72 #endif 73 61 74 // check process found 62 75 if( owner_xp == XPTR_NULL) … … 92 105 } 93 106 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) 113 if( DEBUG_SYS_KILL < tm_start ) 114 printk("\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 94 125 // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 95 126 switch( sig_id ) … … 108 139 process_sigaction( pid , BLOCK_ALL_THREADS ); 109 140 110 // get pointer on target processmain thread141 // block the main thread 111 142 xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] ); 112 113 // block main thread114 143 thread_block( main_xp , THREAD_BLOCKED_GLOBAL ); 115 144 … … 117 146 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 118 147 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 119 154 retval = 0; 120 155 break; … … 137 172 process_txt_detach( owner_xp ); 138 173 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 ); 140 176 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 143 180 xptr_t main_xp = XPTR( owner_cxy , &owner_ptr->th_tbl[0] ); 144 145 // block main thread146 181 thread_block( main_xp , THREAD_BLOCKED_GLOBAL ); 147 182 … … 150 185 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 151 186 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 152 193 retval = 0; 153 194 break;
Note: See TracChangeset
for help on using the changeset viewer.