Changeset 651 for trunk/kernel/kern/thread.c
- Timestamp:
- Nov 14, 2019, 11:50:09 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r647 r651 673 673 uint32_t cycle = (uint32_t)hal_get_cycles(); 674 674 if( DEBUG_THREAD_USER_EXEC < cycle ) 675 printk("\n[%s] thread[%x,%x] enter / cycle %d\n",676 __FUNCTION__, process->pid, thread->trdid, cycle );675 printk("\n[%s] thread[%x,%x] enter / entry %x / cycle %d\n", 676 __FUNCTION__, process->pid, thread->trdid, entry_func , cycle ); 677 677 #endif 678 678 … … 1105 1105 ////////////////////////////////////// 1106 1106 void thread_delete( xptr_t target_xp, 1107 pid_t pid,1108 1107 bool_t is_forced ) 1109 1108 { … … 1115 1114 cxy_t target_cxy; // target thread cluster 1116 1115 thread_t * target_ptr; // pointer on target thread 1117 process_t * target_process; // pointer on arget process1116 process_t * target_process; // pointer on target process 1118 1117 pid_t target_pid; // target process identifier 1119 1118 xptr_t target_flags_xp; // extended pointer on target thread <flags> … … 1122 1121 trdid_t target_trdid; // target thread identifier 1123 1122 ltid_t target_ltid; // target thread local index 1123 uint32_t target_flags; // target thread flags 1124 1124 xptr_t joining_xp; // extended pointer on joining thread 1125 thread_t * joining_ptr; // local pointer on joining thread 1126 cxy_t joining_cxy; // joining thread cluster 1125 1127 1126 1128 // get target thread cluster and local pointer … … 1128 1130 target_ptr = GET_PTR( target_xp ); 1129 1131 1130 // get target thread identifier, attached flag, and process PID1132 // get target thread trdid, ltid, flags, and process PID 1131 1133 target_trdid = hal_remote_l32( XPTR( target_cxy , &target_ptr->trdid ) ); 1132 1134 target_ltid = LTID_FROM_TRDID( target_trdid ); 1133 target_flags_xp = XPTR( target_cxy , &target_ptr->flags ); 1134 target_ attached = ( (hal_remote_l32( target_flags_xp ) & THREAD_FLAG_DETACHED) == 0);1135 target_flags_xp = XPTR( target_cxy , &target_ptr->flags ); 1136 target_flags = hal_remote_l32( target_flags_xp ); 1135 1137 target_process = hal_remote_lpt( XPTR( target_cxy , &target_ptr->process ) ); 1136 1138 target_pid = hal_remote_l32( XPTR( target_cxy , &target_process->pid ) ); 1137 1138 // check target PID 1139 assert( (pid == target_pid), 1140 "unconsistent pid and target_xp arguments" ); 1139 target_attached = ((target_flags & THREAD_FLAG_DETACHED) == 0); 1141 1140 1142 1141 // get killer thread pointers … … 1147 1146 uint32_t cycle = (uint32_t)hal_get_cycles(); 1148 1147 if( DEBUG_THREAD_DELETE < cycle ) 1149 printk("\n[%s] killer[%x,%x] enters / target[%x,%x] / cycle %d\n",1148 printk("\n[%s] killer[%x,%x] enters / target[%x,%x] / forced %d / flags %x / cycle %d\n", 1150 1149 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1151 target_p tr->process->pid, target_ptr->trdid, cycle );1150 target_pid, target_trdid, is_forced, target_flags, cycle ); 1152 1151 #endif 1153 1152 1154 1153 // check target thread is not the main thread, because the main thread 1155 1154 // must be deleted by the parent process sys_wait() function 1156 assert( ((CXY_FROM_PID( pid ) != target_cxy) || (target_ltid != 0)),1155 assert( ((CXY_FROM_PID( target_pid ) != target_cxy) || (target_ltid != 0)), 1157 1156 "target thread cannot be the main thread" ); 1158 1157 … … 1182 1181 // get extended pointer on joining thread 1183 1182 joining_xp = (xptr_t)hal_remote_l64( target_join_xp_xp ); 1183 1184 // get cluster and local pointer on joining thread 1185 joining_ptr = GET_PTR( joining_xp ); 1186 joining_cxy = GET_CXY( joining_xp ); 1187 1188 // copy exit_status from target thread to joining thread, because 1189 // target thread may be deleted before joining thread resume 1190 void * status = hal_remote_lpt( XPTR( target_cxy , &target_ptr->exit_status ) ); 1191 hal_remote_spt( XPTR( joining_cxy , &joining_ptr->exit_status ) , status ); 1184 1192 1185 1193 // reset the join_done flag in target thread … … 1202 1210 1203 1211 #if DEBUG_THREAD_DELETE 1204 cycle = (uint32_t)hal_get_cycles ;1212 cycle = (uint32_t)hal_get_cycles(); 1205 1213 if( DEBUG_THREAD_DELETE < cycle ) 1206 1214 printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n", 1207 1215 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1208 target_p tr->process->pid, target_ptr->trdid, cycle );1216 target_pid, target_trdid, cycle ); 1209 1217 #endif 1210 1218 … … 1215 1223 hal_remote_atomic_or( target_flags_xp , THREAD_FLAG_KILL_DONE ); 1216 1224 1217 // block t histhread on BLOCKED_JOIN1225 // block target thread on BLOCKED_JOIN 1218 1226 thread_block( killer_xp , THREAD_BLOCKED_JOIN ); 1219 1227 … … 1225 1233 1226 1234 #if DEBUG_THREAD_DELETE 1227 cycle = (uint32_t)hal_get_cycles ;1235 cycle = (uint32_t)hal_get_cycles(); 1228 1236 if( DEBUG_THREAD_DELETE < cycle ) 1229 1237 printk("\n[%s] killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n", 1230 1238 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1231 target_p tr->process->pid, target_ptr->trdid, cycle );1239 target_pid, target_trdid, cycle ); 1232 1240 #endif 1233 1241 // deschedule … … 1244 1252 1245 1253 #if DEBUG_THREAD_DELETE 1246 cycle = (uint32_t)hal_get_cycles ;1254 cycle = (uint32_t)hal_get_cycles(); 1247 1255 if( DEBUG_THREAD_DELETE < cycle ) 1248 1256 printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n", 1249 1257 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1250 target_p tr->process->pid, target_ptr->trdid, cycle );1258 target_pid, target_trdid, cycle ); 1251 1259 #endif 1252 1260 … … 1262 1270 1263 1271 #if DEBUG_THREAD_DELETE 1264 cycle = (uint32_t)hal_get_cycles ;1272 cycle = (uint32_t)hal_get_cycles(); 1265 1273 if( DEBUG_THREAD_DELETE < cycle ) 1266 1274 printk("\n[%s] killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n", 1267 1275 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1268 target_p tr->process->pid, target_ptr->trdid, cycle );1276 target_pid, target_trdid, cycle ); 1269 1277 #endif 1270 1278
Note: See TracChangeset
for help on using the changeset viewer.