Changeset 443 for trunk/kernel/kern/thread.c
- Timestamp:
- May 16, 2018, 4:15:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r440 r443 142 142 cluster_t * local_cluster = LOCAL_CLUSTER; 143 143 144 #if DEBUG_THREAD_USER_INIT 145 uint32_t cycle = (uint32_t)hal_get_cycles(); 146 if( DEBUG_THREAD_USER_INIT < cycle ) 147 printk("\n[DBG] %s : thread %x enter to init thread %x in process %x / cycle %d\n", 148 __FUNCTION__, CURRENT_THREAD, thread, process->pid , cycle ); 149 #endif 150 144 151 // register new thread in process descriptor, and get a TRDID 145 152 error = process_register_thread( process, thread , &trdid ); … … 196 203 thread->signature = THREAD_SIGNATURE; 197 204 198 // FIXME call hal_thread_init() function to initialise the save_sr field 205 // FIXME define and call an architecture specific hal_thread_init() 206 // function to initialise the save_sr field 199 207 thread->save_sr = 0xFF13; 200 208 … … 204 212 // update DQDT 205 213 dqdt_update_threads( 1 ); 214 215 #if DEBUG_THREAD_USER_INIT 216 cycle = (uint32_t)hal_get_cycles(); 217 if( DEBUG_THREAD_USER_INIT < cycle ) 218 printk("\n[DBG] %s : thread %x exit after init of thread %x in process %x / cycle %d\n", 219 __FUNCTION__, CURRENT_THREAD, thread, process->pid , cycle ); 220 #endif 206 221 207 222 return 0; … … 227 242 uint32_t cycle = (uint32_t)hal_get_cycles(); 228 243 if( DEBUG_THREAD_USER_CREATE < cycle ) 229 printk("\n[DBG] %s : thread %x enter / process%x / cycle %d\n",230 __FUNCTION__, CURRENT_THREAD, pid , cycle );244 printk("\n[DBG] %s : thread %x enter for process %x in cluster %x / cycle %d\n", 245 __FUNCTION__, CURRENT_THREAD, pid , local_cxy , cycle ); 231 246 #endif 232 247 … … 240 255 return ENOMEM; 241 256 } 257 258 #if( DEBUG_THREAD_USER_CREATE & 1) 259 if( DEBUG_THREAD_USER_CREATE < cycle ) 260 printk("\n[DBG] %s : process descriptor = %x for process %x in cluster %x\n", 261 __FUNCTION__, process , pid , local_cxy ); 262 #endif 242 263 243 264 // select a target core in local cluster … … 256 277 core_lid = cluster_select_local_core(); 257 278 } 279 280 #if( DEBUG_THREAD_USER_CREATE & 1) 281 if( DEBUG_THREAD_USER_CREATE < cycle ) 282 printk("\n[DBG] %s : core[%x,%d] selected\n", 283 __FUNCTION__, local_cxy , core_lid ); 284 #endif 258 285 259 286 // allocate a stack from local VMM … … 282 309 return ENOMEM; 283 310 } 311 312 #if( DEBUG_THREAD_USER_CREATE & 1) 313 if( DEBUG_THREAD_USER_CREATE < cycle ) 314 printk("\n[DBG] %s : thread descriptor %x allocated\n", 315 __FUNCTION__, thread ); 316 #endif 284 317 285 318 // initialize thread descriptor … … 300 333 } 301 334 335 #if( DEBUG_THREAD_USER_CREATE & 1) 336 if( DEBUG_THREAD_USER_CREATE < cycle ) 337 printk("\n[DBG] %s : thread descriptor %x initialised / trdid = %x\n", 338 __FUNCTION__, thread , thread->trdid ); 339 #endif 340 302 341 // set DETACHED flag if required 303 342 if( attr->attributes & PT_ATTR_DETACH ) … … 327 366 cycle = (uint32_t)hal_get_cycles(); 328 367 if( DEBUG_THREAD_USER_CREATE < cycle ) 329 printk("\n[DBG] %s : thread %x exit / process %x / new_thread%x / core %d / cycle %d\n",330 __FUNCTION__, CURRENT_THREAD, pid, thread, core_lid, cycle );368 printk("\n[DBG] %s : thread %x exit / new_thread %x in process %x / core %d / cycle %d\n", 369 __FUNCTION__, CURRENT_THREAD, thread->trdid , pid , core_lid, cycle ); 331 370 #endif 332 371 … … 602 641 // has been released, using a cache of mmap requests. [AG] 603 642 /////////////////////////////////////////////////////////////////////////////////////// 604 voidthread_destroy( thread_t * thread )643 bool_t thread_destroy( thread_t * thread ) 605 644 { 606 645 reg_t save_sr; 646 bool_t last_thread; 607 647 608 648 process_t * process = thread->process; … … 616 656 #endif 617 657 618 assert( (thread->local_locks == 0) , __FUNCTION__ , "all local locks not released" ); 619 620 assert( (thread->remote_locks == 0) , __FUNCTION__ , "all remote locks not released" ); 658 assert( (thread->local_locks == 0) , __FUNCTION__ , 659 "local lock not released for thread %x in process %x", thread->trdid, process->pid ); 660 661 assert( (thread->remote_locks == 0) , __FUNCTION__ , 662 "remote lock not released for thread %x in process %x", thread->trdid, process->pid ); 621 663 622 664 // update intrumentation values … … 637 679 638 680 // remove thread from process th_tbl[] 639 process_remove_thread( thread );681 last_thread = process_remove_thread( thread ); 640 682 641 683 // update DQDT … … 654 696 __FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle ); 655 697 #endif 698 699 return last_thread; 656 700 657 701 } // end thread_destroy() … … 1092 1136 hal_enable_irq( NULL ); 1093 1137 1094 if( CONFIG_THREAD_IDLE_MODE_SLEEP ) // force core to low-power mode 1138 // force core to low-power mode (optional) 1139 if( CONFIG_THREAD_IDLE_MODE_SLEEP ) 1095 1140 { 1096 1141 … … 1113 1158 1114 1159 } 1115 else // search a runable thread 1116 { 1117 sched_yield( "IDLE" ); 1118 } 1160 1161 // search a runable thread 1162 sched_yield( "IDLE" ); 1119 1163 } 1120 1164 } // end thread_idle()
Note: See TracChangeset
for help on using the changeset viewer.