Using Threads

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Threads

Sean Hinde-2
Vance,

> Now the next question I have is why I can't get threads at all on
> any system other than Windows.  Solaris is supposed to be supported
> but mine doesn't seam to work:
>
> $ erl +A10
> Erlang (BEAM) emulator version 5.0.1.1 [source]
>
> Eshell V5.0.1.1  (abort with ^G)
> 1> erlang:system_info(thread_pool_size).
> 0


This works as below for the commercial Solaris version on my machine:

erl +A10
Erlang (BEAM) emulator version 5.0.2.2 [threads]

Eshell V5.0.2.2 (abort with ^G)
1> erlang:system_info(thread_pool_size).
10

The version I compiled from open source gives the same response as you got.

I wonder if the little [threads] logo might give a clue ??

Rgds,
Sean



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.



Reply | Threaded
Open this post in threaded view
|

Using Threads

Rickard Green-3
Hello,

The emulator is by default not built with thread support in the open
source release. In order to enable thread support one is supposed to
pass the "--enable-threads" argument to the configure script; but, due
to a bug this doesn't work. One can easily bypass this bug, though.

Do the following to build the open source release with thread support:

  # Set the ERL_TOP environment variable to the absolute path of the
  # top level directory

  cd $ERL_TOP
  ./configure --enable-threads $MY_OTHER_CONFIG_ARGS

  cd $ERL_TOP/erts/autoconf                           # These steps
  ./configure --enable-threads $MY_OTHER_CONFIG_ARGS  # bypass the
  cd $ERL_TOP                                         # bug.

  make
  make install

If you succeeded "[threads]" should pop up on the first line in the
Erlang shell.

This bug will be fixed in the next patch to r7b01.


/Rickard Green, Erlang/OTP, Ericsson UAB


Sean Hinde wrote:

>
> Vance,
>
> > Now the next question I have is why I can't get threads at all on
> > any system other than Windows.  Solaris is supposed to be supported
> > but mine doesn't seam to work:
> >
> > $ erl +A10
> > Erlang (BEAM) emulator version 5.0.1.1 [source]
> >
> > Eshell V5.0.1.1  (abort with ^G)
> > 1> erlang:system_info(thread_pool_size).
> > 0
>
> This works as below for the commercial Solaris version on my machine:
>
> erl +A10
> Erlang (BEAM) emulator version 5.0.2.2 [threads]
>
> Eshell V5.0.2.2 (abort with ^G)
> 1> erlang:system_info(thread_pool_size).
> 10
>
> The version I compiled from open source gives the same response as you got.
>
> I wonder if the little [threads] logo might give a clue ??
>
> Rgds,
> Sean
>
> NOTICE AND DISCLAIMER:
> This email (including attachments) is confidential.  If you have received
> this email in error please notify the sender immediately and delete this
> email from your system without copying or disseminating it or placing any
> reliance upon its contents.  We cannot accept liability for any breaches of
> confidence arising through use of email.  Any opinions expressed in this
> email (including attachments) are those of the author and do not necessarily
> reflect our opinions.  We will not accept responsibility for any commitments
> made by our employees outside the scope of our business.  We do not warrant
> the accuracy or completeness of such information.



Reply | Threaded
Open this post in threaded view
|

Using Threads

Scott Lystig Fritchie-3
In reply to this post by Sean Hinde-2
>>>>> "sh" == Sean Hinde <Sean.Hinde> 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


Reply | Threaded
Open this post in threaded view
|

Using Threads

Daniel Neri
Scott Lystig Fritchie <fritchie> writes:

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

Aren't you supposed to use the "-pthread" option[*] to cc, to
compile/link pthreaded stuff on FreeBSD?


Regards,
    --Daniel


[*] http://www.FreeBSD.org/cgi/man.cgi?query=pthread&apropos=0&sektion=0&manpath=FreeBSD+4.3-RELEASE&format=html

--
Daniel Neri
dne