thread2 test gets deadlocked... Is it possible or am I missing some config option?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

thread2 test gets deadlocked... Is it possible or am I missing some config option?

David Fernandez
Hi there,

Testing my hal for Cortex-R4, I'm getting a funny behaviour for test
 kernel/.../thread2. It seems that when two threads have the same
 priority, there is no timeslicing working (interestingly, the
 timeslice tests also get deadlocked).

The problem seems to appear because thread#2 preempts thread #1,
(thread #1 seems to do more API calls than thread #2, but reducing the
unnecessary ones does not solve the problem), so thread #2 gets
waiting for thread #1 to increase "q", and thread #1 never gets
scheduled to realize that "q" has moved to 101, so it can move it to
102...

I've added lots of traces (see attached modified thread2.cxx, and the
trace output below).

Is this test expected to succeed without timeslicing?
Is it possible that the checks that thread#1 does at that critical
point might tip off the things to the wrong side?
Or is it that I might have some wrong configuration option set or unset?

If none of the above... Any idea on what could be wrong?

Regards.

These are the extra output that tries to show what is wrong:

INFO:<Main changing priority for thread #0 to 5.>
INFO:<Main changing priority for thread #1 to 6.>
INFO:<Main changing priority for thread #2 to 7.>
INFO:<Changing Priorities in main done.>
INFO:<Thread #0 Has q 0 => 1.>
INFO:<Thread #0 waiting on s0...>
INFO:<Thread #1 Has q 1 => 2.>
INFO:<Thread #1 waiting on s1...>
INFO:<Thread #2 Has q 2 => 3.>
INFO:<Thread #2 Posts s0.>
INFO:<Thread #0 waiting on s0 done.>
INFO:<Thread #0 Has q 3 => 4.>
INFO:<Thread #0 Posts s1.>
INFO:<Thread #0 Has q 4 => 5.>
INFO:<Thread #0 waiting on s0 (1/2)...>
INFO:<Thread #1 waiting on s1 done.>
INFO:<Thread #1 Has q 5 => 6.>
INFO:<Thread #1 changing priority for thread #0 to 9.>
INFO:<Thread #1 Posts s0.>
INFO:<Thread #1 Has q 6 => 7.>
INFO:<Thread #1 changing priority for thread #2 to 3.>
INFO:<Thread #2 Has q 7 => 8.>
INFO:<Thread #2 waiting on s2...>
INFO:<Thread #1 Has q 8 => 9.>
INFO:<Thread #1 Posts s2.>
INFO:<Thread #2 waiting on s2 done.>
INFO:<Thread #2 Has q 9 => 10.>
INFO:<Thread #2 changing priority for thread #1 to 6.>
INFO:<Thread #2 Has q 10 => 11.>
INFO:<Thread #2 changing its priority to 2.>
INFO:<Thread #2 Has q 11 => 12.>
INFO:<Thread #2 changing its priority to 7.>
INFO:<Thread #1 Has q 12 => 13.>
INFO:<Thread #1 Has q => 100.>
INFO:<Thread #1 changing priority for thread #2 to 6.>
INFO:<Thread #1 waiting for 'INFO:<Thread #2 Has q 100 => 101.>
INFO:<Thread #2 waiting for 'q' to be != 101...>

thread2.cxx (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: thread2 test gets deadlocked... Is it possible or am I missing some config option?

David Fernandez
Never mind,

I've discover a bad interaction between the default ISR/VSR code and
the context switch code... that interrupt_end routine trying to switch
context while on an interrupt stack... That caused that the interrupt
controller code to clear the interrupt priority (for the clok, the
only one going on at the moment), to be skipped.

That would require a bit of complexity to realize and do a proper
context switch on the right stack frame...

By the way, is it me or is this list a bit on holiday... :)

On Tue, Aug 13, 2013 at 2:59 PM, David Fernandez
<[hidden email]> wrote:

> Hi there,
>
> Testing my hal for Cortex-R4, I'm getting a funny behaviour for test
>  kernel/.../thread2. It seems that when two threads have the same
>  priority, there is no timeslicing working (interestingly, the
>  timeslice tests also get deadlocked).
>
> The problem seems to appear because thread#2 preempts thread #1,
> (thread #1 seems to do more API calls than thread #2, but reducing the
> unnecessary ones does not solve the problem), so thread #2 gets
> waiting for thread #1 to increase "q", and thread #1 never gets
> scheduled to realize that "q" has moved to 101, so it can move it to
> 102...
>
> I've added lots of traces (see attached modified thread2.cxx, and the
> trace output below).
>
> Is this test expected to succeed without timeslicing?
> Is it possible that the checks that thread#1 does at that critical
> point might tip off the things to the wrong side?
> Or is it that I might have some wrong configuration option set or unset?
>
> If none of the above... Any idea on what could be wrong?
>
> Regards.
>
> These are the extra output that tries to show what is wrong:
>
> INFO:<Main changing priority for thread #0 to 5.>
> INFO:<Main changing priority for thread #1 to 6.>
> INFO:<Main changing priority for thread #2 to 7.>
> INFO:<Changing Priorities in main done.>
> INFO:<Thread #0 Has q 0 => 1.>
> INFO:<Thread #0 waiting on s0...>
> INFO:<Thread #1 Has q 1 => 2.>
> INFO:<Thread #1 waiting on s1...>
> INFO:<Thread #2 Has q 2 => 3.>
> INFO:<Thread #2 Posts s0.>
> INFO:<Thread #0 waiting on s0 done.>
> INFO:<Thread #0 Has q 3 => 4.>
> INFO:<Thread #0 Posts s1.>
> INFO:<Thread #0 Has q 4 => 5.>
> INFO:<Thread #0 waiting on s0 (1/2)...>
> INFO:<Thread #1 waiting on s1 done.>
> INFO:<Thread #1 Has q 5 => 6.>
> INFO:<Thread #1 changing priority for thread #0 to 9.>
> INFO:<Thread #1 Posts s0.>
> INFO:<Thread #1 Has q 6 => 7.>
> INFO:<Thread #1 changing priority for thread #2 to 3.>
> INFO:<Thread #2 Has q 7 => 8.>
> INFO:<Thread #2 waiting on s2...>
> INFO:<Thread #1 Has q 8 => 9.>
> INFO:<Thread #1 Posts s2.>
> INFO:<Thread #2 waiting on s2 done.>
> INFO:<Thread #2 Has q 9 => 10.>
> INFO:<Thread #2 changing priority for thread #1 to 6.>
> INFO:<Thread #2 Has q 10 => 11.>
> INFO:<Thread #2 changing its priority to 2.>
> INFO:<Thread #2 Has q 11 => 12.>
> INFO:<Thread #2 changing its priority to 7.>
> INFO:<Thread #1 Has q 12 => 13.>
> INFO:<Thread #1 Has q => 100.>
> INFO:<Thread #1 changing priority for thread #2 to 6.>
> INFO:<Thread #1 waiting for 'INFO:<Thread #2 Has q 100 => 101.>
> INFO:<Thread #2 waiting for 'q' to be != 101...>