ltib
[Top][All Lists]
Advanced

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

[Ltib] threads on mpc5200 ltib platform


From: Andrea Galbusera
Subject: [Ltib] threads on mpc5200 ltib platform
Date: Mon, 04 Jun 2007 16:17:47 +0200

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;
}

----------------------------------------------------------------------------







reply via email to

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