Using pthread on L4/Fiasco

=?ks_c_5601-1987?B?vK7H9sO2?= <[email protected]>
Newsgroups gmane.comp.micro-kernel.l4.devel
Message-ID <[email protected]>
Hi. Hackers

 

I¡¯m trying to use pthread in an application which runs on L4.

I modified ¡°main.c¡± in Hello application, including ¡°#include
<pthread.h>¡±.

And when I compiled L4Re, I got error messages:

 

 

main.o: In function `main':

/root/l4re-core-2011081207/src/l4/pkg/hello/server/src/main.c:39: undefined
reference to `pthread_create'

/root/l4re-core-2011081207/src/l4/pkg/hello/server/src/main.c:44: undefined
reference to `pthread_join'

make[5]: *** [hello] Error 1

 

 

I think this is because it cannot fine pthread.h header file. But I don¡¯t
know how to fix it.

 

When I looked up previous lists, I could find one thread related to pthread
in 2011 list.

(the thread title is ¡°Silly Pthread Issues¡±)

I think that it is the same problem, but the reply is only one. Said ¡°Add
REQUIRES_LIBS = libpthread to the Makefile.¡±

Actually, I tried it, but I couldn¡¯t solve the problem.

 

How can I use the pthread? Please, Help me!!

 

Thank you!

Hyunchul Seok

 

 

 

The modified code is below:

#include <stdio.h>

#include <unistd.h>

 

//#include <pthread-l4.h>

#include <pthread.h>

 

void *process_test(void *arg)

{

    int i = (int)arg;

    int j;

 

    for (;;)

    {

        for (j = 0; j < i; j++) {

            printf("  ");

        }

        printf("%d thread\n", i);

        sleep(i);

    }

}

 

int main(void)

{

    pthread_t threads[10];

    int status[10];

    int i;

 

    for (i = 0; i < 3; i++) {

        pthread_create(&threads[i], NULL, process_test, (void *)i);

        puts("New thread creation!");

    }

 

for (i = 0; i < 3; i++) {

        pthread_join(threads[i], (void **)&status[i]);

    }

 

    return 0;

}

_______________________________________________
l4-hackers mailing list
[email protected]
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.