[ECOS] Problem with pthread_self for the eCos main thread

Andrew Lunn andrew@lunn.ch
Fri Oct 27 11:02:00 GMT 2006


On Fri, Oct 27, 2006 at 11:37:54AM +0200, LOGIE Hans wrote:
> Hi,
>  
> I have a problem with the pthread_self() function in eCos. When creating
> POSIX threads and retrieving their thread ID's with pthread_self() there
> are no problems. However when retrieving the thread ID of the main
> thread, there is an assert on line 680 of pthread.cxx which tells that
> the current thread is not a POSIX thread.

I've not been able to reproduce this problem. Attached is a little
patch to one of the test cases. Please try it and see if it works for
you, or throws an assert.

     Andrew
-------------- next part --------------
Index: packages/compat/posix/current/tests/pthread1.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/compat/posix/current/tests/pthread1.c,v
retrieving revision 1.4
diff -u -r1.4 pthread1.c
--- packages/compat/posix/current/tests/pthread1.c	23 May 2002 23:00:02 -0000	1.4
+++ packages/compat/posix/current/tests/pthread1.c	27 Oct 2006 11:00:10 -0000
@@ -48,6 +48,7 @@
 //####DESCRIPTIONEND####
 //==========================================================================
 
+#include <cyg/infra/diag.h>
 #include <cyg/infra/testcase.h>
 #include <pkgconf/posix.h>
 
@@ -86,6 +87,8 @@
 int main(int argc, char **argv)
 {
     pthread_t thread;
+    pthread_t me;
+    
     pthread_attr_t attr;
     void *retval;
 
@@ -102,6 +105,9 @@
                     pthread_entry1,
                     (void *)0x12345678);
 
+    me = pthread_self();
+    diag_printf("me = %x\n", me);
+    
     // Now join with it
     pthread_join( thread, &retval );
 

-------------- next part --------------
-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


More information about the Ecos-discuss mailing list