Changeset 428 for trunk/kernel/kern/scheduler.c
- Timestamp:
- Jan 29, 2018, 6:08:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/scheduler.c
r416 r428 86 86 87 87 // release lock 88 hal_fence(); 88 89 spinlock_unlock( &sched->lock ); 89 90 … … 181 182 list_entry_t * iter; 182 183 thread_t * thread; 183 184 // printk("\n@@@ %s : current thread %x enter at cycle %d\n", 185 // __FUNCTION__ , CURRENT_THREAD , hal_time_stamp() ); 184 process_t * process; 186 185 187 186 scheduler_t * sched = &core->scheduler; … … 212 211 if( thread->flags & THREAD_FLAG_REQ_DELETE ) 213 212 { 214 215 sched_dmsg("\n[DBG] %s : current thread %x delete thread %x at cycle %d\n", 216 __FUNCTION__ , CURRENT_THREAD , thread , hal_time_stamp() ); 213 // get thread process descriptor 214 process = thread->process; 217 215 218 216 // release FPU if required … … 223 221 thread_child_parent_unlink( thread->parent , XPTR( local_cxy , thread ) ); 224 222 225 // detach thread from process226 process_remove_thread( thread );227 228 // remove thread from scheduler223 // remove thread from scheduler (scheduler lock already taken) 224 uint32_t threads_nr = sched->u_threads_nr; 225 assert( (threads_nr != 0) , __FUNCTION__ , "u_threads_nr cannot be 0\n" ); 226 sched->u_threads_nr = threads_nr - 1; 229 227 list_unlink( &thread->sched_list ); 230 sched->u_threads_nr--; 231 if( sched->u_threads_nr == 0 ) sched->u_last = NULL; 232 233 // release memory allocated to thread 228 if( threads_nr == 1 ) sched->u_last = NULL; 229 230 // delete thread 234 231 thread_destroy( thread ); 235 232 233 sched_dmsg("\n[DBG] %s : thread %x deleted thread %x / cycle %d\n", 234 __FUNCTION__ , CURRENT_THREAD , thread , (uint32_t)hal_get_cycles() ); 235 236 236 // destroy process descriptor if no more threads 237 if (thread->process->th_nr == 0) process_destroy( thread->process ); 237 if( process->th_nr == 0 ) 238 { 239 // delete process 240 process_destroy( process ); 241 242 sched_dmsg("\n[DBG] %s : thread %x deleted process %x / cycle %d\n", 243 __FUNCTION__ , CURRENT_THREAD , process , (uint32_t)hal_get_cycles() ); 244 245 } 238 246 } 239 247 } 240 248 241 249 // release lock 250 hal_fence(); 242 251 spinlock_unlock( &sched->lock ); 243 244 // printk("\n@@@ %s : current thread %x exit at cycle %d\n",245 // __FUNCTION__ , CURRENT_THREAD , hal_time_stamp() );246 252 247 253 } // end sched_handle_requests() … … 277 283 278 284 // check next thread not blocked when type != IDLE 279 assert( ( next->blocked == 0) || (next->type = THREAD_IDLE) , __FUNCTION__ ,285 assert( ((next->blocked == 0) || (next->type == THREAD_IDLE)) , __FUNCTION__ , 280 286 "next thread %x (%s) is blocked on core[%x,%d]\n", 281 287 next->trdid , thread_type_str(next->type) , local_cxy , core->lid ); … … 310 316 { 311 317 312 sched_dmsg("\n[DBG] %s : core[%x,%d] / cause = %s\n" 318 #if( CONFIG_SCHED_DEBUG & 0x1 ) 319 if( hal_time_stamp() > CONFIG_SCHED_DEBUG ) 320 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 313 321 " thread %x (%s) (%x,%x) continue / cycle %d\n", 314 322 __FUNCTION__, local_cxy, core->lid, cause, 315 323 current, thread_type_str(current->type), current->process->pid, current->trdid, 316 324 (uint32_t)hal_get_cycles() ); 325 #endif 317 326 318 327 } … … 355 364 remote_spinlock_lock_busy( lock_xp , &save_sr ); 356 365 357 nolock_printk("\n***** scheduler state for core[%x,%d] at cycle %d\n" 358 "kernel_threads = %d / user_threads = %d / current = (%x,%x)\n", 359 local_cxy , core->lid, hal_time_stamp(), 360 sched->k_threads_nr, sched->u_threads_nr, 366 nolock_printk("\n***** scheduler state for core[%x,%d] / cycle %d / current = (%x,%x)\n", 367 local_cxy , core->lid, (uint32_t)hal_get_cycles(), 361 368 sched->current->process->pid , sched->current->trdid ); 362 369
Note: See TracChangeset
for help on using the changeset viewer.