Changeset 651 for trunk/kernel/kern
- Timestamp:
- Nov 14, 2019, 11:50:09 AM (5 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r647 r651 929 929 /////////////////////////////////////////////////////////////////////////////////////////// 930 930 // This function is the entry point for the kernel initialisation. 931 // It is executed by all cores in all clusters, but only core[ 0] initializes931 // It is executed by all cores in all clusters, but only core[cxy][0] initializes 932 932 // the shared resources such as the cluster manager, or the local peripherals. 933 933 // To comply with the multi-kernels paradigm, it accesses only local cluster memory, using … … 1017 1017 ///////////////////////////////////////////////////////////////////////////////// 1018 1018 1019 // core[0] initialises DQDT (only core[0] in cluster 0build the quad-tree)1019 // core[0] initialises DQDT (only core[0][0] build the quad-tree) 1020 1020 if( core_lid == 0 ) dqdt_init(); 1021 1021 -
trunk/kernel/kern/process.c
r637 r651 916 916 { 917 917 // mark target thread for delete and block it 918 thread_delete( target_xp , process->pid , false ); // notforced918 thread_delete( target_xp , true ); // forced 919 919 } 920 920 } … … 1802 1802 // allocates memory for process descriptor from local cluster 1803 1803 process = process_alloc(); 1804 1805 1806 1804 if( process == NULL ) 1807 1805 { -
trunk/kernel/kern/process.h
r635 r651 122 122 typedef struct process_s 123 123 { 124 125 126 127 128 129 130 124 vmm_t vmm; /*! embedded virtual memory manager */ 125 126 fd_array_t fd_array; /*! embedded open file descriptors array */ 127 128 xptr_t vfs_root_xp; /*! extended pointer on VFS root inode */ 129 xptr_t vfs_bin_xp; /*! extended pointer on .elf file descriptor */ 130 pid_t pid; /*! process identifier */ 131 131 xptr_t ref_xp; /*! extended pointer on reference process */ 132 132 xptr_t owner_xp; /*! extended pointer on owner process */ 133 133 xptr_t parent_xp; /*! extended pointer on parent process */ 134 134 135 136 137 138 135 xptr_t cwd_xp; /*! extended pointer on current working dir inode */ 136 remote_busylock_t cwd_lock; /*! lock protecting working directory changes */ 137 138 xlist_entry_t children_root; /*! root of the children process xlist */ 139 139 remote_queuelock_t children_lock; /*! lock protecting children process xlist */ 140 140 uint32_t children_nr; /*! number of children processes */ 141 141 142 142 xlist_entry_t children_list; /*! member of list of children of same parent */ 143 143 xlist_entry_t local_list; /*! member of list of process in same cluster */ 144 144 xlist_entry_t copies_list; /*! member of list of copies of same process */ 145 145 xlist_entry_t txt_list; /*! member of list of processes sharing same TXT */ 146 146 147 148 149 147 struct thread_s * th_tbl[CONFIG_THREADS_MAX_PER_CLUSTER]; /*! local threads */ 148 149 uint32_t th_nr; /*! number of threads in this cluster */ 150 150 rwlock_t th_lock; /*! lock protecting th_tbl[] i */ 151 151 -
trunk/kernel/kern/scheduler.c
r641 r651 493 493 #endif 494 494 495 // This assert should never be false, as this check has been495 // This assert should always be true, as this check has been 496 496 // done before, by any function that can possibly deschedule... 497 497 assert( (current->busylocks == 0), 498 " unexpected descheduling of thread holding %d busylocks = %d\n", current->busylocks );498 "current thread hold %d busylocks\n", current->busylocks ); 499 499 500 500 // activate or create an RPC thread if RPC_FIFO non empty … … 514 514 "kernel stack overflow for thread %x on core[%x,%d]", next, local_cxy, lid ); 515 515 516 // check next thread attached to same core as the c allingthread516 // check next thread attached to same core as the current thread 517 517 assert( (next->core == current->core), 518 "next core %x != current core %x", next->core, current->core);519 518 "next_core_lid %d / current_core_lid %d", current->core->lid, next->core->lid ); 519 520 520 // check next thread not blocked when type != IDLE 521 521 assert( ((next->blocked == 0) || (next->type == THREAD_IDLE)) , -
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 -
trunk/kernel/kern/thread.h
r647 r651 153 153 remote_busylock_t join_lock; /*! lock protecting the join/exit */ 154 154 xptr_t join_xp; /*! joining/killer thread extended pointer */ 155 void * exit_status; /*! status returned to joiniy thread */ 155 156 156 157 uint32_t * ack_rsp_count; /*! pointer on acknowledge response counter */ … … 392 393 *************************************************************************************** 393 394 * @ thread_xp : extended pointer on the target thread. 394 * @ pid : process identifier (to get the owner cluster identifier).395 395 * @ is_forced : the deletion does not depends on the attached mode. 396 396 **************************************************************************************/ 397 397 void thread_delete( xptr_t thread_xp, 398 pid_t pid,399 398 bool_t is_forced ); 400 399
Note: See TracChangeset
for help on using the changeset viewer.