1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/sched: fix pid/tcb & refactor SCHEDSTATISTICS

pid and tcb_t were compared instead of pid and pid

SCHEDSTATISTICS:
- reduce hwtimer_now calls
- dont use thread_last_pid anymore
- increase readability
This commit is contained in:
Ludwig Ortmann 2014-07-07 14:48:07 +02:00
parent 9cabdb3043
commit 147c285365

View File

@ -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("\nscheduler: 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_thread;
if (sched_active_thread && (my_next_pid != thread_last_pid)) {
thread_last_pid = sched_active_pid;
}
#endif
sched_active_pid = my_next_pid;
DEBUG("scheduler: next task: %s\n", my_active_thread->name);