Changeset 443 for trunk/kernel/kern/scheduler.c
- Timestamp:
- May 16, 2018, 4:15:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/scheduler.c
r440 r443 34 34 #include <scheduler.h> 35 35 36 36 37 /////////////////////////////////////////////////////////////////////////////////////////// 37 38 // Extern global variables 38 39 /////////////////////////////////////////////////////////////////////////////////////////// 39 40 40 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 41 extern uint32_t switch_save_sr[]; // allocated in kernel_init.c file 41 uint32_t idle_thread_count; 42 uint32_t idle_thread_count_active; 43 44 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 45 extern uint32_t switch_save_sr[]; // allocated in kernel_init.c file 42 46 43 47 //////////////////////////////// … … 50 54 51 55 sched->current = CURRENT_THREAD; 52 sched->idle = NULL; // initialized in kernel_init()53 sched->u_last = NULL; // initialized in sched_register_thread()54 sched->k_last = NULL; // initialized in sched_register_thread()56 sched->idle = NULL; // initialized in kernel_init() 57 sched->u_last = NULL; // initialized in sched_register_thread() 58 sched->k_last = NULL; // initialized in sched_register_thread() 55 59 56 60 // initialise threads lists … … 58 62 list_root_init( &sched->k_root ); 59 63 60 sched->req_ack_pending = false; // no pending request 64 sched->req_ack_pending = false; // no pending request 65 sched->trace = false; // context switches trace desactivated 61 66 62 67 } // end sched_init() … … 179 184 thread_t * thread; 180 185 process_t * process; 186 bool_t last_thread; 181 187 182 188 // get pointer on scheduler … … 237 243 238 244 // delete thread 239 thread_destroy( thread );245 last_thread = thread_destroy( thread ); 240 246 241 247 #if DEBUG_SCHED_HANDLE_SIGNALS 242 248 uint32_t cycle = (uint32_t)hal_get_cycles(); 243 249 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 244 printk("\n[DBG] %s : thread %x in proces %x (%x)deleted / cycle %d\n",245 __FUNCTION__ , thread , process->pid , process, cycle );250 printk("\n[DBG] %s : thread %x in proces %x on core[%x,%d] deleted / cycle %d\n", 251 __FUNCTION__ , thread->trdid , process->pid , local_cxy , thread->core->lid , cycle ); 246 252 #endif 247 253 // destroy process descriptor if no more threads 248 if( process->th_nr == 0)254 if( last_thread ) 249 255 { 250 256 // delete process … … 254 260 cycle = (uint32_t)hal_get_cycles(); 255 261 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 256 printk("\n[DBG] %s : process %x has beendeleted / cycle %d\n",257 __FUNCTION__ , process->pid , cycle );262 printk("\n[DBG] %s : process %x in cluster %x deleted / cycle %d\n", 263 __FUNCTION__ , process->pid , local_cxy , cycle ); 258 264 #endif 259 265 … … 277 283 278 284 #if (DEBUG_SCHED_YIELD & 0x1) 279 if( DEBUG_SCHED_YIELD < (uint32_t)hal_get_cycles())285 if( sched->trace ) 280 286 sched_display( core->lid ); 281 287 #endif … … 295 301 296 302 // check next thread kernel_stack overflow 297 assert( (next->signature == THREAD_SIGNATURE), 298 __FUNCTION__ , "kernel stack overflow for thread %x\n", next);303 assert( (next->signature == THREAD_SIGNATURE), __FUNCTION__ , 304 "kernel stack overflow for thread %x on core[%x,%d] \n", next, local_cxy, core->lid ); 299 305 300 306 // check next thread attached to same core as the calling thread 301 assert( (next->core == current->core), 302 __FUNCTION__ ,"next core %x != current core %x\n", next->core, current->core );307 assert( (next->core == current->core), __FUNCTION__ , 308 "next core %x != current core %x\n", next->core, current->core ); 303 309 304 310 // check next thread not blocked when type != IDLE … … 311 317 { 312 318 313 if( (local_cxy == 0X1) && (core->lid == 1) && ((uint32_t)current == 0xcc000) )314 printk("\n@@@@@ cc000 exit at cycle %d\n", (uint32_t)hal_get_cycles() );315 316 if( (local_cxy == 0X1) && (core->lid == 1) && ((uint32_t)next == 0xcc000) )317 printk("\n@@@@@ cc000 enter at cycle %d\n", (uint32_t)hal_get_cycles() );318 319 319 #if DEBUG_SCHED_YIELD 320 uint32_t cycle = (uint32_t)hal_get_cycles(); 321 if( DEBUG_SCHED_YIELD < cycle ) 320 if( sched->trace ) 322 321 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 323 322 " thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n", 324 323 __FUNCTION__, local_cxy, core->lid, cause, 325 current, thread_type_str(current->type), current->process->pid, current->trdid, 326 next , thread_type_str(next->type) , next->process->pid , next->trdid , cycle);324 current, thread_type_str(current->type), current->process->pid, current->trdid,next , 325 thread_type_str(next->type) , next->process->pid , next->trdid , (uint32_t)hal_get_cycles() ); 327 326 #endif 328 327 … … 345 344 { 346 345 347 #if (DEBUG_SCHED_YIELD & 1) 348 uint32_t cycle = (uint32_t)hal_get_cycles(); 349 if( DEBUG_SCHED_YIELD < cycle ) 346 #if DEBUG_SCHED_YIELD 347 if( sched->trace ) 350 348 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 351 349 " thread %x (%s) (%x,%x) continue / cycle %d\n", 352 __FUNCTION__, local_cxy, core->lid, cause, 353 current , thread_type_str(current->type), current->process->pid, current->trdid, cycle);350 __FUNCTION__, local_cxy, core->lid, cause, current, thread_type_str(current->type), 351 current->process->pid, current->trdid, (uint32_t)hal_get_cycles() ); 354 352 #endif 355 353 … … 389 387 390 388 nolock_printk("\n***** threads on core[%x,%d] / current %x / cycle %d\n", 391 389 local_cxy , core->lid, sched->current, (uint32_t)hal_get_cycles() ); 392 390 393 391 // display kernel threads
Note: See TracChangeset
for help on using the changeset viewer.