Function pointer within isr

Joel Sherrill joel.sherrill at oarcorp.com
Wed Jul 2 13:15:45 UTC 2014


On 7/1/2014 3:37 PM, Peter Dufault wrote:
> On Jun 30, 2014, at 14:41 , Joel Sherrill <Joel.Sherrill at oarcorp.com> wrote:
>
>> Is your "struct handler_arguments" declared on the stack (e.g. an
>> automatic variable)? If so, then the memory is likely clobbered by
>> the time the ISR runs.
> Not necessarily. A common method would be:
>
> thread_to_process_something() {
> 	struct handler_arguments on_stack;
> 	install_isr_that_uses_on_stack();
>
> 	while (work_to_do_with_isr()) {
> 		receive_and_process_semaphore_from_isr();
> 	}
> 	shutdown_isr();
> }
>
> You just need to ensure that the stack isn't out of scope when the isr can fire.
Good point but most code is going to have an initialization subroutine
like a device driver initialization routine that is called as the system is
brought up.

But a device driver dedicated task that encapsulates everything including
initialization wouldn't have this problem.
> You can't do this on systems that have per-thread stacks that are only mapped when the thread is active, but I don't know of any RTEMS usage of that.  I've used multi-processor systems that have that attribute.
>
> Peter
> -----------------
> Peter Dufault
> HD Associates, Inc.      Software and System Engineering
>

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list