@ -59,6 +59,10 @@ void sched_run(void)
{
sched_context_switch_request = 0 ;
# ifdef SCHEDSTATISTICS
unsigned long time = hwtimer_now ( ) ;
# endif
tcb_t * my_active_thread = ( tcb_t * ) sched_active_thread ;
if ( my_active_thread ) {
@ -72,15 +76,12 @@ void sched_run(void)
}
# endif
}
# ifdef SCHEDSTATISTICS
unsigned long time = hwtimer_now ( ) ;
if ( my_active_thread & & ( sched_pidlist [ my_active_thread - > pid ] . laststart ) ) {
sched_pidlist [ my_active_thread - > pid ] . runtime_ticks + = time - sched_pidlist [ my_active_thread - > pid ] . laststart ;
}
if ( sched_pidlist [ my_active_thread - > pid ] . laststart ) {
sched_pidlist [ my_active_thread - > pid ] . runtime_ticks + = time - sched_pidlist [ my_active_thread - > pid ] . laststart ;
}
# endif
}
DEBUG ( " \n scheduler: previous task: %s \n " , ( my_active_thread = = NULL ) ? " none " : my_active_thread - > name ) ;
@ -92,22 +93,23 @@ void sched_run(void)
DEBUG ( " scheduler: first in queue: %s \n " , ( ( tcb_t * ) next . data ) - > name ) ;
clist_advance ( & ( sched_runqueues [ nextrq ] ) ) ;
my_active_thread = ( tcb_t * ) next . data ;
sched_active_pid = ( volatile int ) my_active_thread - > pid ;
int my_next_pid = my_active_thread - > pid ;
# if SCHEDSTATISTICS
sched_pidlist [ my_active_thread - > pid ] . laststart = time ;
sched_pidlist [ my_active_thread - > pid ] . schedules + + ;
if ( ( sched_cb ) & & ( sched_active_thread ! = thread_last_pid ) ) {
sched_cb ( hwtimer_now ( ) , my_active_thread - > pid ) ;
thread_last_pid = my_active_thread - > pid ;
sched_pidlist [ my_next_pid ] . laststart = time ;
sched_pidlist [ my_next_pid ] . schedules + + ;
if ( ( sched_cb ) & & ( my_next_pid ! = sched_active_pid ) ) {
sched_cb ( time , my_next_pid ) ;
}
# endif
# ifdef MODULE_NSS
if ( sched_active_thread & & sched_active_thread ! = thread_last_pid ) {
thread_last_pid = sched_active_ threa d;
if ( sched_active_thread & & ( my_next_pid ! = thread_last_pid ) ) {
thread_last_pid = sched_active_ pi d;
}
# endif
sched_active_pid = my_next_pid ;
DEBUG ( " scheduler: next task: %s \n " , my_active_thread - > name ) ;