[ECOS] Interrupt vs Thread - shared resource

Paul D. DeRocco pderocco@ix.netcom.com
Fri Feb 13 01:54:00 GMT 2009


> From: Szentirmai Gergely
> 
> Guys, thank you for your answers!
>  
> Scheduler lock is an alternative to mask the interrupt, but masking the 
> specific interrupt (or lock the specific DSR) is maybe better in 
> performance, but too application specific (code reuse).
> As I read the scheduler manual:
> "However there is one situation where locking the scheduler is 
> appropriate: if some data structure needs to be shared between an 
> application thread and a DSR associated with some interrupt source, the 
> thread can use the scheduler lock to prevent concurrent invocations of 
> the DSR and then safely manipulate the structure."
> It writes the same thing.
>  
> So there are two possible solution only; lock the scheduler, or mask the 
> interrupt.
> Programatically I think both solution are not "pretty" enough, because I 
> have to write procedures, that bother with these "hacks" (they are not 
> high level enough), rather than use a mutex, but this is an eCos 
> conceptional problem (what a shame, not too user-friendly), I think...
>  
> Thank you for this dsr_lock idea too!

I wouldn't call locking the scheduler a hack--it's the normal way to interface between threads and DSRs. If you use semaphores, etc., they do the locking and unlocking for you. Indeed, the whole reason for having DSRs is that it gives you an intermediate layer which can be disabled (by locking the scheduler) without disabling interrupts.

If you have hardware that needs really fast response time, then you write an ISR which handles the really fast stuff, in which case the DSR has to do hardware-dependent interrupt masking when it accesses resources (buffer pointers, etc.) shared with the ISR.

If your hardware isn't so insanely fast, then your ISR just invokes the DSR, the DSR talks to the hardware, and the thread "masks" DSRs by locking the scheduler when it accesses resources shared with the DSR.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list