Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

threads vs. pthread in perl

I wonder what the different is between the options 'THREADS' and 'PTHREAD' when I compile perl 5.16 (and other version) from port source in freebsd?

Is the PTHREAD the posix-threading? (because -pthread) And if so, is it prefered to 'THREADS'? (because it seems to be preselected) even on freebsd? And what is 'THREADS' (Kernel threads?) on the other hand? What are the pros and cons?

Could I use both in one installation? Is it sensefull?

There is not to much to find around in combination with perl, as far as I can see.

thanks a lot jimmy

like image 890
Jimmy Koerting Avatar asked Nov 27 '12 15:11

Jimmy Koerting


1 Answers

Using threads is as others have described it of course.

The link with pthread means that your perl is built with the -pthread flag. This has a subtle but important effect. It means that when perl starts up, the libc data that maintains state for threads is initialized. This means that if your perl calls dlopen() on a library which is threaded, it will work properly, instead of hanging.

PS. I'm actually the person who wrote and committed the PTHREAD option to the port. I actually discovered some perl modules which dlopen()'d some threaded libs and caused perl to hang. Took me a while to figure out why. Trust me, you want the PTHREAD option on. I'm actually thinking of removing the option to turn it off. For more info, see FreeBSD PR 163512 and 163878. We probably should push this option upstream so that perl uses this by default on FreeBSD. Anything that may call dlopen() should really be built with -pthread.

like image 94
Steve Wills Avatar answered Sep 25 '22 22:09

Steve Wills