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


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


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