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]

problem in thread creation


> hi all,
> i have written small application which has  2 threads.
> small part of it is as follows:
> void cyg_user_start(void)
> {
>       printf("entering two threads cyg_user_start() function\n");
>       cyg_thread_create(4,simple_program,(cyg_addrword_t)0,
>                         "Thread A",(void*) stack[0],4096,
>                         &simple_threadA,&thread_s[0]);
>       cyg_thread_create(5,simple_program1,(cyg_addrword_t)1,
>                        "Thread B",(void*) stack[1],4096,
>                        &simple_threadB,&thread_s[1]);
> cyg_thread_resume(simple_threadA);
> cyg_thread_resume(simple_threadB);
> }
> when the control comes for execution of second thread the system
hangs.
> on debug i found that the control is in thread.cxx.
> why is this happening and how to overcome this.

>Given the terseness of your description, it's hard to tell exactly
>what the problem is.  First guess is that stack[0] and stack[1]
>don't contain actual stack pointers.

>Have you run this code with asserts (kernel debugging) enabled?

>-- 
>Gary Thomas <gary@mlbassoc.com>
?
>MLB Associates

Thanks for ur kind reply
After debugging i found that problem is in following code fragment in
file thread.cxx:

		Cyg_Thread::add_to_list( void )
-	127	{
 	128	    // Add thread to housekeeping list
 	129	    Cyg_Scheduler::lock();
 	130	
-	131	    if( thread_list == 0 )
 	132	        list_next = this;
 	133	    else {prev != thread_list
 	134	        Cyg_Thread *prev = thread_list;
-	135	        do {
-	136	            if ( this == prev )
 	137	                break; // found it already!
-	138	            prev = prev->list_next;
-	139	        } while ( prev != thread_list );
-	140	        if ( this != prev ) {
 	141	            // insert it in the list:
-	142	            list_next = thread_list->list_next;
-	143	            thread_list->list_next = this;
 	144	        }
 	145	    }

the control is in the while loop forever as prev == thread_list ( line
139 )ie prev has become NULL.

Thanking in Advance

Aravind B



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