opensubscriber
   Find in this group all groups
 
Unknown more information…

l : l4-hackers@os.inf.tu-dresden.de 23 May 2012 • 4:08PM -0400

Re: Using pthread on L4/Fiasco
by Marcus Haehnel

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi,

Am 2012-05-23 09:01, schrieb 석현철:
> 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.
>

The error message has nothing to do with the header, as it is an error
in the link phase, where the symbols of the libpthread can not be
resolved.


> 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.”
>

Yes, you need to include this line in your Makefile and for me this
leads to the program linking correctly.
Are you sure you included it in server/src/Makefile and not somewhere
else? Can you show us your Makefile and the Output of

make V=1

to see the compiler and linker commands invoked?


> Actually, I tried it, but I couldn’t solve the problem.
>
> How can I use the pthread? Please, Help me!!
>
> Thank you!
>
> Hyunchul Seok
>


Kind regards,

Marcus

> 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 threadn", 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
l4-hackers@os.i...
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.