freemyipod r389 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r388‎ | r389 | r390 >
Date:00:09, 28 December 2010
Author:theseven
Status:new
Tags:
Comment:
emBIOS: Fix IRQ mode CPU load accounting (now goes into kernel load)
Modified paths:
  • /embios/trunk/arm/contextswitch.S (modified) (history)
  • /embios/trunk/thread.c (modified) (history)
  • /embios/trunk/thread.h (modified) (history)
  • /embios/trunk/tools/embios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/embios.py
@@ -504,9 +504,8 @@
505505 coreload = 1 - (threadload + idleload)
506506 cpuload = threadload + coreload
507507 self.logger.info("The device has " + str(len(threads)) + " running threads.\n" + \
508 - "It is running at " + str(cpuload * 100) + "% cpu load with a core load of " + \
509 - str(coreload * 100) + "%, a thread load of " + str(threadload * 100) + "% " + \
510 - "and an idle load of " + str(idleload * 100) + "%\n\n")
 508+ "It is running at " + str(cpuload * 100) + "% cpu load with a kernel load of " + \
 509+ str(coreload * 100) + "% and a user load of " + str(threadload * 100) + "%\n\n")
511510 self.logger.info("Thread dump:\n")
512511 for thread in threads:
513512 self.logger.info(" "+thread.name+":\n")
Index: embios/trunk/arm/contextswitch.S
@@ -78,6 +78,7 @@
7979 mov r1, lr
8080 msr cpsr_c, #0xd2
8181 stmia r5, {r0-r4}
 82+ bl scheduler_pause_accounting
8283 adr lr, resume_thread
8384 mov r0, #-1
8485 b scheduler_switch
@@ -110,6 +111,7 @@
111112 sub r3, lr, #4
112113 enter_irqhandler:
113114 stmia r12, {r0-r4}
 115+ bl scheduler_pause_accounting
114116 bl irqhandler
115117 @ fallthrough
116118
@@ -116,6 +118,7 @@
117119 .global resume_thread
118120 .type resume_thread, %function
119121 resume_thread:
 122+ bl scheduler_resume_accounting
120123 ldr lr, =current_thread
121124 ldr lr, [lr]
122125 mov r0, lr
Index: embios/trunk/thread.c
@@ -242,6 +242,18 @@
243243 return old;
244244 }
245245
 246+void scheduler_pause_accounting()
 247+{
 248+ uint32_t usec = USEC_TIMER;
 249+ current_thread->cputime_total += usec - current_thread->startusec;
 250+ current_thread->cputime_current += usec - current_thread->startusec;
 251+}
 252+
 253+void scheduler_resume_accounting()
 254+{
 255+ current_thread->startusec = USEC_TIMER;
 256+}
 257+
246258 void scheduler_switch(int thread)
247259 {
248260 int i;
@@ -248,8 +260,6 @@
249261 uint32_t score, best;
250262 uint32_t usec = USEC_TIMER;
251263 if (current_thread->state == THREAD_RUNNING) current_thread->state = THREAD_READY;
252 - current_thread->cputime_total += usec - current_thread->startusec;
253 - current_thread->cputime_current += usec - current_thread->startusec;
254264 if ((int)current_thread->stack != -1 && *current_thread->stack != 0xaffebeaf)
255265 {
256266 for (i = 0; i < MAX_THREADS; i++)
@@ -310,7 +320,6 @@
311321
312322 current_thread = &scheduler_threads[thread];
313323 current_thread->state = THREAD_RUNNING;
314 - current_thread->startusec = USEC_TIMER;
315324 }
316325
317326 int thread_create(const char* name, const void* code, void* stack,
Index: embios/trunk/thread.h
@@ -108,6 +108,8 @@
109109
110110
111111 void scheduler_init() INITCODE_ATTR;
 112+void scheduler_pause_accounting() ICODE_ATTR;
 113+void scheduler_resume_accounting() ICODE_ATTR;
112114 void scheduler_switch(int thread) ICODE_ATTR;
113115 bool scheduler_freeze(bool value);
114116 int thread_create(const char* name, const void* code, void* stack,