diff options
| author | Keith Packard <keithp@keithp.com> | 2012-10-23 22:17:49 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2012-10-25 00:07:14 -0700 | 
| commit | b119e19604aa557a40e848c60d98a67b5f259bbd (patch) | |
| tree | 2391c2fb7db1843096ec4e3d288cb26f7cb88b92 /src/core/ao_task.c | |
| parent | 7d34811ba035367bbf26a8510265754f3fbb5a95 (diff) | |
altos: profiling on STM32L
Add sample-based profiling, using a 1kHz timer
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_task.c')
| -rw-r--r-- | src/core/ao_task.c | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/ao_task.c b/src/core/ao_task.c index 65654731..c2b1b270 100644 --- a/src/core/ao_task.c +++ b/src/core/ao_task.c @@ -16,6 +16,10 @@   */  #include <ao.h> +#include <ao_task.h> +#if HAS_SAMPLE_PROFILE +#include <ao_sample_profile.h> +#endif  #define AO_NO_TASK_INDEX	0xff @@ -67,6 +71,8 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam  	ao_arch_init_stack(task, start);  } +__xdata uint8_t	ao_idle; +  /* Task switching function. This must not use any stack variables */  void  ao_yield(void) ao_arch_naked_define @@ -77,6 +83,13 @@ ao_yield(void) ao_arch_naked_define  		ao_cur_task_index = ao_num_tasks-1;  	else  	{ +#if HAS_SAMPLE_PROFILE +		uint16_t	tick = ao_sample_profile_timer_value(); +		uint16_t	run = tick - ao_cur_task->start; +		if (run > ao_cur_task->max_run) +			ao_cur_task->max_run = run; +		++ao_cur_task->yields; +#endif  		ao_arch_save_stack();  	} @@ -110,6 +123,9 @@ ao_yield(void) ao_arch_naked_define  			if (ao_cur_task_index == ao_last_task_index)  				ao_arch_cpu_idle();  		} +#if HAS_SAMPLE_PROFILE +	ao_cur_task->start = ao_sample_profile_timer_value(); +#endif  	}  #if AO_CHECK_STACK  	cli();  | 
