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]
Other format: [Raw text]

Task switching problem


Good Day!

eCos: v2.0-20030509-0835
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.

Yuriy Coureelo



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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