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


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

Yes it is unsafe.

> 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.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions    http://www.redhat-techworld.com/


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