Using Threads
Scott Lystig Fritchie
fritchie@REDACTED
Thu Jun 7 15:05:05 CEST 2001
>>>>> "sh" == Sean Hinde <Sean.Hinde@REDACTED> writes:
sh> [The +A flag] works as below for the commercial Solaris version on my
sh> machine:
sh> [...]
sh> The version I compiled from open source gives the same response as
sh> you got.
If I recall correctly, I had to do a couple of things to get threads
support with the open source release. I don't have time to confirm
them before sending this message, but perhaps you can work it out from
here. {shrug}
Disclaimer: this is what I recall I had to do with open source R7B-1
under Linux, FreeBSD, and Solaris. YMMV.
After running the top-level "configure", I had to manually edit
erts/emulator/Makefile to add what configure should've added when
using the I-forget-the-configure-flag-that-should've-enabled-os-
thread-support (enable-threads?). The configure-substituted symbols
are THR_DEFS (in CFLAGS) and THR_LIBS (in LIBS) (see
erts/emulator/Makefile.in). The OS-appropriate values for the THR_*
symbols can be found in erts/autoconf/configure.
Solaris & Linux:
THR_LIBS="-lpthread"
THR_DEFS="-DUSE_THREADS -D_REENTRANT"
THR_DEFS="$THR_DEFS -DPOSIX_THREADS -D_THREAD_SAFE"
FreeBSD:
THR_LIBS="-lc_r"
THR_DEFS="-DUSE_THREADS -D_REENTRANT"
THR_DEFS="$THR_DEFS -DPOSIX_THREADS -D_THREAD_SAFE"
You'll come to much grief and woe if you don't include -DUSE_THREADS
*and* -D_REENTRANT.
If you did the build stuff correctly, you'd see this at startup:
% erl
Erlang (BEAM) emulator version 5.0.1.1 [source] [threads]
Eshell V5.0.1.1 (abort with ^G)
1>
Second, I recall (fuzzy memory) that the +A flag still didn't work. I
had to set the ERL_THREAD_POOL_SIZE environment variable to get
erlang:system_info(thread_pool_size) to spit out something non-zero.
-Scott
More information about the erlang-questions
mailing list