Hi,<br><br><div class="gmail_quote">On Mon, Mar 31, 2008 at 8:11 PM, André Keller Abadie <<a href="mailto:akabadie@gmail.com">akabadie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi again!<br>
<br>
I've already talked to Alain about this and he suggested me to discuss it here.<br>
<br>
The problem happens when thread_dispatch is scheduled within an isr to<br>
be executed after its return. This scheduling procedure has a flaw and<br>
RTEMS keeps crashing every time a few conditions are met.<br>
<br>
Blackfin is an architecture that saves the return pointer of a call in<br>
a register - called RETS - instead of saving in the stack. However you<br>
can use the instruction 'link' to create a stack frame and this<br>
automatically pushes the RETS' value. All C code has this call+link<br>
pair so technically we do save the return pointer in the stack.</blockquote><div><br>The problem here is that call/link resp. it's counter pair unlink/ret are<br>two separate instructions and thus not atomic. The whole part in the interrupt<br>
hanlding dealing with interruptions between call/link is a bit hacky and I don't<br>like it very much.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
This routine that schedules the execution of thread_dispatch after the<br>
return of an interruption does so by changing the RETI's ('return from<br>
interrupt' register) value to point to thread_dispatch and then<br>
changes RETS's value to the old RETI's. Because of this operation, the<br>
old RETS is lost if not previously saved by 'link'. All this procedure<br>
goes perfectly well if the call+link pair is executed, but there are a<br>
few functions that doesn't use 'link' (gcc code written in assembly).</blockquote><div><br>One thing I had not thought about was that these functions don't seem to call<br>any other functions. Maybe this can lead to any solution. As far as I remember<br>
RETS is not reset by the link instruction. So we can not simply check RETS<br>if a call has been made without a LINK. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I guess there are other architectures that, as blackfin, don't save<br>
the return pointers in the stack. If so, how did you solve this<br>
problem?<br>
<br>
Any suggestions?<br>
<br>
I do have a working solution but it uses a separate software<br>
interruption to handle the threaddispatch function.</blockquote><div> </div><div>Which puts architecure dependent code in parts of the rtems codebase which are clearly<br>architecture independent. I am almost 100% this patch will not get accepted. Even if it<br>
is "protected" by a #IFDEF.<br><br><br>alani</div></div>