Changeset 635 for trunk/kernel/kern/thread.c
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r633 r635 78 78 static thread_t * thread_alloc( void ) 79 79 { 80 page_t * page; // pointer on page descriptor containing thread descriptor81 80 kmem_req_t req; // kmem request 82 81 83 82 // allocates memory for thread descriptor + kernel stack 84 req.type = KMEM_P AGE;85 req. size= CONFIG_THREAD_DESC_ORDER;83 req.type = KMEM_PPM; 84 req.order = CONFIG_THREAD_DESC_ORDER; 86 85 req.flags = AF_KERNEL | AF_ZERO; 87 page = kmem_alloc( &req ); 88 89 if( page == NULL ) return NULL; 90 91 // return pointer on new thread descriptor 92 xptr_t base_xp = ppm_page2base( XPTR(local_cxy , page ) ); 93 return GET_PTR( base_xp ); 86 87 return kmem_alloc( &req ); 94 88 95 89 } // end thread_alloc() … … 125 119 { 126 120 127 // check type and trdid fields initialized121 // check type and trdid fields are initialized 128 122 assert( (thread->type == type) , "bad type argument" ); 129 123 assert( (thread->trdid == trdid) , "bad trdid argument" ); … … 133 127 thread_t * this = CURRENT_THREAD; 134 128 if( DEBUG_THREAD_INIT < cycle ) 135 printk("\n[%s] thread[%x,%x] enter for thread %x in process %x/ cycle %d\n",136 __FUNCTION__, this->process->pid, this->trdid, thread->trdid, process->pid, cycle );129 printk("\n[%s] thread[%x,%x] enter for thread[%x,%x] / cycle %d\n", 130 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 137 131 #endif 138 132 … … 192 186 cycle = (uint32_t)hal_get_cycles(); 193 187 if( DEBUG_THREAD_INIT < cycle ) 194 printk("\n[%s] thread[%x,%x] exit for thread %x in process %x/ cycle %d\n",195 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );188 printk("\n[%s] thread[%x,%x] exit for thread[%x,%x] / cycle %d\n", 189 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 196 190 #endif 197 191 … … 580 574 vpn_t parent_vpn_size = hal_remote_l32( XPTR( parent_cxy, &parent_us_vseg->vpn_size ) ); 581 575 vpn_t child_vpn_base = child_us_vseg->vpn_base; 576 582 577 for( parent_vpn = parent_vpn_base , child_vpn = child_vpn_base ; 583 578 parent_vpn < (parent_vpn_base + parent_vpn_size) ; … … 625 620 #if (DEBUG_THREAD_USER_FORK & 1) 626 621 if( DEBUG_THREAD_USER_FORK < cycle ) 627 printk("\n[%s] thread[%x,%x] copied all stack vseg PTEs tochild GPT\n",622 printk("\n[%s] thread[%x,%x] copied STACK vseg PTEs & set COW in child GPT\n", 628 623 __FUNCTION__, this->process->pid, this->trdid ); 629 624 #endif … … 636 631 #if (DEBUG_THREAD_USER_FORK & 1) 637 632 if( DEBUG_THREAD_USER_FORK < cycle ) 638 printk("\n[%s] thread[%x,%x] set the COW flag for stackvseg in parent GPT\n",633 printk("\n[%s] thread[%x,%x] set COW for STACK vseg in parent GPT\n", 639 634 __FUNCTION__, this->process->pid, this->trdid ); 640 635 #endif … … 906 901 thread_assert_can_yield( thread , __FUNCTION__ ); 907 902 908 // update target process instrumentation counter 909 // process->vmm.pgfault_nr += thread->info.pgfault_nr; 903 #if CONFIG_INSTRUMENTATION_PGFAULTS 904 process->vmm.false_pgfault_nr += thread->info.false_pgfault_nr; 905 process->vmm.local_pgfault_nr += thread->info.local_pgfault_nr; 906 process->vmm.global_pgfault_nr += thread->info.global_pgfault_nr; 907 process->vmm.false_pgfault_cost += thread->info.false_pgfault_cost; 908 process->vmm.local_pgfault_cost += thread->info.local_pgfault_cost; 909 process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost; 910 #endif 910 911 911 912 // remove thread from process th_tbl[] 912 913 count = process_remove_thread( thread ); 913 914 914 // release memory allocated for CPU context and FPU context if required915 // release memory allocated for CPU context and FPU context 915 916 hal_cpu_context_destroy( thread ); 916 917 hal_fpu_context_destroy( thread ); … … 933 934 // release memory for thread descriptor (including kernel stack) 934 935 kmem_req_t req; 935 xptr_t base_xp = ppm_base2page( XPTR(local_cxy , thread ) ); 936 937 req.type = KMEM_PAGE; 938 req.ptr = GET_PTR( base_xp ); 936 req.type = KMEM_PPM; 937 req.ptr = thread; 939 938 kmem_free( &req ); 940 939
Note: See TracChangeset
for help on using the changeset viewer.