This is the mail archive of the libc-help@sourceware.org mailing list for the glibc 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]

Pthread initialization


Hello all,

I'm integrating a linux OS with sparc-leon3 processor. The linux
kernel is built with a Crosstool-ng based toochain, downloaded from
Gaisler website. It generates the toolchain using the glibc 2.9. I
built my linux image with buildroot and the kernel does boot and
login. However, pthreads apps isn't working very well on the system.
Have somebody here worked with pthreads on the sparc architecture?

These problems with pthreads arises even on simpler programs, as in
this C code example, attached to the e-mail. It seems that the stack
couldn't be allocated , returning the following error:
allocate_stack: Assertion `size != 0' failed.

Adding some debugging code in ntpl/allocatestack.c and ntpl/init.c, I
realize that stack size and address returned by the pthreads API call
are always returning NULL and that
__pthread_initialize_minimal_internal is not being called.  The
disassembled code shows that the _init function in
sysdeps/generic/initfini.c is called, but the function _init in
ntpl/sysdeps/pthread/pt-initfini.c (which initializes the stack size)
isn't. Is this the reason of my problem?

What do I have to do in order to call the _init in
ntpl/sysdeps/pthread/pt-initfini.c?

Here the .init section of my program:
Disassembly of section .init:

000103c4 <_init>:
   103c4: 9d e3 bf a0 save  %sp, -96, %sp
   103c8: 40 00 00 18 call  10428 <call_gmon_start>
   103cc: 01 00 00 00 nop
   103d0: 40 00 00 44 call  104e0 <frame_dummy>
   103d4: 01 00 00 00 nop
   103d8: 40 00 00 bf call  106d4 <__do_global_ctors_aux>
   103dc: 01 00 00 00 nop
   103e0: 81 c7 e0 08 ret
   103e4: 81 e8 00 00 restore

Thanks in advance,
Wesley Gonçalves
/* example.c*/
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

void thread(void)
{    
	int i=0,j=0; 
	
	while(1) {
		for (i = 0;i < 100000;i++) {
			j++;
		}
		printf("This is a pthread %i.\n",j);
	}
}  

int main(void)
{    
	pthread_t id;
	int i=0,ret,j=0;
	ret = pthread_create(&id,NULL,(void *) thread,NULL);
	
	if( ret != 0 ) {
		printf ("Create pthread error!\n");
		exit (1);
	}
	while(1) {
		printf("This is the main process %i.\n",j);
		for (i = 0;i < 100000;i++) {
			j++;
		}
	}
	
	pthread_join(id,NULL);
	return (0);
}   


 
  
 

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