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]

Cyg_Thread::add_to_list()


Why does add_to_list() search to see if the
thread is already on the thread_list? Wouldn't
that be a symptom of a bug?

Using #if to remove the search as shown below doesn't appear
to cause any problems.

inline void
Cyg_Thread::add_to_list( void )
{
    // Add thread to housekeeping list
    Cyg_Scheduler::lock();

    if( thread_list == 0 ) {
        list_next = this;
	list_prev = this;
    }
    else {
#if 0
        Cyg_Thread *prev = thread_list;
	
       /* As far as I can tell, add_to_list is only called from
	* the contstructor, so it should not be necessary to check
	* see if this is already in the list.
	*/
        do {
            if ( this == prev )
                break; // found it already!
            prev = prev->list_next;
        } while ( prev != thread_list );

        if ( this != prev )
#endif
	{
            // insert it in the list:
            list_next = thread_list;
	    list_prev = thread_list->list_prev;
	    thread_list->list_prev->list_next = this;
	    thread_list->list_prev = this;
        }
    }
    thread_list = this;

    Cyg_Scheduler::unlock();
}

-- 
Chris Morrow	YottaYotta Inc. email: cmorrow@yottayotta.com
phone: (780) 989 6814 web:	http:  //www.yottayotta.com

-- 
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]