Changeset 593 for trunk/kernel/kern/thread.c
- Timestamp:
- Nov 10, 2018, 2:16:38 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r583 r593 124 124 // It updates the local DQDT. 125 125 ///////////////////////////////////////////////////////////////////////////////////// 126 // @ thread : pointer on thread descriptor127 // @ process : pointer on process descriptor.126 // @ thread : pointer on local thread descriptor 127 // @ process : pointer on local process descriptor. 128 128 // @ type : thread type. 129 129 // @ func : pointer on thread entry function. … … 148 148 149 149 #if DEBUG_THREAD_INIT 150 uint32_t cycle = (uint32_t)hal_get_cycles(); 150 uint32_t cycle = (uint32_t)hal_get_cycles(); 151 thread_t * this = CURRENT_THREAD; 151 152 if( DEBUG_THREAD_INIT < cycle ) 152 printk("\n[DBG] %s : thread %x in process %x enter fot thread %x in process %x / cycle %d\n", 153 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 154 thread, process->pid , cycle ); 153 printk("\n[%s] thread[%x,%x] enter for thread %x in process %x / cycle %d\n", 154 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid , cycle ); 155 155 #endif 156 156 … … 229 229 cycle = (uint32_t)hal_get_cycles(); 230 230 if( DEBUG_THREAD_INIT < cycle ) 231 printk("\n[DBG] %s : thread %x in process %x exit for thread %x in process %x / cycle %d\n", 232 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 233 thread, process->pid , cycle ); 231 printk("\n[%s] thread[%x,%x] exit for thread %x in process %x / cycle %d\n", 232 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle ); 234 233 #endif 235 234 … … 251 250 vseg_t * vseg; // stack vseg 252 251 253 252 assert( (attr != NULL) , "pthread attributes must be defined" ); 254 253 255 254 #if DEBUG_THREAD_USER_CREATE 256 uint32_t cycle = (uint32_t)hal_get_cycles(); 255 thread_t * this = CURRENT_THREAD; 256 uint32_t cycle = (uint32_t)hal_get_cycles(); 257 257 if( DEBUG_THREAD_USER_CREATE < cycle ) 258 printk("\n[ DBG] %s : thread %x in process %x enter in cluster%x / cycle %d\n",259 __FUNCTION__, CURRENT_THREAD->trdid, pid , local_cxy, cycle );258 printk("\n[%s] thread[%x,%x] enter in cluster %x for process %x / cycle %d\n", 259 __FUNCTION__, this->process->pid , this->trdid , local_cxy , pid , cycle ); 260 260 #endif 261 261 … … 272 272 #if( DEBUG_THREAD_USER_CREATE & 1) 273 273 if( DEBUG_THREAD_USER_CREATE < cycle ) 274 printk("\n[ DBG] %s :process descriptor = %x for process %x in cluster %x\n",274 printk("\n[%s] process descriptor = %x for process %x in cluster %x\n", 275 275 __FUNCTION__, process , pid , local_cxy ); 276 276 #endif … … 294 294 #if( DEBUG_THREAD_USER_CREATE & 1) 295 295 if( DEBUG_THREAD_USER_CREATE < cycle ) 296 printk("\n[ DBG] %s :core[%x,%d] selected\n",296 printk("\n[%s] core[%x,%d] selected\n", 297 297 __FUNCTION__, local_cxy , core_lid ); 298 298 #endif … … 316 316 #if( DEBUG_THREAD_USER_CREATE & 1) 317 317 if( DEBUG_THREAD_USER_CREATE < cycle ) 318 printk("\n[ DBG] %s :stack vseg created / vpn_base %x / %d pages\n",318 printk("\n[%s] stack vseg created / vpn_base %x / %d pages\n", 319 319 __FUNCTION__, vseg->vpn_base, vseg->vpn_size ); 320 320 #endif … … 332 332 #if( DEBUG_THREAD_USER_CREATE & 1) 333 333 if( DEBUG_THREAD_USER_CREATE < cycle ) 334 printk("\n[ DBG] %s :new thread descriptor %x allocated\n",334 printk("\n[%s] new thread descriptor %x allocated\n", 335 335 __FUNCTION__, thread ); 336 336 #endif … … 355 355 #if( DEBUG_THREAD_USER_CREATE & 1) 356 356 if( DEBUG_THREAD_USER_CREATE < cycle ) 357 printk("\n[ DBG] %s :new thread descriptor initialised / trdid %x\n",357 printk("\n[%s] new thread descriptor initialised / trdid %x\n", 358 358 __FUNCTION__, thread->trdid ); 359 359 #endif … … 387 387 #if( DEBUG_THREAD_USER_CREATE & 1) 388 388 if( DEBUG_THREAD_USER_CREATE < cycle ) 389 printk("\n[ DBG] %s :CPU & FPU contexts created\n",389 printk("\n[%s] CPU & FPU contexts created\n", 390 390 __FUNCTION__, thread->trdid ); 391 391 vmm_display( process , true ); … … 395 395 cycle = (uint32_t)hal_get_cycles(); 396 396 if( DEBUG_THREAD_USER_CREATE < cycle ) 397 printk("\n[ DBG] %s : thread %x in process %xexit / new_thread %x / core %d / cycle %d\n",398 __FUNCTION__, CURRENT_THREAD->trdid , pid, thread->trdid, core_lid, cycle );397 printk("\n[%s] thread[%x,%x] exit / new_thread %x / core %d / cycle %d\n", 398 __FUNCTION__, this->process->pid , this->trdid , thread->trdid, core_lid, cycle ); 399 399 #endif 400 400 … … 430 430 431 431 #if DEBUG_THREAD_USER_FORK 432 uint32_t cycle = (uint32_t)hal_get_cycles(); 432 uint32_t cycle = (uint32_t)hal_get_cycles(); 433 thread_t * this = CURRENT_THREAD; 433 434 if( DEBUG_THREAD_USER_FORK < cycle ) 434 printk("\n[ DBG] %s : thread %x in process %xenter / child_process %x / cycle %d\n",435 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_process->pid, cycle );435 printk("\n[%s] thread[%x,%x] enter / child_process %x / cycle %d\n", 436 __FUNCTION__, this->process->pid, this->trdid, child_process->pid, cycle ); 436 437 #endif 437 438 … … 487 488 #if (DEBUG_THREAD_USER_FORK & 1) 488 489 if( DEBUG_THREAD_USER_FORK < cycle ) 489 printk("\n[DBG] %s : thread %x in process %x / initialised thread %x in process %x\n", 490 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 491 child_ptr->trdid, child_process->pid ); 490 printk("\n[%s] thread[%x,%x] initialised thread %x in process %x\n", 491 __FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid ); 492 492 #endif 493 493 … … 522 522 #if (DEBUG_THREAD_USER_FORK & 1) 523 523 if( DEBUG_THREAD_USER_FORK < cycle ) 524 printk("\n[ DBG] %s : thread %x in process %x / created CPU & FPU contexts\n",525 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );524 printk("\n[%s] thread[%x,%x] created CPU & FPU contexts for thread %x in process %x\n", 525 __FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid ); 526 526 #endif 527 527 … … 542 542 #if (DEBUG_THREAD_USER_FORK & 1) 543 543 if( DEBUG_THREAD_USER_FORK < cycle ) 544 printk("\n[ DBG] %s : thread %x in process %x / created stack vseg\n",545 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );544 printk("\n[%s] thread[%x,%x] created stack vseg for thread %x in process %x\n", 545 __FUNCTION__, this->process->pid, this->trdid, child_ptr->trdid, child_process->pid ); 546 546 #endif 547 547 … … 591 591 cycle = (uint32_t)hal_get_cycles(); 592 592 if( DEBUG_THREAD_USER_FORK < cycle ) 593 printk("\n[ DBG] %s : thread %x in process %xcopied one PTE to child GPT : vpn %x / forks %d\n",594 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, vpn,595 hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) );593 printk("\n[%s] thread[%x,%x] copied one PTE to child GPT : vpn %x / forks %d\n", 594 __FUNCTION__, this->process->pid, this->trdid, 595 vpn, hal_remote_l32( XPTR( page_cxy , &page_ptr->forks) ) ); 596 596 #endif 597 597 … … 607 607 cycle = (uint32_t)hal_get_cycles(); 608 608 if( DEBUG_THREAD_USER_FORK < cycle ) 609 printk("\n[ DBG] %s : thread %x in process %xexit / child_thread %x / cycle %d\n",610 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, child_ptr, cycle );609 printk("\n[%s] thread[%x,%x] exit / child_thread %x / cycle %d\n", 610 __FUNCTION__, this->process->pid, this->trdid, child_ptr, cycle ); 611 611 #endif 612 612 … … 626 626 uint32_t cycle = (uint32_t)hal_get_cycles(); 627 627 if( DEBUG_THREAD_USER_EXEC < cycle ) 628 printk("\n[ DBG] %s : thread %x in process %xenter / cycle %d\n",629 __FUNCTION__, thread->trdid, process->pid, cycle );628 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", 629 __FUNCTION__, process->pid, thread->trdid, cycle ); 630 630 #endif 631 631 … … 688 688 cycle = (uint32_t)hal_get_cycles(); 689 689 if( DEBUG_THREAD_USER_EXEC < cycle ) 690 printk("\n[ DBG] %s : thread %x in process %xset CPU context & jump to user code / cycle %d\n",691 __FUNCTION__, thread->trdid, process->pid, cycle );690 printk("\n[%s] thread[%x,%x] set CPU context & jump to user code / cycle %d\n", 691 __FUNCTION__, process->pid, thread->trdid, cycle ); 692 692 vmm_display( process , true ); 693 693 #endif … … 712 712 thread_t * thread; // pointer on new thread descriptor 713 713 714 assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) , 715 "illegal thread type" ); 716 717 assert( (core_lid < LOCAL_CLUSTER->cores_nr) , 718 "illegal core_lid" ); 714 thread_t * this = CURRENT_THREAD; 715 716 assert( ( (type == THREAD_IDLE) || (type == THREAD_RPC) || (type == THREAD_DEV) ) , 717 "illegal thread type" ); 718 719 assert( (core_lid < LOCAL_CLUSTER->cores_nr) , 720 "illegal core_lid" ); 719 721 720 722 #if DEBUG_THREAD_KERNEL_CREATE 721 uint32_t cycle = (uint32_t)hal_get_cycles();723 uint32_t cycle = (uint32_t)hal_get_cycles(); 722 724 if( DEBUG_THREAD_KERNEL_CREATE < cycle ) 723 printk("\n[ DBG] %s : thread %xenter / requested_type %s / cycle %d\n",724 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );725 printk("\n[%s] thread[%x,%x] enter / requested_type %s / cycle %d\n", 726 __FUNCTION__, this->process->pid, this->trdid, thread_type_str(type), cycle ); 725 727 #endif 726 728 … … 732 734 printk("\n[ERROR] in %s : thread %x in process %x\n" 733 735 " no memory for thread descriptor\n", 734 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );736 __FUNCTION__, this->trdid, this->process->pid ); 735 737 return ENOMEM; 736 738 } … … 749 751 printk("\n[ERROR] in %s : thread %x in process %x\n" 750 752 " cannot initialize thread descriptor\n", 751 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );753 __FUNCTION__, this->trdid, this->process->pid ); 752 754 thread_release( thread ); 753 755 return ENOMEM; … … 760 762 { 761 763 printk("\n[ERROR] in %s : thread %x in process %x\n" 762 " cannotcannot create CPU context\n",763 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );764 " cannot create CPU context\n", 765 __FUNCTION__, this->trdid, this->process->pid ); 764 766 thread_release( thread ); 765 767 return EINVAL; … … 774 776 cycle = (uint32_t)hal_get_cycles(); 775 777 if( DEBUG_THREAD_KERNEL_CREATE < cycle ) 776 printk("\n[ DBG] %s : thread %xexit / new_thread %x / type %s / cycle %d\n",777 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle );778 printk("\n[%s] thread[%x,%x] exit / new_thread %x / type %s / cycle %d\n", 779 __FUNCTION__, this->process->pid, this->trdid, thread, thread_type_str(type), cycle ); 778 780 #endif 779 781 … … 830 832 thread_t * this = CURRENT_THREAD; 831 833 if( DEBUG_THREAD_DESTROY < cycle ) 832 printk("\n[ DBG] %s :thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n",834 printk("\n[%s] thread[%x,%x] enter to destroy thread[%x,%x] / cycle %d\n", 833 835 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 834 836 #endif … … 862 864 cycle = (uint32_t)hal_get_cycles(); 863 865 if( DEBUG_THREAD_DESTROY < cycle ) 864 printk("\n[ DBG] %s :thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n",866 printk("\n[%s] thread[%x,%x] exit / destroyed thread[%x,%x] / cycle %d\n", 865 867 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 866 868 #endif … … 944 946 uint32_t cycle = (uint32_t)hal_get_cycles(); 945 947 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) ); 948 thread_t * this = CURRENT_THREAD; 946 949 if( DEBUG_THREAD_BLOCK < cycle ) 947 printk("\n[ DBG] %s : thread %x in process %xblocked thread %x in process %x / cause %x\n",948 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,950 printk("\n[%s] thread[%x,%x] blocked thread %x in process %x / cause %x\n", 951 __FUNCTION__, this->process->pid, this->trdid, 949 952 ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause ); 950 953 #endif … … 967 970 uint32_t cycle = (uint32_t)hal_get_cycles(); 968 971 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) ); 972 thread_t * this = CURRENT_THREAD; 969 973 if( DEBUG_THREAD_BLOCK < cycle ) 970 printk("\n[ DBG] %s : thread %x in process %xunblocked thread %x in process %x / cause %x\n",971 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid,974 printk("\n[%s] thread[%x,%x] unblocked thread %x in process %x / cause %x\n", 975 __FUNCTION__, this->process->pid, this->trdid, 972 976 ptr->trdid, hal_remote_l32(XPTR( cxy , &process->pid )), cause ); 973 977 #endif … … 1016 1020 uint32_t cycle = (uint32_t)hal_get_cycles(); 1017 1021 if( DEBUG_THREAD_DELETE < cycle ) 1018 printk("\n[ DBG] %s :killer[%x,%x] enters / target[%x,%x] / cycle %d\n",1022 printk("\n[%s] killer[%x,%x] enters / target[%x,%x] / cycle %d\n", 1019 1023 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1020 1024 target_ptr->process->pid, target_ptr->trdid, cycle ); … … 1075 1079 cycle = (uint32_t)hal_get_cycles; 1076 1080 if( DEBUG_THREAD_DELETE < cycle ) 1077 printk("\n[ DBG] %s :killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",1081 printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n", 1078 1082 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1079 1083 target_ptr->process->pid, target_ptr->trdid, cycle ); … … 1098 1102 cycle = (uint32_t)hal_get_cycles; 1099 1103 if( DEBUG_THREAD_DELETE < cycle ) 1100 printk("\n[ DBG] %s :killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n",1104 printk("\n[%s] killer[%x,%x] deschedules / target[%x,%x] not completed / cycle %d\n", 1101 1105 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1102 1106 target_ptr->process->pid, target_ptr->trdid, cycle ); … … 1117 1121 cycle = (uint32_t)hal_get_cycles; 1118 1122 if( DEBUG_THREAD_DELETE < cycle ) 1119 printk("\n[ DBG] %s :killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n",1123 printk("\n[%s] killer[%x,%x] exit / target[%x,%x] marked after join / cycle %d\n", 1120 1124 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1121 1125 target_ptr->process->pid, target_ptr->trdid, cycle ); … … 1135 1139 cycle = (uint32_t)hal_get_cycles; 1136 1140 if( DEBUG_THREAD_DELETE < cycle ) 1137 printk("\n[ DBG] %s :killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n",1141 printk("\n[%s] killer[%x,%x] exit / target [%x,%x] marked / no join / cycle %d\n", 1138 1142 __FUNCTION__, killer_ptr->process->pid, killer_ptr->trdid, 1139 1143 target_ptr->process->pid, target_ptr->trdid, cycle ); … … 1141 1145 1142 1146 } 1143 1144 1147 } // end thread_delete() 1145 1148 … … 1162 1165 uint32_t cycle = (uint32_t)hal_get_cycles(); 1163 1166 if( DEBUG_THREAD_IDLE < cycle ) 1164 printk("\n[ DBG] %s :idle thread on core[%x,%d] goes to sleep / cycle %d\n",1167 printk("\n[%s] idle thread on core[%x,%d] goes to sleep / cycle %d\n", 1165 1168 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle ); 1166 1169 } … … 1173 1176 uint32_t cycle = (uint32_t)hal_get_cycles(); 1174 1177 if( DEBUG_THREAD_IDLE < cycle ) 1175 printk("\n[ DBG] %s :idle thread on core[%x,%d] wake up / cycle %d\n",1178 printk("\n[%s] idle thread on core[%x,%d] wake up / cycle %d\n", 1176 1179 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle ); 1177 1180 } … … 1237 1240 thread_t * this = CURRENT_THREAD; 1238 1241 if( DEBUG_THREAD_GET_XPTR < cycle ) 1239 printk("\n[ DBG] %s :thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",1242 printk("\n[%s] thread %x in process %x enters / pid %x / trdid %x / cycle %d\n", 1240 1243 __FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle ); 1241 1244 #endif … … 1262 1265 #if( DEBUG_THREAD_GET_XPTR & 1 ) 1263 1266 if( DEBUG_THREAD_GET_XPTR < cycle ) 1264 printk("\n[ DBG] %s :scan processes in cluster %x :\n", __FUNCTION__, target_cxy );1267 printk("\n[%s] scan processes in cluster %x :\n", __FUNCTION__, target_cxy ); 1265 1268 #endif 1266 1269 … … 1295 1298 #if( DEBUG_THREAD_GET_XPTR & 1 ) 1296 1299 if( DEBUG_THREAD_GET_XPTR < cycle ) 1297 printk("\n[ DBG] %s :pid %x not found in cluster %x\n",1300 printk("\n[%s] pid %x not found in cluster %x\n", 1298 1301 __FUNCTION__, pid, target_cxy ); 1299 1302 #endif … … 1310 1313 #if( DEBUG_THREAD_GET_XPTR & 1 ) 1311 1314 if( DEBUG_THREAD_GET_XPTR < cycle ) 1312 printk("\n[ DBG] %s :thread %x not registered in process %x in cluster %x\n",1315 printk("\n[%s] thread %x not registered in process %x in cluster %x\n", 1313 1316 __FUNCTION__, trdid, pid, target_cxy ); 1314 1317 #endif … … 1319 1322 cycle = (uint32_t)hal_get_cycles(); 1320 1323 if( DEBUG_THREAD_GET_XPTR < cycle ) 1321 printk("\n[ DBG] %s :thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",1324 printk("\n[%s] thread %x in process %x exit / pid %x / trdid %x / cycle %d\n", 1322 1325 __FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle ); 1323 1326 #endif … … 1347 1350 1348 1351 // display error message on TXT0 1349 nolock_printk("\n[PANIC] in %s / thread %x in process %x [%x] cannot yield : "1352 nolock_printk("\n[PANIC] in %s / thread[%x,%x] cannot yield : " 1350 1353 "hold %d busylock(s) / cycle %d\n", 1351 func_str, thread-> trdid, thread->process->pid, thread,1354 func_str, thread->process->pid, thread->trdid, 1352 1355 thread->busylocks, (uint32_t)hal_get_cycles() ); 1353 1356
Note: See TracChangeset
for help on using the changeset viewer.