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



  I have reviewed my own code (I can understand why you feel lazy to read my 'not
neat' code) and I have discover a mistake (in my code):

  cyg_flag_timed_wait expects an absolute time for the timeout, and I supplied only
the time I wanted to wait (I have resloved this just adding to the timeout the
value of cyg_current_time().   .... I hope this helps someone else.

  This doesn't solve my problem because my thread is not correctly awoken... but
now the timer is set correctly.

  So I suppose that the problem is in how the thread switch happens after I set the
flag.

  The idea of using the ISR-DSR scheme to set the flag in the DSR is not applicable
for me. I'm using a processor runnig at 0.8MHz, a memory of 8 bits with an extra
WAIT state (don't ask me why do I have a micro of 32bits with an 8 bit memory) so
any instructions takes 8 cycles to be read, and I have a buggy embedded USART
without buffer(I have to twist the bits that I want to send and read)...  so the
time till the ISR is activated is enough to overrun characters (this is not true if
I set the serial speed to 400 bauds... no way).

  I understand that you feel like reviewing my code (it bores me too) so I'll make
some questions instead of throwing new code...

1.- As Robin insinuated... Is it unsafe to call cyg_flag_setbits inside an ISR?
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
me know.


  Thank you for your attention.


> I'm way too lazy to look deaply in your code. Though one thing rings a bell, in
> general you should not use eCos services from FIQ mode. To check that's actually
> your problem, try using an IRQ instead which triggers a DSR to invoke
> cyg_flag_setbits() (if its not safe to call it from an interrupt handler).
>
> Robin

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