ltib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ltib] threads on mpc5200 ltib platform


From: Stuart Hughes
Subject: Re: [Ltib] threads on mpc5200 ltib platform
Date: Mon, 04 Jun 2007 15:56:37 +0100

Hi Andrea,

I tried this on an 8349itx-gp which was using:
mtwk-lnx-powerpc-gcc-3.4.3-glibc-2.3.3-0.28-1.i686.rpm which is a
similar toolchain and it worked okay (I think), I got:

~ # /usr/bin/main
This is parent process.
This is the thread.
This is parent process.
This is the thread.
This is parent process.
This is parent process.

However, although my compiler accepts it, the call to pthread_create
looks suspicious, shouldn't it be:

retval= pthread_create (&thread_id, NULL, thread_func, NULL);

That is, no '&' in front of the function name.

I'd also not really sure about clone, I've not used it, but possibly if
you have your stack size wrong it may cause a problem.  Why not start
with fork, or just pthread_create only and then add it back once that
works?

Regards, Stuart

On Mon, 2007-06-04 at 16:17 +0200, Andrea Galbusera wrote:
> Hi all,
> 
> I'm building my linux system under the following conditions but I'am
> having problem with a simple threaded application I attach for
> reference. I'm new to thread programming so I might be using a wrong
> approach.
> 
> These are the system components and tools I'm using:
> * platform config forked from mpc5200 (powerpc)
> * standard toolchain referenced by this config
> (tc-mtwk-x86lnx-603e-3.4.3-1.i386)
> * the attached test app is being built within ltib with its own spec
> file (this should prevent any undesired reference to different
> libraries)
> 
> What I see is that the pthread_create() function is not returning, even
> if the thread is created and its executions starts.
> 
> I also tryed the same app with different glibc setup I have on another
> filesystem where the application seems to work good. In fact I've been
> using for a while a whole big application based on this code against
> that other glibc set. Now I'm moving the application under ltib and
> discovered the problem.
> 
> Does anybody have any idea why this discrepancy arises? Should I
> investigate more on the different glibc setups or am I making mistakes
> in coding threads? If useful I can provide glibc version and
> configuration options in the two environment.
> 
> TIA
> Regards,
> Andrea
> 
> ---------------- test app and makefile follow ------------------------
> 
> --------------------- main.c -----------------------------------------
> #include <sys/types.h>
> #include <sys/wait.h>
> #include <unistd.h>
> #include <string.h>
> 
> #include <pthread.h>
> #include <stdio.h>
> 
> #define CHILD_STACK_SIZE (1024*2)
> 
> static int child_process_stack[CHILD_STACK_SIZE+1];
> 
> void * thread_func (void* unused)
> {
>       while (1)
>       {
>               printf("This is the thread.\n");
>               sleep(2);
>       }
>       return NULL;
> }
> 
> int ChildProcess(void)
> {
>       pthread_t thread_id;
>       int retval;
> 
>       retval= pthread_create (&thread_id, NULL, &thread_func, NULL);
>       printf("pthread_create: retval= %d\n",retval);
>       while (1)
>       {
>               printf("This is child process.\n");
>               sleep(3);
>       }
> }
> 
> int main ()
> {
>       int retval;
>       int status_pid;
>       
>         status_pid = clone(ChildProcess,child_process_stack
> +CHILD_STACK_SIZE, CLONE_VM | SIGCHLD, (void *)NULL);
>       while (1)
>       {
>               printf("This is parent process.\n");
>               sleep(1);
>       }
>       return 0;
> }
> 
> ----------------------------------------------------------------------------
> 
> 
> 
> 
> 
> _______________________________________________
> LTIB home page: http://bitshrine.org
> 
> Ltib mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/ltib





reply via email to

[Prev in Thread] Current Thread [Next in Thread]