Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: use proper inttype for runtime, use import instead of declaration, rename to runtime_ticks #334

Merged
merged 2 commits into from
Nov 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef struct {
unsigned int laststart; /*< Time stamp of the last time this thread was
scheduled to run */
unsigned int schedules; /*< How often the thread was scheduled to run */
unsigned int runtime; /*< The total runtime of this thread */
unsigned long runtime_ticks; /*< The total runtime of this thread in ticks */
} schedstat;

/**
Expand Down
16 changes: 10 additions & 6 deletions core/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* TODO: setup dependency from SCHEDSTATISTICS to MODULE_HWTIMER
*
* @ingroup kernel
* @{
* @file
Expand All @@ -21,6 +23,10 @@
#include <clist.h>
#include <bitarithm.h>

#if SCHEDSTATISTICS
#include "hwtimer.h"
#endif

#define ENABLE_DEBUG (0)
#include <debug.h>

Expand Down Expand Up @@ -51,7 +57,7 @@ void sched_init()
sched_threads[i] = NULL;
#if SCHEDSTATISTICS
pidlist[i].laststart = 0;
pidlist[i].runtime = 0;
pidlist[i].runtime_ticks = 0;
pidlist[i].schedules = 0;
#endif
}
Expand Down Expand Up @@ -87,13 +93,11 @@ void sched_run()

}

#if SCHEDSTATISTICS
/* TODO: setup dependency from SCHEDSTATISTICS to MODULE_HWTIMER */
extern unsigned long hwtimer_now(void);
unsigned int time = hwtimer_now();
#ifdef SCHEDSTATISTICS
unsigned long time = hwtimer_now();

if (my_active_thread && (pidlist[my_active_thread->pid].laststart)) {
pidlist[my_active_thread->pid].runtime += time - pidlist[my_active_thread->pid].laststart;
pidlist[my_active_thread->pid].runtime_ticks += time - pidlist[my_active_thread->pid].laststart;
}

#endif
Expand Down
6 changes: 3 additions & 3 deletions sys/ps/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ void thread_print_all(void)
const char *sname = state_names[statebit]; // get state name
const char *queued = queued_name + (state & BIT0); // get queued flag
int stacksz = p->stack_size; // get max used stack
double runtime = 0 / 0.0;
double runtime_ticks = 0 / 0.0;
int switches = -1;
#if SCHEDSTATISTICS
runtime = pidlist[i].runtime / (double) hwtimer_now() * 100;
runtime_ticks = pidlist[i].runtime_ticks / (double) hwtimer_now() * 100;
switches = pidlist[i].schedules;
#endif
overall_stacksz += stacksz;
stacksz -= thread_measure_stack_usage(p->stack_start);
printf("\t%3u | %-21s| %-8s %.1s | %3i | %5i (%5i) %p | %6.3f%% | ",
p->pid, p->name, sname, queued, p->priority, p->stack_size, stacksz, p->stack_start, runtime);
p->pid, p->name, sname, queued, p->priority, p->stack_size, stacksz, p->stack_start, runtime_ticks);
printf(" %8u\n", switches);
}
}
Expand Down