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]

RE: Re: ECOS: fatal error!


>Iztok zupet wrote :
 >Hi
 >
 >  I think, that You just can't access the scheduler queue from an interrupt 
 >(ISR) routine! No way. What you need to do is to write a DSR for Your ISR and 
 >in that DSR You can only set up a driver condition to notify a normal thread 
 >waiting for it, which can access the scheduler queue after the condition 
 >becomes true. 
 >Only a normal thread can access the scheduler queue, if You want to be safe, 
 >not the ISR (interrupt service routine) or DSR (deferred service routine).
 >
 >Regards
 >iz
 >
 hello!
    Can I call bin_sem::post() in a interrupt routine(ISR/DSR)?
if I can ,you see,
  void Cyg_Binary_Semaphore::post()
{
    // Prevent preemption
    Cyg_Scheduler::lock();

    CYG_INSTRUMENT_BINSEM( POST, this, 0 );
        
    state = true;
        
    if( !queue.empty() ) {

        // The queue is non-empty, so grab the next
        // thread from it and wake it up. The waiter
        // will clear the flag.

        Cyg_Thread *thread = queue.dequeue();

        thread->set_wake_reason( Cyg_Thread::DONE );
        
        thread->wake();

        CYG_INSTRUMENT_BINSEM( WAKE, this, thread );
    }
    
    // Unlock the scheduler and maybe switch threads
    Cyg_Scheduler::unlock();
    
} 


  so thread->wake() was called,which was listed:
 

 void
Cyg_Thread::wake()
{
    CYG_REPORT_FUNCTION();

    CYG_INSTRUMENT_THREAD(WAKE,this,Cyg_Scheduler::current_thread);
    
    // Prevent preemption
    Cyg_Scheduler::lock();

    if( 0 != (state & SLEEPSET) )
    {
        // Set the state
        state &= ~SLEEPSET;

        // remove from any queue we were on
        remove();

        // If the thread is now runnable, return it to run queue
        if( state == RUNNING )
            Cyg_Scheduler::scheduler.add_thread(this);

    }
    
    // Unlock the scheduler and maybe switch threads
    Cyg_Scheduler::unlock();

    CYG_REPORT_RETURN();
}
   

  remove()was called,so threadQueue race conditions occur!!!

  Right?

                                              zhlg
______________________________________

===================================================================
新浪免费电子邮箱 (http://mail.sina.com.cn)
新浪分类信息:二手市场走一走,该出手时就出手! (http://classad.sina.com.cn/2shou/)

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


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