From e195f7358f727bcf1f553cb00b1085d6ac3cb6ee Mon Sep 17 00:00:00 2001 From: arighi Date: Wed, 19 May 2010 09:32:53 +0000 Subject: [PATCH] benchmark: context switch testcase improvement. Move LED_ON()/LED_OFF() just after sig_wait(). Since they represent a C language barrier they basically disables optimizations around it, causing time measurements to be more determistic. Moreover, be sure to not start child processes before we set the right priority. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3714 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/benchmark/context_switch.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bertos/benchmark/context_switch.c b/bertos/benchmark/context_switch.c index a09a6146..5ab77159 100644 --- a/bertos/benchmark/context_switch.c +++ b/bertos/benchmark/context_switch.c @@ -68,12 +68,12 @@ static void NORETURN hp_process(void) while (1) { sig_wait(SIG_USER0); - #if CONFIG_USE_HP_TIMER - end = timer_hw_hpread(); - #endif #if CONFIG_USE_LED LED_ON(); #endif + #if CONFIG_USE_HP_TIMER + end = timer_hw_hpread(); + #endif sig_send(main_proc, SIG_USER0); } } @@ -83,13 +83,13 @@ static void NORETURN lp_process(void) while (1) { sig_wait(SIG_USER0); - #if CONFIG_USE_HP_TIMER - start = timer_hw_hpread(); - #endif #if CONFIG_USE_LED LED_ON(); LED_OFF(); #endif + #if CONFIG_USE_HP_TIMER + start = timer_hw_hpread(); + #endif sig_send(hp_proc, SIG_USER0); } } @@ -108,15 +108,18 @@ void NORETURN context_switch(void) LED_INIT(); #endif + proc_forbid(); hp_proc = proc_new(hp_process, NULL, PROC_STACK_SIZE, hp_stack); lp_proc = proc_new(lp_process, NULL, PROC_STACK_SIZE, lp_stack); main_proc = proc_current(); - proc_setPri(hp_proc, 2); proc_setPri(lp_proc, 1); + proc_permit(); while (1) { + timer_delay(100); + sig_send(lp_proc, SIG_USER0); sig_wait(SIG_USER0); @@ -126,7 +129,5 @@ void NORETURN context_switch(void) hptime_to_us((end - start)), hptime_to_us((end - start) * 1000) % 1000); #endif - timer_delay(100); } - } -- 2.25.1