Changeset 566 for trunk/kernel/syscalls/sys_thread_join.c
- Timestamp:
- Oct 4, 2018, 11:50:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_thread_join.c
r506 r566 31 31 #include <errno.h> 32 32 #include <printk.h> 33 #include <remote_ spinlock.h>33 #include <remote_busylock.h> 34 34 35 35 #include <syscalls.h> … … 67 67 tm_start = hal_get_cycles(); 68 68 if( DEBUG_SYS_THREAD_JOIN < tm_start ) 69 printk("\n[DBG] %s : parent thread %x enter / process %x / target trdid %x / cycle %d\n",70 __FUNCTION__ , joining_ptr , process->pid, trdid , (uint32_t)tm_start );69 printk("\n[DBG] %s : thread %x in process %x enter / target thread %x / cycle %d\n", 70 __FUNCTION__ , joining_ptr->trdid, process->pid, trdid , (uint32_t)tm_start ); 71 71 #endif 72 72 73 73 // check trdid argument 74 if( (target_ltid >= CONFIG_THREAD _MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) )74 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 75 75 { 76 76 … … 126 126 127 127 // check target thread joinable 128 if( (hal_remote_l w( target_flags_xp ) & THREAD_FLAG_DETACHED) == 0 )128 if( (hal_remote_l32( target_flags_xp ) & THREAD_FLAG_DETACHED) != 0 ) 129 129 { 130 130 … … 140 140 141 141 // get the lock protecting the join in target thread 142 remote_ spinlock_lock( target_join_lock_xp );142 remote_busylock_acquire( target_join_lock_xp ); 143 143 144 144 // test the kill_done flag from the target thread 145 if( hal_remote_lw( target_flags_xp ) & THREAD_FLAG_KILL_DONE ) // killer thread is first 146 { 145 if( hal_remote_l32( target_flags_xp ) & THREAD_FLAG_KILL_DONE ) // killer thread is first 146 { 147 148 #if (DEBUG_SYS_THREAD_JOIN & 1) 149 if( DEBUG_SYS_THREAD_JOIN < tm_start ) 150 printk("\n[DBG] %s : thread %x in process %x / killer thread arrived first\n", 151 __FUNCTION__ , joining_ptr->trdid, process->pid ); 152 #endif 147 153 // get pointers on killer thread 148 killer_xp = (xptr_t)hal_remote_l wd( target_join_xp_xp );154 killer_xp = (xptr_t)hal_remote_l64( target_join_xp_xp ); 149 155 150 156 // reset the kill_done flag in target thread … … 155 161 156 162 // release the lock protecting join 157 remote_ spinlock_unlock( target_join_lock_xp );163 remote_busylock_release( target_join_lock_xp ); 158 164 159 165 // restore IRQs … … 162 168 else // joining thread is first 163 169 { 170 171 #if (DEBUG_SYS_THREAD_JOIN & 1) 172 if( DEBUG_SYS_THREAD_JOIN < tm_start ) 173 printk("\n[DBG] %s : thread %x in process %x / joining thread arrived first\n", 174 __FUNCTION__ , joining_ptr->trdid, process->pid ); 175 #endif 164 176 // set the join_done flag in target thread 165 177 hal_remote_atomic_or( target_flags_xp , THREAD_FLAG_JOIN_DONE ); … … 169 181 170 182 // register the joining thread extended pointer in target thread 171 hal_remote_s wd( target_join_xp_xp , joining_xp );183 hal_remote_s64( target_join_xp_xp , joining_xp ); 172 184 173 185 // release the lock protecting the join 174 remote_spinlock_unlock( target_join_lock_xp ); 175 186 remote_busylock_release( target_join_lock_xp ); 187 188 #if (DEBUG_SYS_THREAD_JOIN & 1) 189 if( DEBUG_SYS_THREAD_JOIN < tm_start ) 190 printk("\n[DBG] %s : thread %x in process %x / joining thread deschedule\n", 191 __FUNCTION__ , joining_ptr->trdid, process->pid ); 192 #endif 176 193 // deschedule 177 194 sched_yield( "joining thread waiting killer thread" ); 178 195 196 #if (DEBUG_SYS_THREAD_JOIN & 1) 197 if( DEBUG_SYS_THREAD_JOIN < tm_start ) 198 printk("\n[DBG] %s : thread %x in process %x / joining thread resume\n", 199 __FUNCTION__ , joining_ptr->trdid, process->pid ); 200 #endif 179 201 // restore IRQs 180 202 hal_restore_irq( save_sr ); … … 184 206 tm_end = hal_get_cycles(); 185 207 if( DEBUG_SYS_THREAD_JOIN < tm_end ) 186 printk("\n[DBG] %s : parent thread %x exit / process %x / target trdid %x / cycle %d\n",187 __FUNCTION__, joining_ptr , process->pid, trdid, (uint32_t)tm_end );208 printk("\n[DBG] %s : thread %x in process %x exit / target thread %x / cycle %d\n", 209 __FUNCTION__, joining_ptr->trdid, process->pid, (uint32_t)tm_end ); 188 210 #endif 189 211
Note: See TracChangeset
for help on using the changeset viewer.