This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problem with synchronization


Jonathan Larmour wrote:

> Rafael Rodríguez Velilla wrote:
> >
> > 1.- As Robin insinuated... Is it unsafe to call cyg_flag_setbits inside an ISR?
>
> Yes it is unsafe.

  Then, any operation that can produce a thread switch must be called outside of th
eISR, right?


> > 2.- What do I have to do to guarantee a safe thread-switch? I think that the
> > processor mode is not relevant, it is only relevant having the stack pointer
> > pointing into the thread's stack (so no other thread or IRQ can mess around it), if
> > this is true, actually I'm not doing it correctly (I'll continue with my work to
> > mend it). If anyone has the gold rules to prepare for a thread-switch, please let
>
> When you use the setbits, that causes a reschedule. The stack pointer will
> be wrong, and the system will not expect that it is in a FIQ context.
>
> If you are not using DSRs, then effectively you are working outside the
> eCos kernel, so don't try and use kernel primitives. Perhaps the easiest
> route may just be to dump stuff in a buffer, and have a thread just poll
> that buffer. Then at least all rx data is saved. If that isn't an option,
> then at least you can make your FIQ more like an ISR by making it invoke a
> DSR in exactly the same way as a "standard" FIQ would. Then you will
> hopefully have had enough time to grab the rx data, stick it in a buffer
> and re-enable interrupts. The risk with this approach though is that if
> your CPU is sufficiently slow and loaded, it may spend all its time
> processing ISRs, and never reach the DSR.

  Yes. I have just tried this approach and it seems to fit perfectly.
  As the serial communication happens in fixed length streams this approach is perfect
for me.
  My FIQ now posts a DSR when it receives all the buffer or sends it all and it seems to
work perfectly (and I have spent 10 times less to program the new routine).

  Thank you for your hint... I've learnt something... if the kernel does it for you just
use it ... and I was reinventing the DSR for the FIQ.



--
Rafael Rodríguez Velilla        rrv@tid.es
Telefónica I+D          http://www.tid.es
Telf: +34 - 91 337 4270




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]