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: catch errors in eCos's kernel


Hi,
The Cyg_Condition_Variable::wait_inner() (Of course the timeout version) did
throw an assertion under some condition like James described. I've attached
the trace in trace.txt. As the trace said, the thread will be woken at
self->set_timer() since the alarm code called in that function
(Cyg_Counter::add_alarm()) will wake the thread up when timeout is in the
past.

Happy hacking!
I-Jui Sung
----- Original Message -----
From: "Jonathan Larmour" <jlarmour@redhat.com>
To: "james chen" <james_ch1@sina.com>
Cc: <ecos-discuss@sources.redhat.com>
Sent: Saturday, September 08, 2001 5:32 AM
Subject: Re: [ECOS] catch errors in eCos's kernel


> james chen wrote:
> >
> > externC int sem_trywait  (sem_t *sem)
> > {[snip]
> >     SEMA_RETURN(0);
> >     ^^^^^^^^^^^^^^^^^^^
> > }
> > This  function  always return 0 if we decrement a semaphore or not, so
it
> > should be  * SEMA_RETURN(retval); *
>
> Yep, well spotted. I've fixed that.
>
> > 2.
> > The function will generate a assert "Unnecessary call to unlock_inner()"
> > if we call it when timeout has already fired.It occurs because if the
> > timeout
> > is in the past, the thread will be woken up immediately and will not
sleep.
> > so we needn't use Cyg_Scheduler::unlock_reschedule() in line 749 to
> > reschedule.
> > The lines begin with "+" is my suggestion to add.
>
> I'm afraid I don't see why that assertion would fire because the thread
> state should be Cyg_Thread::SLEEPing (as set by the self->sleep() below),
> not Cyg_Thread::RUNNING. Or am I missing something?
>
> Jifl
>
> > cyg_bool
> > Cyg_Condition_Variable::wait_inner( Cyg_Mutex *mx, cyg_tick_count
timeout )
> > {
> [snip]
> >     mx->unlock();
> >
> >     // The ordering of sleep() and set_timer() here are
> >     // important. If the timeout is in the past, the thread
> >     // will be woken up immediately and will not sleep.
> >
> >     self->sleep();
> >
> >     // Set the timer and sleep reason
> >     self->set_timer( timeout, Cyg_Thread::TIMEOUT );
> >
> >     // Only enqueue if the timeout has not already fired.
> >     if( self->get_wake_reason() == Cyg_Thread::NONE )
> >         queue.enqueue( self );
> >
> >     // Avoid calling ASRs during the following unlock.
> >     self->set_asr_inhibit();
> >
> >     // Unlock the scheduler and switch threads
> >
> >    + if( self->get_wake_reason() != Cyg_Thread::NONE )
> >    + Cyg_Scheduler::unlock;
> >    + else
> >         Cyg_Scheduler::unlock_reschedule();
>
> --
> Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
> Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
ASSERT FAIL: <7>sched.cxx           [ 141] static void Cyg_Scheduler::unlock_inner()                                                            Unnecessary call to unlock_inner()
TRACE: <7>sched.cxx           [ 704] void Cyg_SchedThread::disinherit_priority()                                                          }}RETURNING UNSET!
TRACE: <7>sched.cxx           [ 132] static void Cyg_Scheduler::unlock_inner()                                                            {{enter
TRACE: <7>sched.cxx           [ 301] static void Cyg_Scheduler::unlock_inner()                                                            }}return void
TRACE: <7>mutex.cxx           [ 415] void Cyg_Mutex::unlock()                                                                             }}return void
TRACE: <7>mutex.cxx           [ 745] cyg_bool Cyg_Condition_Variable::wait_inner()                                                        {{enter
TRACE: <7>mutex.cxx           [ 745] cyg_bool Cyg_Condition_Variable::wait_inner()                                                        ((timeout = 1781))
TRACE: <7>mutex.cxx           [ 548] cyg_bool Cyg_Condition_Variable::check_this()                                                        {{enter
TRACE: <7>mutex.cxx           [ 548] cyg_bool Cyg_Condition_Variable::check_this()                                                        ((zeal = 2))
TRACE: <7>mutex.cxx           [ 571] cyg_bool Cyg_Condition_Variable::check_this()                                                        }}returning 1
TRACE: <7>mutex.cxx           [ 351] void Cyg_Mutex::unlock()                                                                             {{enter
TRACE: <7>sched.cxx           [ 704] void Cyg_SchedThread::disinherit_priority()                                                          {{enter
TRACE: <7>sched.cxx           [ 627] void Cyg_SchedThread::clear_inherited_priority()                                                       {{enter
TRACE: <7>sched.cxx           [ 627] void Cyg_SchedThread::clear_inherited_priority()                                                       }}RETURNING UNSET!
TRACE: <7>sched.cxx           [ 704] void Cyg_SchedThread::disinherit_priority()                                                          }}RETURNING UNSET!
TRACE: <7>mutex.cxx           [ 415] void Cyg_Mutex::unlock()                                                                             }}return void
TRACE: <7>thread.cxx          [ 334] static void Cyg_Thread::sleep()                                                                      {{enter
TRACE: <7>mlqueue.cxx         [ 274] void Cyg_Scheduler_Implementation::rem_thread()                                                      {{enter
TRACE: <7>mlqueue.cxx         [ 274] void Cyg_Scheduler_Implementation::rem_thread()                                                        ((thread=002FF138))
TRACE: <7>mlqueue.cxx         [ 328] void Cyg_Scheduler_Implementation::rem_thread()                                                      }}return void
TRACE: <7>thread.cxx          [ 355] static void Cyg_Thread::sleep()                                                                      }}return void
TRACE: <7>clock.cxx           [ 696] void Cyg_Alarm::initialize()                                                                         {{enter
TRACE: <7>clock.cxx           [ 267] void Cyg_Counter::add_alarm()                                                                        {{enter
TRACE: <7>thread.cxx          [1123] static void Cyg_ThreadTimer::alarm()                                                                   {{enter
TRACE: <7>thread.cxx          [ 364] void Cyg_Thread::wake()                                                                                  {{enter
TRACE: <7>mlqueue.cxx         [ 205] void Cyg_Scheduler_Implementation::add_thread()                                                            {{enter
TRACE: <7>mlqueue.cxx         [ 205] void Cyg_Scheduler_Implementation::add_thread()                                                              ((thread=002FF138))
TRACE: <7>mlqueue.cxx         [ 266] void Cyg_Scheduler_Implementation::add_thread()                                                            }}return void
TRACE: <7>thread.cxx          [ 388] void Cyg_Thread::wake()                                                                                  }}return void
TRACE: <7>thread.cxx          [1164] static void Cyg_ThreadTimer::alarm()                                                                   }}return void
TRACE: <7>clock.cxx           [ 267] void Cyg_Counter::add_alarm()                                                                        }}RETURNING UNSET!
TRACE: <7>clock.cxx           [ 696] void Cyg_Alarm::initialize()                                                                         }}RETURNING UNSET!
TRACE: <7>sched.cxx           [ 132] static void Cyg_Scheduler::unlock_inner()                                                            {{enter

Scheduler:

Lock:                2
Current Thread:      <Not a string: 0x2FF110>

Threads:

pthread.00000800     pri =  15 state = S      id =   6
                     stack base = 002B1014 ptr = 002B2D34 size = 00001EF4
                     sleep reason DELAY    wake reason NONE    
                     queue = 00000000      wait info = 00000000

<Not a string: 0x2FF110>                    pri =  15 state = R      id =   7
                     stack base = 002FF1F4 ptr = 0030ED4C size = 0000FEF4
                     sleep reason NONE     wake reason TIMEOUT 
                     queue = 00000000      wait info = FFFFFFFF

pthread.00001002     pri =  13 state = S      id =   8
                     stack base = 00311694 ptr = 00321318 size = 0000FEF4
                     sleep reason WAIT     wake reason NONE    
                     queue = 00321604      wait info = 00000000

pthread.00001403     pri =  14 state = S      id =   9
                     stack base = 00321CA4 ptr = 00322184 size = 000006D4
                     sleep reason WAIT     wake reason NONE    
                     queue = 002F6B84      wait info = FFFFFFFF

<Not a string: 0x3223A8>                    pri =  15 state = R      id =  10
                     stack base = 0032248C ptr = 00332044 size = 0000FEF4
                     sleep reason NONE     wake reason DONE    
                     queue = 00000000      wait info = 00000000

<Not a string: 0x3323B0>                    pri =  15 state = S      id =  11
                     stack base = 00332494 ptr = 00342004 size = 0000FEF4
                     sleep reason WAIT     wake reason NONE    
                     queue = 002B429C      wait info = 00000000

Idle Thread          pri =  31 state = R      id =   1
                     stack base = 002AF4E8 ptr = 002AFC18 size = 00000800
                     sleep reason NONE     wake reason NONE    
                     queue = 00000000      wait info = 00000000

UCB Server           pri =   3 state = S      id =   2
                     stack base = 002F6750 ptr = 002F69CC size = 00000400
                     sleep reason WAIT     wake reason NONE    
                     queue = 002F6B60      wait info = 002F6A78

Network alarm suppor pri =   6 state = S      id =   3
                     stack base = 002F5084 ptr = 002F5874 size = 00000960
                     sleep reason WAIT     wake reason NONE    
                     queue = 002F5A9C      wait info = 002F5920

Network support      pri =   7 state = S      id =   4
                     stack base = 002B442C ptr = 002B4C14 size = 00000960
                     sleep reason WAIT     wake reason NONE    
                     queue = 002F80B4      wait info = 002B4CC0

SC LP-E card support pri =   6 state = S      id =   5
                     stack base = 002F5AF8 ptr = 002F6158 size = 00000960
                     sleep reason DELAY    wake reason NONE    
                     queue = 00000000      wait info = 00000000

pthread.00003807@    pri =  15 state = S      id =  18
                     stack base = 0041ED74 ptr = 00435800 size = 0002FEF4
                     sleep reason TIMEOUT  wake reason NONE    
                     queue = 002B429C      wait info = 002B01AC


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