Changeset 438 for trunk/kernel/kern/thread.c
- Timestamp:
- Apr 4, 2018, 2:49:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r436 r438 112 112 ///////////////////////////////////////////////////////////////////////////////////// 113 113 // This static function initializes a thread descriptor (kernel or user). 114 // It can be called by the threefunctions:114 // It can be called by the four functions: 115 115 // - thread_user_create() 116 116 // - thread_user_fork() 117 117 // - thread_kernel_create() 118 // - thread_idle_init() 119 // It updates the local DQDT. 118 120 ///////////////////////////////////////////////////////////////////////////////////// 119 121 // @ thread : pointer on thread descriptor … … 202 204 thread->save_sr = 0xFF13; 203 205 204 // update local DQDT205 dqdt_local_update_threads( 1 );206 207 206 // register new thread in core scheduler 208 207 sched_register_thread( thread->core , thread ); 208 209 // update DQDT 210 dqdt_update_threads( 1 ); 209 211 210 212 return 0; … … 227 229 assert( (attr != NULL) , __FUNCTION__, "pthread attributes must be defined" ); 228 230 229 #if CONFIG_DEBUG_THREAD_USER_CREATE231 #if DEBUG_THREAD_USER_CREATE 230 232 uint32_t cycle = (uint32_t)hal_get_cycles(); 231 if( CONFIG_DEBUG_THREAD_USER_CREATE < cycle )233 if( DEBUG_THREAD_USER_CREATE < cycle ) 232 234 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 233 235 __FUNCTION__, CURRENT_THREAD, pid , cycle ); … … 326 328 } 327 329 328 // update DQDT for new thread 329 dqdt_local_update_threads( 1 ); 330 331 #if CONFIG_DEBUG_THREAD_USER_CREATE 330 #if DEBUG_THREAD_USER_CREATE 332 331 cycle = (uint32_t)hal_get_cycles(); 333 if( CONFIG_DEBUG_THREAD_USER_CREATE < cycle )332 if( DEBUG_THREAD_USER_CREATE < cycle ) 334 333 printk("\n[DBG] %s : thread %x exit / process %x / new_thread %x / core %d / cycle %d\n", 335 334 __FUNCTION__, CURRENT_THREAD, pid, thread, core_lid, cycle ); … … 366 365 vseg_t * vseg; // child thread STACK vseg 367 366 368 #if CONFIG_DEBUG_THREAD_USER_FORK367 #if DEBUG_THREAD_USER_FORK 369 368 uint32_t cycle = (uint32_t)hal_get_cycles(); 370 if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )369 if( DEBUG_THREAD_USER_FORK < cycle ) 371 370 printk("\n[DBG] %s : thread %x enter / child_process %x / cycle %d\n", 372 371 __FUNCTION__, CURRENT_THREAD, child_process->pid, cycle ); … … 493 492 hal_remote_atomic_add( XPTR( page_cxy , &page_ptr->forks ) , 1 ); 494 493 495 #if ( CONFIG_DEBUG_THREAD_USER_FORK & 1)494 #if (DEBUG_THREAD_USER_FORK & 1) 496 495 cycle = (uint32_t)hal_get_cycles(); 497 if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )496 if( DEBUG_THREAD_USER_FORK < cycle ) 498 497 printk("\n[DBG] %s : thread %x copied stack PTE to child GPT : vpn %x\n", 499 498 __FUNCTION__, CURRENT_THREAD, vpn ); … … 508 507 vpn_size ); 509 508 510 // update DQDT for child thread 511 dqdt_local_update_threads( 1 ); 512 513 #if CONFIG_DEBUG_THREAD_USER_FORK 509 #if DEBUG_THREAD_USER_FORK 514 510 cycle = (uint32_t)hal_get_cycles(); 515 if( CONFIG_DEBUG_THREAD_USER_FORK < cycle )511 if( DEBUG_THREAD_USER_FORK < cycle ) 516 512 printk("\n[DBG] %s : thread %x exit / child_process %x / child_thread %x / cycle %d\n", 517 513 __FUNCTION__, CURRENT_THREAD, child_process->pid, child_ptr, cycle ); … … 538 534 __FUNCTION__ , "illegal core_lid" ); 539 535 540 #if CONFIG_DEBUG_THREAD_KERNEL_CREATE536 #if DEBUG_THREAD_KERNEL_CREATE 541 537 uint32_t cycle = (uint32_t)hal_get_cycles(); 542 if( CONFIG_DEBUG_THREAD_KERNEL_CREATE < cycle )538 if( DEBUG_THREAD_KERNEL_CREATE < cycle ) 543 539 printk("\n[DBG] %s : thread %x enter / requested_type %s / cycle %d\n", 544 540 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle ); … … 568 564 hal_cpu_context_create( thread ); 569 565 570 // update DQDT for kernel thread 571 dqdt_local_update_threads( 1 ); 572 573 #if CONFIG_DEBUG_THREAD_KERNEL_CREATE 566 #if DEBUG_THREAD_KERNEL_CREATE 574 567 cycle = (uint32_t)hal_get_cycles(); 575 if( CONFIG_DEBUG_THREAD_KERNEL_CREATE < cycle )568 if( DEBUG_THREAD_KERNEL_CREATE < cycle ) 576 569 printk("\n[DBG] %s : thread %x exit / new_thread %x / type %s / cycle %d\n", 577 570 __FUNCTION__, CURRENT_THREAD, thread, thread_type_str(type), cycle ); … … 583 576 } // end thread_kernel_create() 584 577 585 ///////////////////////////////////////////////// //586 error_t thread_ kernel_init( thread_t * thread,587 588 589 590 578 ///////////////////////////////////////////////// 579 error_t thread_idle_init( thread_t * thread, 580 thread_type_t type, 581 void * func, 582 void * args, 583 lid_t core_lid ) 591 584 { 592 585 assert( (type == THREAD_IDLE) , __FUNCTION__ , "illegal thread type" ); … … 607 600 return error; 608 601 609 } // end thread_ kernel_init()602 } // end thread_idle_init() 610 603 611 604 /////////////////////////////////////////////////////////////////////////////////////// … … 620 613 core_t * core = thread->core; 621 614 622 #if CONFIG_DEBUG_THREAD_DESTROY615 #if DEBUG_THREAD_DESTROY 623 616 uint32_t cycle = (uint32_t)hal_get_cycles(); 624 if( CONFIG_DEBUG_THREAD_DESTROY < cycle )617 if( DEBUG_THREAD_DESTROY < cycle ) 625 618 printk("\n[DBG] %s : thread %x enter to destroy thread %x in process %x / cycle %d\n", 626 619 __FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle ); … … 652 645 process_remove_thread( thread ); 653 646 654 // update localDQDT655 dqdt_ local_update_threads( -1 );647 // update DQDT 648 dqdt_update_threads( -1 ); 656 649 657 650 // invalidate thread descriptor … … 661 654 thread_release( thread ); 662 655 663 #if CONFIG_DEBUG_THREAD_DESTROY656 #if DEBUG_THREAD_DESTROY 664 657 cycle = (uint32_t)hal_get_cycles(); 665 if( CONFIG_DEBUG_THREAD_DESTROY < cycle )658 if( DEBUG_THREAD_DESTROY < cycle ) 666 659 printk("\n[DBG] %s : thread %x exit / destroyed thread %x in process %x / cycle %d\n", 667 660 __FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle ); … … 811 804 hal_fence(); 812 805 813 #if CONFIG_DEBUG_THREAD_BLOCK806 #if DEBUG_THREAD_BLOCK 814 807 uint32_t cycle = (uint32_t)hal_get_cycles(); 815 if( CONFIG_DEBUG_THREAD_BLOCK < cycle )808 if( DEBUG_THREAD_BLOCK < cycle ) 816 809 printk("\n[DBG] %s : thread %x blocked thread %x / cause %x / cycle %d\n", 817 810 __FUNCTION__ , CURRENT_THREAD , ptr , cause , cycle ); 818 811 #endif 819 812 820 #if ( CONFIG_DEBUG_THREAD_BLOCK & 1)821 if( CONFIG_DEBUG_THREAD_BLOCK < cycle )813 #if (DEBUG_THREAD_BLOCK & 1) 814 if( DEBUG_THREAD_BLOCK < cycle ) 822 815 sched_display( ptr->core->lid ); 823 816 #endif … … 837 830 hal_fence(); 838 831 839 #if CONFIG_DEBUG_THREAD_BLOCK832 #if DEBUG_THREAD_BLOCK 840 833 uint32_t cycle = (uint32_t)hal_get_cycles(); 841 if( CONFIG_DEBUG_THREAD_BLOCK < cycle )834 if( DEBUG_THREAD_BLOCK < cycle ) 842 835 printk("\n[DBG] %s : thread %x unblocked thread %x / cause %x / cycle %d\n", 843 836 __FUNCTION__ , CURRENT_THREAD , ptr , cause , cycle ); 844 837 #endif 845 838 846 #if ( CONFIG_DEBUG_THREAD_BLOCK & 1)847 if( CONFIG_DEBUG_THREAD_BLOCK < cycle )839 #if (DEBUG_THREAD_BLOCK & 1) 840 if( DEBUG_THREAD_BLOCK < cycle ) 848 841 sched_display( ptr->core->lid ); 849 842 #endif … … 890 883 killer_xp = XPTR( local_cxy , killer_ptr ); 891 884 892 #if CONFIG_DEBUG_THREAD_KILL885 #if DEBUG_THREAD_KILL 893 886 uint32_t cycle = (uint32_t)hal_get_cycles; 894 if( CONFIG_DEBUG_THREAD_KILL < cycle )887 if( DEBUG_THREAD_KILL < cycle ) 895 888 printk("\n[DBG] %s : thread %x enter for target thread %x / cycle %d\n", 896 889 __FUNCTION__, killer_ptr, target_ptr, cycle ); … … 989 982 else hal_remote_atomic_or( process_state_xp , PROCESS_TERM_KILL ); 990 983 991 #if CONFIG_DEBUG_THREAD_KILL984 #if DEBUG_THREAD_KILL 992 985 cycle = (uint32_t)hal_get_cycles; 993 if( CONFIG_DEBUG_THREAD_KILL < cycle )986 if( DEBUG_THREAD_KILL < cycle ) 994 987 printk("\n[DBG] %s : thread %x exit for thread %x / main thread / cycle %d\n", 995 988 __FUNCTION__, killer_ptr, target_ptr, cycle ); … … 1002 995 hal_remote_atomic_or( target_flags_xp , THREAD_FLAG_REQ_DELETE ); 1003 996 1004 #if CONFIG_DEBUG_THREAD_KILL997 #if DEBUG_THREAD_KILL 1005 998 cycle = (uint32_t)hal_get_cycles; 1006 if( CONFIG_DEBUG_THREAD_KILL < cycle )999 if( DEBUG_THREAD_KILL < cycle ) 1007 1000 printk("\n[DBG] %s : thread %x exit for thread %x / not the main thread / cycle %d\n", 1008 1001 __FUNCTION__, killer_ptr, target_ptr, cycle ); … … 1024 1017 { 1025 1018 1026 #if CONFIG_DEBUG_THREAD_IDLE1019 #if DEBUG_THREAD_IDLE 1027 1020 uint32_t cycle = (uint32_t)hal_get_cycles; 1028 1021 thread_t * this = CURRENT_THREAD; 1029 if( CONFIG_DEBUG_THREAD_IDLE < cycle )1022 if( DEBUG_THREAD_IDLE < cycle ) 1030 1023 printk("\n[DBG] %s : idle thread %x on core[%x,%d] goes to sleep / cycle %d\n", 1031 1024 __FUNCTION__, this, local_cxy, this->core->lid, cycle ); … … 1034 1027 hal_core_sleep(); 1035 1028 1036 #if CONFIG_DEBUG_THREAD_IDLE1029 #if DEBUG_THREAD_IDLE 1037 1030 cycle = (uint32_t)hal_get_cycles; 1038 if( CONFIG_DEBUG_THREAD_IDLE < cycle )1031 if( DEBUG_THREAD_IDLE < cycle ) 1039 1032 printk("\n[DBG] %s : idle thread %x on core[%x,%d] wake up / cycle %d\n", 1040 1033 __FUNCTION__, this, local_cxy, this->core->lid, cycle );
Note: See TracChangeset
for help on using the changeset viewer.