This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Task switching problem
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Yuriy Coureelo <coureelo at micran dot ru>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Fri, 1 Jul 2005 12:52:46 +0200
- Subject: Re: [ECOS] Task switching problem
- References: <526561229.20050701155934@micran.ru>
On Fri, Jul 01, 2005 at 03:59:34PM +0600, Yuriy Coureelo wrote:
> Good Day!
>
> eCos: v2.0-20030509-0835
That is quite an old version of eCos. Have you tried with anoncvs?
> Architecture: ARM, AT91
>
> PROBLEM DESCRIPTION
> There are 4 active threads: system idle thread, thread A working with
> FIQ, thread B working with IRQ, high-priority thread C just blinking
> a LED. Starting hardware I see blinking LED (good) and working threads
> A and B (fine). System works from couple of seconds upto couple of
> minutes, then LED stops blinking.
>
> I tried to find out a reason lot of times, and had following common info:
>
> 01.FIQ incoming
> 02.ISR and DSR called, DSR posted flags for thread A
> 03.Scheduler takes a decision to switch from idle to thread A
> 04.IRQ incoming but scheduler works yet, so ISR called and DSR just
> posted
> 05.Threads A start working but there is pending DSR (posted at step 04)
> 06.DSR called and posted flags for thread B
> 07.Scheduler takes a decision to switch from thread A to thread B
> 08.Thread B working and going to sleep
> 09.IRQ incoming but scheduler already works, so ISR called and DSR just
> posted
> 10.Scheduler takes a decision to switch from thread B to thread A,
> because thread B already sleeping, and IRQ (at step 09) posted DSR
> a bit later than scheduler checks DSRs at its beginning
> 11.After switching scheduler checks for DSRs again and detects DSR,
> posted at step 09:
>
> if( Cyg_Interrupt::DSRs_pending() ) {
> inc_sched_lock(); // reclaim the lock
> continue; // go back to head of loop
> }
>
> 12.DSR called and posted flags for thread B
> 13.Scheduler takes a decision to switch from thread A to thread B
> (thread A didn't even continue)
> 14.Thread B working and going to sleep
> 15.Scheduler takes a decision to switch from thread B to thread A
> 16.Thread A working and going to sleep
> 17.Scheduler takes a decision to switch from thread A to idle
> 18.interrupt_end() at last exits,
> Cyg_Scheduler::get_sched_lock() returns 0 (my checkpoint)
>
> But idle thread isn't called.
> When new interrupt comes, interrupt_end() exits because sched_lock
> already equals 1, althoug no calls to inc_sched_lock() and
> set_sched_lock().
> No more interrupts come after that (i think cpu got somewhere away).
> Stacks seems are OK (I have memory dump over JTAG).
>
> I guess it is extremely hard to find a reason of the problem, but
> would you point me where or what I should search, please.
You could try enabling the kernel instramentation. Take a look at the
example in the documentation:
http://ecos.sourceware.org/docs-latest/user-guide/kernel-instrumentation.html
It might help you track down where the schedular lock count goes
funny.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss