Using Threads

Vance Shipley <>
Wed Jun 6 20:08:38 CEST 2001


I want to run a threaded system so that device drivers
can take advantage of threads for possibly slow operations.

The first thing I note is that the documentation doesn't
quite jive with the implementation.  

	erl <arguments>


	Starts the Erlang system. 

	Any argument starting with a plus sign (+) is always interpreted 
	as a system flag (described below), regardless of where it occurs 
	on the command line. 

	Arguments starting with a hyphen (-) are the start of a flag. A 
	flag includes all following arguments up to the next argument 
	starting with a hyphen. 
...
	System Flags

	The erl script invokes the code for the Erlang virtual machine. 
	This program supports the following flags: 

	+A size 
		Sets the pool size for device driver threads. Default is 0. 

OK, so then this should work (but doesn't):

C:\>erl +A 10
erl unknown flag -root
usage: erl [flags] [ -- [init_args] ]
The flags are:

-v         turn on chatty mode, GCs will be reported e
-l         turn on auto load tracing
-i module  set the boot module (default init)
-b fun     set the boot function (default boot)
-h number  set minimum heap size in words (default 233
-# number  set the number of items to be used in trace
-B         turn break handler off
-P number  set maximum number of processes on this nod
           valid range is [16-32768]
-A number  set number or threads in async thread pool
           valid range is [0-256]

OK, so it didn't work.  Now from the above usage message you might 
assume that the correct syntax would be:

C:\>erl -A 10
Eshell V5.0.2  (abort with ^G)
1> erlang:system_info(thread_pool_size) .
0
2>

However it isn't as you see.  The correct syntax is:

C:\>erl +A10
Eshell V5.0.2  (abort with ^G)
1> erlang:system_info(thread_pool_size).
10
2>


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

According to the release notes threading is supported on both Solaris
& Windows:

	There is now support for operating system threads in drivers. 
	The file driver has been modified to make use of this, which 
	means that lengthy file operations no longer cause everything 
	on the node to pause. Currently only supported on Solaris and 
	Windows. The number of threads in the thread pool can be set 
	with the emulator system flag -A. The default number of threads 
	is 0, which means that this feature is turned off. The number of 
	threads in a node can be obtained by the call 
	erlang:info(thread_pool_size). 


So now I'm digging into the build stuff to determine why I have no
working threads.  

Can anyone else get threads recognized on systems other than Windows?

	-Vance

Motivity Telecom Inc.
+1 519 579 5816







More information about the erlang-questions mailing list