By convention, most built-in functions (BIFs) are seen as being
in the module
In the text, auto-imported BIFs are listed without module prefix. BIFs listed with module prefix are not auto-imported.
BIFs may fail for a variety of reasons. All BIFs fail with
reason
Some BIFs may be used in guard tests, these are marked with "Allowed in guard tests".
A binary data object, structured according to the Erlang external term format.
See
Currently supported time unit representations:
Time unit expressed in parts per second. That is,
the time unit equals
Symbolic representation of the time unit
represented by the integer
Symbolic representation of the time unit
represented by the integer
Symbolic representation of the time unit
represented by the integer
Symbolic representation of the time unit
represented by the integer
Symbolic representation of the native time unit used by the Erlang runtime system.
The
One can get an approximation of the
The value of the
The
Returns an integer or float which is the arithmetical
absolute value of
> abs(-3.33). 3.33 > abs(-3). 3
Allowed in guard tests.
Computes and returns the adler32 checksum for
Continue computing the adler32 checksum by combining
the previous checksum,
The following code:
X = erlang:adler32(Data1),
Y = erlang:adler32(X,Data2).
- would assign the same value to
Y = erlang:adler32([Data1,Data2]).
Combines two previously computed adler32 checksums. This computation requires the size of the data object for the second checksum to be known.
The following code:
Y = erlang:adler32(Data1),
Z = erlang:adler32(Y,Data2).
- would assign the same value to
X = erlang:adler32(Data1),
Y = erlang:adler32(Data2),
Z = erlang:adler32_combine(X,Y,iolist_size(Data2)).
Returns a new tuple which has one element more than
> erlang:append_element({one, two}, three). {one,two,three}
Call a fun, passing the elements in
Note: If the number of elements in the arguments are known at
compile-time, the call is better written as
Earlier,
Returns the result of applying
> apply(lists, reverse, [[a, b, c]]). [c,b,a]
> apply(erlang, atom_to_list, ['Erlang']). "Erlang"
Note: If the number of arguments are known at compile-time,
the call is better written as
Failure:
Returns a binary which corresponds to the text
representation of
Currently,
> atom_to_binary('Erlang', latin1). <<"Erlang">>
Returns a string which corresponds to the text
representation of
> atom_to_list('Erlang'). "Erlang"
Extracts the part of the binary described by
Negative length can be used to extract bytes at the end of a binary:
1> Bin = <<1,2,3,4,5,6,7,8,9,10>>.
2> binary_part(Bin,{byte_size(Bin), -5}).
<<6,7,8,9,10>>
If
1> Bin = <<1,2,3>>
2> binary_part(Bin,{0,2}).
<<1,2>>
See the STDLIB module
Allowed in guard tests.
The same as
Allowed in guard tests.
Returns the atom whose text representation is
> binary_to_atom(<<"Erlang">>, latin1). 'Erlang' > binary_to_atom(<<1024/utf8>>, utf8). ** exception error: bad argument in function binary_to_atom/2 called as binary_to_atom(<<208,128>>,utf8)
Works like
Failure:
Returns the float whose text representation is
> binary_to_float(<<"2.2017764e+0">>). 2.2017764
Failure:
Returns an integer whose text representation is
> binary_to_integer(<<"123">>). 123
Failure:
Returns an integer whose text representation in base
> binary_to_integer(<<"3FF">>, 16). 1023
Failure:
Returns a list of integers which correspond to the bytes of
As
This function's indexing style of using one-based indices for
binaries is deprecated. New code should use the functions in
the STDLIB module
Returns a list of integers which correspond to the bytes of
Returns an Erlang term which is the result of decoding
the binary object
When decoding binaries from untrusted sources, consider using
See also
As
Use this option when receiving binaries from an untrusted source.
When enabled, it prevents decoding data that may be used to attack the Erlang system. In the event of receiving unsafe data, decoding fails with a badarg error.
Currently, this prevents creation of new atoms directly, creation of new atoms indirectly (as they are embedded in certain structures like pids, refs, funs, etc.), and creation of new external function references. None of those resources are currently garbage collected, so unchecked creation of them can exhaust available memory.
Failure:
See also
Returns an integer which is the size in bits of
> bit_size(<<433:16,3:3>>). 19 > bit_size(<<1,2,3>>). 24
Allowed in guard tests.
This implementation-dependent function increments the reduction counter for the calling process. In the Beam emulator, the reduction counter is normally incremented by one for each function and BIF call, and a context switch is forced when the counter reaches the maximum number of reductions for a process (2000 reductions in R12B).
This BIF might be removed in a future version of the Beam machine without prior warning. It is unlikely to be implemented in other Erlang implementations.
Returns an integer which is the number of bytes needed to contain
> byte_size(<<433:16,3:3>>). 3 > byte_size(<<1,2,3>>). 3
Allowed in guard tests.
Cancels a timer, where
See also
Note: Cancelling a timer does not guarantee that the message has not already been delivered to the message queue.
Returns
See also
The same as
Check if the node local process identified by
Currently available
If
See also
Failures:
Converts the
You may lose accuracy and precision when converting
between time units. In order to minimize such loss, collect all
data at
Computes and returns the crc32 (IEEE 802.3 style) checksum for
Continue computing the crc32 checksum by combining
the previous checksum,
The following code:
X = erlang:crc32(Data1),
Y = erlang:crc32(X,Data2).
- would assign the same value to
Y = erlang:crc32([Data1,Data2]).
Combines two previously computed crc32 checksums. This computation requires the size of the data object for the second checksum to be known.
The following code:
Y = erlang:crc32(Data1),
Z = erlang:crc32(Y,Data2).
- would assign the same value to
X = erlang:crc32(Data1),
Y = erlang:crc32(Data2),
Z = erlang:crc32_combine(X,Y,iolist_size(Data2)).
Returns the current date as
The time zone and daylight saving time correction depend on the underlying OS.
> date(). {1995,2,19}
Decodes the binary
If an entire packet is contained in
If
If the packet does not conform to the protocol format
The following values of
No packet handling is done. Entire binary is returned unless it is empty.
Packets consist of a header specifying the number of bytes in the packet, followed by that number of bytes. The length of header can be one, two, or four bytes; the order of the bytes is big-endian. The header will be stripped off when the packet is returned.
A packet is a line terminated with newline. The
newline character is included in the returned packet
unless the line was truncated according to the option
The header is not stripped off.
The meanings of the packet types are as follows:
The Hypertext Transfer Protocol. The packets
are returned with the format according to
Recognized request methods and header fields are returned as atoms.
Others are returned as strings. Strings of unrecognized header fields
are formatted with only capital letters first and after hyphen characters
(like
The protocol type
The variants
The following options are available:
Sets the max allowed size of the packet body. If the packet header indicates that the length of the packet is longer than the max allowed length, the packet is considered invalid. Default is 0 which means no size limit.
For packet type
Option
> erlang:decode_packet(1,<<3,"abcd">>,[]). {ok,<<"abc">>,<<"d">>} > erlang:decode_packet(1,<<5,"abcd">>,[]). {more,6}
Returns a new tuple with element at
> erlang:delete_element(2, {one, two, three}). {one,three}
Makes the current code for
This BIF is intended for the code server (see
Failure:
If
Once
Prior to OTP release R11B (erts version 5.5)
Current behavior can be viewed as two combined operations: asynchronously send a "demonitor signal" to the monitored entity and ignore any future results of the monitor.
Failure: It is an error if
The returned value is
Currently the following
Remove (one)
Calling
demonitor(MonitorRef),
receive
{_, MonitorRef, _, _, _} ->
true
after 0 ->
true
end
The returned value is one of the following:
The monitor was found and removed. In this case
no
The monitor was not found and could not be removed.
This probably because someone already has placed a
If the
More options may be added in the future.
Failure:
Forces the disconnection of a node. This will appear to
the node
Prints a text representation of
This BIF is intended for debugging only.
Returns the
> element(2, {a, b, c}). b
Allowed in guard tests.
Returns the process dictionary and deletes it.
> put(key1, {1, 2, 3}), put(key2, [a, b, c]), erase(). [{key1,{1,2,3}},{key2,[a,b,c]}]
Returns the value
> put(key1, {merry, lambs, are, playing}), X = erase(key1), {X, erase(key1)}. {{merry,lambs,are,playing},undefined}
Stops the execution of the calling process with the reason
> catch error(foobar). {'EXIT',{foobar,[{erl_eval,do_apply,5}, {erl_eval,expr,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]}}
Stops the execution of the calling process with the reason
Stops the execution of the calling process with the exit
reason
> exit(foobar). ** exception exit: foobar > catch exit(foobar). {'EXIT',foobar}
Sends an exit signal with exit reason
The following behavior apply if
If
If
If
Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:
> Size1 = byte_size(term_to_binary(Term )), > Size2 = erlang:external_size(Term ), > true = Size1 =< Size2. true
This is equivalent to a call to: erlang:external_size(
Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:
> Size1 = byte_size(term_to_binary(Term ,Options )), > Size2 = erlang:external_size(Term ,Options ), > true = Size1 =< Size2. true
The option
Returns a float by converting
> float(55). 55.0
Allowed in guard tests.
Note that if used on the top-level in a guard, it will
test whether the argument is a floating point number; for
clarity, use
When
The same as
Returns a binary which corresponds to the text
representation of
> float_to_binary(7.12, [{decimals, 4}]). <<"7.1200">> > float_to_binary(7.12, [{decimals, 4}, compact]). <<"7.12">>
The same as
Returns a string which corresponds to the text
representation of
> float_to_list(7.12, [{decimals, 4}]). "7.1200" > float_to_list(7.12, [{decimals, 4}, compact]). "7.12"
Returns a list containing information about the fun
This BIF is mainly intended for debugging, but it can occasionally be useful in library functions that might need to verify, for instance, the arity of a fun.
There are two types of funs with slightly different semantics:
A fun created by
All other funs are called local. When a local fun is called, the same version of the code that created the fun will be called (even if newer version of the module has been loaded).
The following elements will always be present in the list for both local and external funs:
If
If
If
If
The following elements will only be present in the list if
Returns information about
For any fun,
For a local fun,
See
Returns a string which corresponds to the text
representation of
Returns
Returns
Forces an immediate garbage collection of the currently executing process. The function should not be used, unless it has been noticed -- or there are good reasons to suspect -- that the spontaneous garbage collection will occur too late or not at all. Improper use may seriously degrade system performance.
The same as
Garbage collect the node local process identified by
Currently available
If
Note that the same caveats as for
Failures:
Returns the process dictionary as a list of
> put(key1, merry), put(key2, lambs), put(key3, {are, playing}), get(). [{key1,merry},{key2,lambs},{key3,{are,playing}}]
Returns the value
> put(key1, merry), put(key2, lambs), put({any, [valid, term]}, {are, playing}), get({any, [valid, term]}). {are,playing}
Returns the magic cookie of the local node, if the node is
alive; otherwise the atom
Returns a list of keys which are associated with the value
> put(mary, {1, 2}), put(had, {1, 2}), put(a, {1, 2}), put(little, {1, 2}), put(dog, {1, 3}), put(lamb, {1, 2}), get_keys({1, 2}). [mary,had,a,little,lamb]
Get the call stack back-trace (stacktrace) of the last
exception in the calling process as a list of
If there has not been any exceptions in a process, the
stacktrace is
The stacktrace is the same data as the
The second element of the tuple is a string (list of characters) representing the filename of the source file of the function.
The second element of the tuple is the line number (an integer greater than zero) in the source file where the exception occurred or the function was called.
See also
Returns the pid of the group leader for the process which evaluates the function.
Every process is a member of some process group and all
groups have a group leader. All IO from the group
is channeled to the group leader. When a new process is
spawned, it gets the same group leader as the spawning
process. Initially, at system start-up,
Sets the group leader of
See also
The same as
> halt(). os_prompt%
The same as
> halt(17). os_prompt% echo $? 17 os_prompt%
Note that on many platforms, only the status codes 0-255 are supported by the operating system.
For integer
For statuses
Returns a hash value for
This BIF is deprecated as the hash value may differ on
different architectures. Also the hash values for integer
terms larger than 2^27 as well as large binaries are very
poor. The BIF is retained for backward compatibility
reasons (it may have been used to hash records into a file),
but all new code should use one of the BIFs
Returns the head of
> hd([1,2,3,4,5]). 1
Allowed in guard tests.
Failure:
Puts the calling process into a wait state where its memory allocation has been reduced as much as possible, which is useful if the process does not expect to receive any messages in the near future.
The process will be awaken when a message is sent to it, and
control will resume in
If the process has any message in its message queue, the process will be awaken immediately in the same way as described above.
In more technical terms, what
If the size of the live data in the process is less than the minimum heap size, the first garbage collection occurring after the process has been awaken will ensure that the heap size is changed to a size not smaller than the minimum heap size.
Note that emptying the call stack means that any surrounding
Returns a new tuple with element
> erlang:insert_element(2, {one, two, three}, new). {one,new,two,three}
Returns a binary which corresponds to the text
representation of
> integer_to_binary(77). <<"77">>
Returns a binary which corresponds to the text
representation of
> integer_to_binary(1023, 16). <<"3FF">>
Returns a string which corresponds to the text
representation of
> integer_to_list(77). "77"
Returns a string which corresponds to the text
representation of
> integer_to_list(1023, 16). "3FF"
Returns a binary which is made from the integers and
binaries in
> Bin1 = <<1,2,3>>. <<1,2,3>> > Bin2 = <<4,5>>. <<4,5>> > Bin3 = <<6>>. <<6>> > iolist_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]). <<1,2,3,1,2,3,4,5,4,6>>
Returns an integer which is the size in bytes
of the binary that would be the result of
> iolist_size([1,2|<<3,4>>]). 4
Returns
Returns
Allowed in guard tests.
Returns
A binary always contains a complete number of bytes.
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns
Normally the compiler treats calls to
Allowed in guard tests, if
Allowed in guard tests, provided that
This BIF is documented for completeness. In most cases
Returns
Allowed in guard tests.
Returns
Allowed in guard tests.
Returns the length of
> length([1,2,3,4,5,6,7,8,9]). 9
Allowed in guard tests.
Creates a link between the calling process and another
process (or port)
If
Returns the atom whose text representation is
> list_to_atom("Erlang"). 'Erlang'
Returns a binary which is made from the integers and
binaries in
> Bin1 = <<1,2,3>>. <<1,2,3>> > Bin2 = <<4,5>>. <<4,5>> > Bin3 = <<6>>. <<6>> > list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]). <<1,2,3,1,2,3,4,5,4,6>>
Returns a bitstring which is made from the integers and
bitstrings in
> Bin1 = <<1,2,3>>. <<1,2,3>> > Bin2 = <<4,5>>. <<4,5>> > Bin3 = <<6,7:4,>>. <<6>> > list_to_bitstring([Bin1,1,[2,3,Bin2],4|Bin3]). <<1,2,3,1,2,3,4,5,4,6,7:46>>
Returns the atom whose text representation is
Failure:
Returns the float whose text representation is
> list_to_float("2.2017764e+0"). 2.2017764
Failure:
Returns an integer whose text representation is
> list_to_integer("123"). 123
Failure:
Returns an integer whose text representation in base
> list_to_integer("3FF", 16). 1023
Failure:
Returns a pid whose text representation is
This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.
> list_to_pid("<0.4.1>"). <0.4.1>
Failure:
Returns a tuple which corresponds to
> list_to_tuple([share, ['Ericsson_B', 163]]). {share, ['Ericsson_B', 163]}
If
The object code in
This BIF is intended for the code server (see
In releases older than OTP R14B, NIFs were an
experimental feature. Versions of OTP older than R14B might
have different and possibly incompatible NIF semantics and
interfaces. For example, in R13B03 the return value on
failure was
Loads and links a dynamic library containing native
implemented functions (NIFs) for a module.
The call to
It returns either
The OS failed to load the NIF library.
The library did not fulfil the requirements as a NIF library of the calling module.
The corresponding library callback was not successful.
The call to
Returns a list of all loaded Erlang modules (current and/or old code), including preloaded modules.
See also
Returns the current local date and time
The time zone and daylight saving time correction depend on the underlying OS.
> erlang:localtime(). {{1996,11,6},{14,45,17}}
Converts local date and time to Universal Time Coordinated
(UTC), if this is supported by the underlying OS. Otherwise,
no conversion is done and
> erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}). {{1996,11,6},{13,45,17}}
Failure:
Converts local date and time to Universal Time Coordinated
(UTC) just like
If
> erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, true). {{1996,11,6},{12,45,17}} > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, false). {{1996,11,6},{13,45,17}} > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, undefined). {{1996,11,6},{13,45,17}}
Failure:
Return a
Known issue: When a node is restarted multiple times with the same node name, references created on a newer node can be mistaken for a reference created on an older node with the same node name.
Returns a new tuple of the given
> erlang:make_tuple(4, []). {[],[],[],[]}
> erlang:make_tuple(5, [], [{2,ignored},{5,zz},{2,aa}]). {{[],aa,[],[],zz}
Returns an integer which is the number of key-value pairs in
> map_size(#{a=>1, b=>2, c=>3}). 3
Allowed in guard tests.
Return the largest of
Computes an
See The MD5 Message Digest Algorithm (RFC 1321) for more information about MD5.
The MD5 Message Digest Algorithm is not considered safe for code-signing or software integrity purposes.
Finishes the update of an MD5
Creates an MD5 context, to be used in subsequent calls to
Updates an MD5
Returns a list containing information about memory
dynamically allocated by the Erlang emulator. Each element of
the list is a tuple
The total amount of memory currently allocated, which is
the same as the sum of memory size for
The total amount of memory currently allocated by the Erlang processes.
The total amount of memory currently used by the Erlang processes.
This memory is part of the memory presented as
The total amount of memory currently allocated by the emulator that is not directly related to any Erlang process.
Memory presented as
The total amount of memory currently allocated for atoms.
This memory is part of the memory presented as
The total amount of memory currently used for atoms.
This memory is part of the memory presented as
The total amount of memory currently allocated for binaries.
This memory is part of the memory presented as
The total amount of memory currently allocated for Erlang code.
This memory is part of the memory presented as
The total amount of memory currently allocated for ets tables.
This memory is part of the memory presented as
Only on 64-bit halfword emulator.
The total amount of memory allocated in low memory areas that are restricted to less than 4 Gb even though the system may have more physical memory.
May be removed in future releases of halfword emulator.
The maximum total amount of memory allocated since the emulator was started.
This tuple is only present when the emulator is run with instrumentation.
For information on how to run the emulator with
instrumentation see
The
When the emulator is run with instrumentation,
the
Since the
The different amounts of memory that are summed are not gathered atomically which also introduce an error in the result.
The different values has the following relation to each other. Values beginning with an uppercase letter is not part of the result.
total = processes + system
processes = processes_used + ProcessesNotUsed
system = atom + binary + code + ets + OtherSystem
atom = atom_used + AtomNotUsed
RealTotal = processes + RealSystem
RealSystem = system + MissedSystem
More tuples in the returned list may be added in the future.
The
Since erts version 5.6.4
Failure:
Returns the memory size in bytes allocated for memory of
type
Since erts version 5.6.4
Failures:
See also
Return the smallest of
Returns
This BIF is intended for the code server (see
Send a monitor request of type
{Tag, MonitorRef , Type , Object, Info}
The monitor request is an asynchronous signal. That is, it takes time before the signal reach its destination.
Currently valid
Monitor the existence of the process identified by
The process identifier of the process to monitor.
A tuple consisting of a registered name of a process and
a node name. The process residing on the node
The process locally registered as
When a process is monitored by registered name, the process that has the registered name at the time when the monitor request reach its destination will be monitored. The monitor will not be effected, if the registered name is unregistered, or unregistered and later registered on another process.
The monitor is triggered either when the monitored process terminates, is non existing, or if the connection to it is lost. In the case the connection to it is lost, we do not know if it still exist or not. After this type of monitor has been triggered, the monitor is automatically removed.
When the monitor is triggered a
{'DOWN', MonitorRef, Type, Object, Info}
where
equals:
Either the exit reason of the process,
The monitoring is turned off either when the
If an attempt is made to monitor a process on an older node
(where remote process monitoring is not implemented or one
where remote process monitoring by registered name is not
implemented), the call fails with
The format of the
Monitor changes in
The monitor is triggered when the time offset is changed.
This either if the time offset value is changed, or if the
offset is changed from preliminary to final during
If the runtime system is in
The monitor will not be automatically removed after it has been triggered. That is, repeated changes of the time offset will trigger the monitor repeatedly.
When the monitor is triggered a
{'CHANGE', MonitorRef, Type, Item, NewTimeOffset}
where
When the
Making several calls to
The monitor functionality is expected to be extended. That is,
other
If/when
Monitors the status of the node
Making several calls to
If
Nodes connected through hidden connections can be monitored as any other node.
Failure:
Behaves as
The
Failure:
Returns the current
This is a
Different runtime system instances will use different
unspecified points in time as base for their Erlang monotonic clocks.
That is, it is pointless comparing monotonic times from
different runtime system instances. Different runtime system instances
may also place this unspecified point in time different relative
runtime system start. It may be placed in the future (time at start
will be a negative value), the past (time at start will be a
positive value), or the runtime system start (time at start will
be zero). The monotonic time as of runtime system start can be
retrieved by calling
Returns the current
Same as calling
Works exactly like
Works exactly like
Returns the name of the local node. If the node is not alive,
Allowed in guard tests.
Returns the node where
Allowed in guard tests.
Returns a list of all visible nodes in the system, excluding
the local node. Same as
Returns a list of nodes according to argument given. The result returned when the argument is a list, is the list of nodes satisfying the disjunction(s) of the list elements.
Nodes connected to this node through normal connections.
Nodes connected to this node through hidden connections.
All nodes connected to this node.
This node.
Nodes which are known to this node, i.e., connected, previously connected, etc.
Some equalities:
If the local node is not alive,
This function is deprecated! Do not use it!
See the users guide chapter
Returns the tuple
It can only be used to check the local time of day if the time-zone info of the underlying operating system is properly configured.
Returns a port identifier as the result of opening a new Erlang port. A port can be seen as an external Erlang process.
The name of the executable as well as the arguments
given in
The characters in the name (if given as a list) can only be > 255 if the Erlang VM is started in Unicode file name translation mode, otherwise the name of the executable is limited to the ISO-latin-1 character set.
Starts an external program.
When starting external programs on Solaris, the system
call
For external programs, the
Works like
Works like
The shell is not usually invoked to start the
program, it's executed directly. Neither is the
Only if a shell script or
If the
Allows an Erlang process to access any currently opened
file descriptors used by Erlang. The file descriptor
Messages are preceded by their length, sent in
Output messages are sent without packet lengths. A user-defined protocol must be used between the Erlang process and the external object.
Messages are delivered on a per line basis. Each line
(delimited by the OS-dependent newline sequence) is
delivered in one single message. The message data format
is
The
This is only valid for
This is only valid for
This option is only valid for
The arguments are not expanded by the shell prior to
being supplied to the executable, most notably this
means that file wildcard expansion will not happen. Use
Note also that the actual executable name (a.k.a.
If one, for any reason, wants to explicitly set the
program name in the argument vector, the
This option is only valid for
This is only valid for
When the external process connected to the port exits, a
message of the form
If the
If the port program closes its stdout without exiting,
the
This is only valid for
The opposite of
Affects ports to external programs. The executed program
gets its standard error file redirected to its standard
output file.
Affects ports to external programs on Windows® only. The standard input and standard output handles of the port program will, if this option is supplied, be opened with the flag FILE_FLAG_OVERLAPPED, so that the port program can (and has to) do overlapped I/O on its standard handles. This is not normally the case for simple port programs, but an option of value for the experienced Windows programmer. On all other platforms, this option is silently discarded.
The port can only be used for input.
The port can only be used for output.
All IO from the port are binary data objects as opposed to lists of bytes.
The port will not be closed at the end of the file and
produce an exit signal. Instead, it will remain open and
a
When running on Windows, suppress creation of a new console window when spawning the port program. (This option has no effect on other platforms.)
Set scheduler hint for port parallelism. If set to
The default is
Failure: If the port cannot be opened, the exit reason is
Bad input arguments to
All available ports in the Erlang emulator are in use.
There was not enough memory to create the port.
There are no more available operating system processes.
The external command given was too long.
There are no more available file descriptors (for the operating system process that the Erlang emulator runs in).
The file table is full (for the entire operating system).
The
The
During use of a port opened using
The maximum number of ports that can be open at the same
time can be configured by passing the
Portable hash function that will give the same hash for
the same Erlang term regardless of machine architecture and
ERTS version (the BIF was introduced in ERTS 4.9.1.1). Range
can be between 1 and 2^32, the function returns a hash value
for
This BIF could be used instead of the old deprecated
Portable hash function that will give the same hash for
the same Erlang term regardless of machine architecture and
ERTS version (the BIF was introduced in ERTS 5.2). Range can
be between 1 and 2^32, the function returns a hash value for
This BIF should always be used for hashing terms. It
distributes small integers better than
Note that the range
Returns a string which corresponds to the text
representation of
This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.
Closes an open port. Roughly the same as
For comparison:
Note that any process can close a port using
As of OTP-R16
Failure:
Sends data to a port. Same as
For comparison:
Note that any process can send to a port using
If the port is busy, the calling process will be suspended until the port is not busy anymore.
As of OTP-R16
Failures:
Sends data to a port.
If the port command is aborted
If the port is busy, the calling process will be suspended until the port is not busy anymore.
Currently the following
More options may be added in the future.
Failures:
Sets the port owner (the connected port) to
The error behavior differs, see below.
The port does not reply with
The new port owner gets linked to the port.
The old port owner stays linked to the port and have to call
For comparison:
Note that any process can set the port owner using
As of OTP-R16
Failures:
Performs a synchronous control operation on a port.
The meaning of
Returns: a list of integers in the range 0 through 255, or a binary, depending on the port driver. The meaning of the returned data also depends on the port driver.
Failure:
Performs a synchronous call to a port. The meaning of
Returns: a term from the driver. The meaning of the returned data also depends on the port driver.
Failures:
Returns a list containing tuples with information about
the
Currently the result will containt information about the
following
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
If the port identified by
Failure:
Returns a string which corresponds to the text
representation of the port identifier
This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.
Returns a list of port identifiers corresponding to all the ports currently existing on the local node.
Note that a port that is exiting, exists but is not open.
Returns a list of Erlang modules which are pre-loaded in
the system. As all loading of code is done through the file
system, the file system must have been loaded previously.
Hence, at least the module
Writes information about the local process
When
Returns the old value of the flag.
See also
This is used by a process to redefine the error handler for undefined function calls and undefined registered processes. Inexperienced users should not use this flag since code auto-loading is dependent on the correct operation of the error handling module.
Returns the old value of the flag.
This changes the minimum heap size for the calling process.
Returns the old value of the flag.
This changes the minimum binary virtual heap size for the calling process.
Returns the old value of the flag.
Internally in each priority level processes are scheduled in a round robin fashion.
Execution of processes on priority
When there are runnable processes on priority
When there are runnable processes on priority
Scheduling is preemptive. Regardless of priority, a process is preempted when it has consumed more than a certain amount of reductions since the last time it was selected for execution.
NOTE: You should not depend on the scheduling to remain exactly as it is today. Scheduling, at least on the runtime system with SMP support, is very likely to be modified in the future in order to better utilize available processor cores.
There is currently no automatic mechanism for avoiding priority inversion, such as priority inheritance, or priority ceilings. When using priorities you have to take this into account and handle such scenarios by yourself.
Making calls from a
Other priorities than
Returns the old value of the flag.
Returns the old value of the flag.
Set or clear the
Features that are disabled include (but are not limited to) the following:
Tracing: Trace flags can still be set for the process, but no
trace messages of any kind will be generated.
(If the
Sequential tracing: The sequential trace token will be propagated as usual, but no sequential trace messages will be generated.
Stack back-traces cannot be displayed for the process.
In crash dumps, the stack, messages, and the process dictionary will be omitted.
If
Returns the old value of the flag.
Sets certain flags for the process
Failure:
Returns a list containing
The order of the
See
This BIF is intended for debugging only, use
Failure:
Returns information about the process identified by
If the process is alive and a single
If an
If
Currently the following
The binary
Return the current call stack back-trace (stacktrace)
of the process. The stack has the same format as returned by
The value is
A list of pids that are monitoring the process (with
A list of monitors (started by
Note however, that not all implementations support every one
of the above
Failure:
Returns a list of process identifiers corresponding to all the processes currently existing on the local node.
Note that a process that is exiting, exists but is not alive, i.e.,
> processes(). [<0.0.0>,<0.2.0>,<0.4.0>,<0.5.0>,<0.7.0>,<0.8.0>]
Removes old code for
This BIF is intended for the code server (see
Failure:
Adds a new
The values stored when
> X = put(name, walrus), Y = put(name, carpenter), Z = get(name), {X, Y, Z}. {undefined,walrus,carpenter}
Stops the execution of the calling process with an exception of given class, reason and call stack backtrace (stacktrace).
This BIF is intended for debugging and for use in the Erlang operating system. In general, it should be avoided in applications, unless you know very well what you are doing.
The
The stacktrace is used as the exception stacktrace for the calling process; it will be truncated to the current maximum stacktrace depth.
Because evaluating this function causes the process to
terminate, it has no return value - unless the arguments are
invalid, in which case the function returns the error reason, that is
See also
Returns a string which corresponds to the text
representation of
This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.
Associates the name
> register(db, Pid). true
Failure:
Returns a list of names which have been registered using
> registered(). [code_server, file_server, init, user, my_db]
Decreases the suspend count on the process identified by
This BIF is intended for debugging only.
Failures:
Returns an integer by rounding
> round(5.5). 6
Allowed in guard tests.
Returns the pid (process identifier) of the calling process.
> self(). <0.26.0>
Allowed in guard tests.
Sends a message and returns
Sends a message and returns
The possible options are:
If the sender would have to be suspended to do the send,
If the destination node would have to be auto-connected
before doing the send,
As with
Starts a timer which will send the message
If
The
If
If
See also
Failure:
The same as
This function is intended for send operations towards an
unreliable remote node without ever blocking the sending
(Erlang) process. If the connection to the remote node
(usually not a real Erlang node, but a node written in C or
Java) is overloaded, this function will not send the message but return
The same happens, if
This function is only to be used in very rare circumstances
where a process communicates with Erlang nodes that can
disappear without any trace causing the TCP buffers and
the drivers queue to be over-full before the node will actually
be shut down (due to tick timeouts) by
Note that ignoring the return value from this function would
result in unreliable message passing, which is
contradictory to the Erlang programming model. The message is
not sent if this function returns
Note also that in many systems, transient states of
overloaded queues are normal. The fact that this function
returns
Use with extreme care!
The same as
This function behaves like
Whenever the function returns
Use with extreme care!
Sets the magic cookie of
Failure:
Returns a tuple which is a copy of the argument
> setelement(2, {10, green, bottles}, red). {10,red,bottles}
Returns an integer which is the size of the argument
> size({morni, mulle, bwange}). 3
Allowed in guard tests.
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
> spawn(speed, regulator, [high_speed, thin_cut]). <0.13.1>
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
Returns the pid of a new process started by the application
of
A new process is started by the application
of
Returns the pid of a new process started by the application
of
If the option
Returns the pid of a new process started by the application
of
Works exactly like
If the option
Sets a link to the parent process (like
Monitor the new process (just like
Sets the priority of the new process. Equivalent to
executing
This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters.
The Erlang runtime system uses a generational garbage collection scheme, using an "old heap" for data that has survived at least one garbage collection. When there is no more room on the old heap, a fullsweep garbage collection will be done.
The
Here are a few cases when it could be useful to change
This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters.
Gives a minimum heap size in words. Setting this value
higher than the system default might speed up some
processes because less garbage collection is done.
Setting too high value, however, might waste memory and
slow down the system due to worse data locality.
Therefore, it is recommended to use this option only for
fine-tuning an application and to measure the execution
time with various
This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters.
Gives a minimum binary virtual heap size in words. Setting this value
higher than the system default might speed up some
processes because less garbage collection is done.
Setting too high value, however, might waste memory.
Therefore, it is recommended to use this option only for
fine-tuning an application and to measure the execution
time with various
Returns the pid of a new process started by the application
of
The
Returns a tuple containing the binaries which are the result
of splitting
> B = list_to_binary("0123456789"). <<"0123456789">> > byte_size(B). 10 > {B1, B2} = split_binary(B,3). {<<"012">>,<<"3456789">>} > byte_size(B1). 3 > byte_size(B2). 7
Starts a timer which will send the message
If
The
If
If
See also
Failure:
This information may not be valid for all implementations.
> statistics(garbage_collection). {85,23961,0}
Since erts-5.5 (OTP release R11B)
this value does not include reductions performed in current
time slices of currently scheduled processes. If an
exact value is wanted, use
> statistics(reductions). {2046,11}
Returns the total length of the run queues, that is, the number of processes that are ready to run on all available run queues.
Note that the run-time is the sum of the run-time for all threads in the Erlang run-time system and may therefore be greater than the wall-clock time. The time is returned in milliseconds.
> statistics(runtime). {1690,1620}
Returns a list of tuples with
The definition of a busy scheduler is when it is not idle or not scheduling (selecting) a process or port, meaning; executing process code, executing linked-in-driver or NIF code, executing built-in-functions or any other runtime handling, garbage collecting or handling any other memory management. Note, a scheduler may also be busy even if the operating system has scheduled out the scheduler thread.
Returns
The list of scheduler information is unsorted and may appear in different order between calls.
Using
> erlang:system_flag(scheduler_wall_time, true). false > Ts0 = lists:sort(erlang:statistics(scheduler_wall_time)), ok. ok
Some time later we will take another snapshot and calculate scheduler-utilization per scheduler.
> Ts1 = lists:sort(erlang:statistics(scheduler_wall_time)), ok. ok > lists:map(fun({{I, A0, T0}, {I, A1, T1}}) -> {I, (A1 - A0)/(T1 - T0)} end, lists:zip(Ts0,Ts1)). [{1,0.9743474730177548}, {2,0.9744843782751444}, {3,0.9995902361669045}, {4,0.9738012596572161}, {5,0.9717956667018103}, {6,0.9739235846420741}, {7,0.973237033077876}, {8,0.9741297293248656}]
Using the same snapshots to calculate a total scheduler-utilization.
> {A, T} = lists:foldl(fun({{_, A0, T0}, {_, A1, T1}}, {Ai,Ti}) -> {Ai + (A1 - A0), Ti + (T1 - T0)} end, {0, 0}, lists:zip(Ts0,Ts1)), A/T. 0.9769136803764825
Increases the suspend count on the process identified by
A process can be suspended by multiple processes and can
be suspended multiple times by a single process. A suspended
process will not leave the suspended state until its suspend
count reach zero. The suspend count of
Currently the following options (
If the suspend count on the process identified by
This BIF is intended for debugging only.
Failures:
Suspends the process identified by
This BIF is intended for debugging only.
Sets the maximum depth of call stack back-traces in the
exit reason element of
Returns the old value of the flag.
Sets the user defined
Returns the old value of the flag.
The CPU topology is used when binding schedulers to logical processors. If schedulers are already bound when the CPU topology is changed, the schedulers will be sent a request to rebind according to the new CPU topology.
The user defined CPU topology can also be set by passing
the
For information on the
Returns the old value of the flag.
Note that the number of dirty CPU schedulers online may change if the number of
schedulers online changes. For example, if there are 12 schedulers and all are
online, and 6 dirty CPU schedulers, all online as well, and
Note that the dirty schedulers functionality is experimental, and that you have to enable support for dirty schedulers when building OTP in order to try out the functionality.
For more information see
Returns the old value of the flag.
In low-memory systems (especially without virtual memory), setting the value to 0 can help to conserve memory.
An alternative way to set this value is through the
(operating system) environment variable
Sets the default minimum heap size for processes. The
size is given in words. The new
Returns the old value of the flag.
Sets the default minimum binary virtual heap size for processes. The
size is given in words. The new
Returns the old value of the flag.
If
The return values are
NOTE: Blocking of multi-scheduling should normally not be needed. If you feel that you need to block multi-scheduling, think through the problem at least a couple of times again. Blocking multi-scheduling should only be used as a last resort since it will most likely be a very inefficient way to solve the problem.
See also
Controls if and how schedulers are bound to logical processors.
When
Schedulers can currently only be bound on newer Linux, Solaris, FreeBSD, and Windows systems, but more systems will be supported in the future.
In order for the runtime system to be able to bind schedulers,
the CPU topology needs to be known. If the runtime system fails
to automatically detect the CPU topology, it can be defined.
For more information on how to define the CPU topology, see
the
The runtime system will by default not bind schedulers to logical processors.
NOTE: If the Erlang runtime system is the only operating system process that binds threads to logical processors, this improves the performance of the runtime system. However, if other operating system processes (as for example another Erlang runtime system) also bind threads to logical processors, there might be a performance penalty instead. In some cases this performance penalty might be severe. If this is the case, you are advised to not bind the schedulers.
Schedulers can be bound in different ways. The
Same as the
Same as the
Same as the
Same as the
Same as the
Same as the
Same as the
Same as the
Same as the
The value returned equals
Failure:
If binding of schedulers is not supported.
If
If no CPU topology information is available.
The scheduler bind type can also be set by passing
the
For more information, see
For more information see,
Returns the old value of the flag.
Note that if the emulator was built with support for
For more information see,
Sets the value of the node's trace control word to
Returns the old value of the flag.
Finalizes the
Returns the old state identifier. That is, if:
Returns various information about the
Returns a list of tuples with information about miscellaneous allocated memory areas.
Each tuple contains an atom describing type of memory as first element and amount of allocated memory in bytes as second element. In those cases when there is information present about allocated and used memory, a third element is present. This third element contains the amount of used memory in bytes.
Note: The sum of these values is not
the total amount of memory allocated by the emulator.
Some values are part of other values, and some memory
areas are not part of the result. If you are interested
in the total amount of memory allocated by the emulator
see
Returns
Explanation:
See also "System Flags Effecting erts_alloc" in
Returns a list of the names of all allocators
using the ERTS internal
Returns information about the specified allocator.
As of erts version 5.6.1 the return value is a list
of
Note: The information returned is highly implementation dependent and may be changed, or removed at any time without prior notice. It was initially intended as a tool when developing new allocators, but since it might be of interest for others it has been briefly documented.
The recognized allocators are listed in
Returns various size information for the specified
allocator. The information returned is a subset of the
information returned by
Returns various information about the
Returns the
A level in the
Returns the user defined
Returns the automatically detected
For more information see the documentation of the
Returns the
Returns various information about the current system
(emulator) as specified by
See
Returns an atom describing the build type of the runtime
system. This is normally the atom
Returns a two-tuple describing the C compiler used when
compiling the runtime system. The first element is an
atom describing the name of the compiler, or
Returns a list containing miscellaneous information regarding the emulators internal I/O checking. Note, the content of the returned list may vary between platforms and over time. The only thing guaranteed is that a list is returned.
Returns the compatibility mode of the local node as
an integer. The integer returned represents the
Erlang/OTP release which the current emulator has been
set to be backward compatible with. The compatibility
mode can be configured at startup by using the command
line flag
See
Returns the creation of the local node as an integer. The creation is changed when a node is restarted. The creation of a node is stored in process identifiers, port identifiers, and references. This makes it (to some extent) possible to distinguish between identifiers from different incarnations of a node. Currently valid creations are integers in the range 1..3, but this may (probably will) change in the future. If the node is not alive, 0 is returned.
Returns
Returns the number of dirty CPU scheduler threads used by the emulator. Dirty CPU schedulers execute CPU-bound native functions such as NIFs, linked-in driver code, and BIFs that cannot be managed cleanly by the emulator's normal schedulers.
The number of dirty CPU scheduler threads is determined at emulator
boot time and cannot be changed after that. The number of dirty CPU
scheduler threads online can however be changed at any time. The number of
dirty CPU schedulers can be set on startup by passing
the
Note that the dirty schedulers functionality is experimental, and that you have to enable support for dirty schedulers when building OTP in order to try out the functionality.
See also
Returns the number of dirty CPU schedulers online. The return value
satisfies the following relationship:
The number of dirty CPU schedulers online can be set on startup by passing
the
Note that the dirty schedulers functionality is experimental, and that you have to enable support for dirty schedulers when building OTP in order to try out the functionality.
For more information, see
Returns the number of dirty I/O schedulers as an integer. Dirty I/O schedulers execute I/O-bound native functions such as NIFs and linked-in driver code that cannot be managed cleanly by the emulator's normal schedulers.
This value can be set on startup by passing
the
Note that the dirty schedulers functionality is experimental, and that you have to enable support for dirty schedulers when building OTP in order to try out the functionality.
For more information, see
Returns a binary containing a string of distribution
information formatted as in Erlang crash dumps. For more
information see the
Returns the value of the distribution buffer busy limit
in bytes. This limit can be set on startup by passing the
Returns a list of tuples
Returns a string containing the erlang driver version
used by the runtime system. It will be on the form
Returns an atom describing the dynamic trace framework
compiled into the virtual machine. It can currently be either
Returns a
This option will be removed in a future release.
The return value will always be
Returns the value of the
Returns the maximum number of ETS tables allowed. This limit
can be increased on startup by passing the
Returns
Returns a list describing the default garbage collection
settings. A process spawned on the local node by a
Returns a list of integers representing valid heap sizes in words. All Erlang heaps are sized from sizes in this list.
Returns the heap type used by the current emulator. Currently only the following heap type exists:
Each process has a heap reserved for its use and no references between heaps of different processes are allowed. Messages passed between processes are copied between heaps.
Returns a binary containing a string of miscellaneous
system information formatted as in Erlang crash dumps.
For more information see the
Returns
Returns a binary containing a string of loaded module
information formatted as in Erlang crash dumps. For more
information see the
Returns the detected number of logical processors configured
on the system. The return value is either an integer, or
the atom
Returns the detected number of logical processors available to
the Erlang runtime system. The return value is either an
integer, or the atom
Returns the detected number of logical processors online on
the system. The return value is either an integer,
or the atom
Returns a string containing the Erlang machine name.
Returns
Returns
Returns the modified timing level (an integer) if
modified timing has been enabled; otherwise,
Returns
The emulator has only one scheduler thread. The emulator does not have SMP support, or have been started with only one scheduler thread.
The emulator has more than one scheduler thread, but all scheduler threads but one have been blocked, i.e., only one scheduler thread will schedule Erlang processes and execute Erlang code.
The emulator has more than one scheduler thread, and no scheduler threads have been blocked, i.e., all available scheduler threads will schedule Erlang processes and execute Erlang code.
See also
Returns a list of
See also
Returns a string containing the erlang NIF version used by the runtime system. It will be on the form "<major ver>.<minor ver>".
Returns a string containing the OTP release number of the OTP release that the currently executing ERTS application is part of.
As of OTP release 17, the OTP release number corresponds to
the major OTP version number. There is no
Returns a list containing information about the source of
In case
This tuple only exist if
Highest possible
Returns a list containing information about the source of
The list contains two-tuples with
This tuple only exist if
Highest possible
Returns the default port parallelism scheduling hint used.
For more information see the
Returns the number of ports currently existing at
the local node as an integer. The same value as
Returns the maximum number of simultaneously existing
ports at the local node as an integer. This limit
can be configured at startup by using the
Returns the number of processes currently existing at
the local node as an integer. The same value as
Returns the maximum number of simultaneously existing
processes at the local node as an integer. This limit
can be configured at startup by using the
Returns a binary containing a string of process and port
information formatted as in Erlang crash dumps. For more
information see the
Returns information on how user has requested schedulers to be bound or not bound.
NOTE: Even though user has requested
schedulers to be bound, they might have silently failed
to bind. In order to inspect actual scheduler bindings call
For more information, see
the
Returns information on currently used scheduler bindings.
A tuple of a size equal to
Note that only schedulers online can be bound to logical processors.
For more information, see
the
Returns the scheduler id (
Returns the number of scheduler threads used by the emulator. Scheduler threads online schedules Erlang processes and Erlang ports, and execute Erlang code and Erlang linked in driver code.
The number of scheduler threads is determined at emulator boot time and cannot be changed after that. The amount of schedulers online can however be changed at any time.
See also
Returns the amount of schedulers online. The scheduler
identifiers of schedulers online satisfy the following
relationship:
For more information, see
Returns
The
Returns a string containing version number and some important properties such as the number of schedulers.
Returns a string containing the processor and OS architecture the emulator is built for.
Returns
Returns the number of async threads in the async thread
pool used for asynchronous driver calls
(
Returns a boolean value indicating whether
Returns the state of the time offset:
The time offset is preliminary, and will be changed
at a later time when being finalized. The preliminary time offset
is used during the preliminary phase of the
The time offset is final. This
either due to the use of the
The time offset is volatile. That is, it may
change at any time. This due to the
Returns a value identifying the
The
The
The
Returns whether a pre erts-7.0 backwards compatible compensation
for sudden changes of system time is
Returns the value of the node's trace control word.
For more information see documentation of the function
The runtime system rereads the CPU information available and
updates its internally stored information about the
Returns a string containing the version number of the emulator.
Same as
Returns the size of Erlang term words in bytes as an integer, i.e. on a 32-bit architecture 4 is returned, and on a pure 64-bit architecture 8 is returned. On a halfword 64-bit emulator, 4 is returned, as the Erlang terms are stored using a virtual wordsize of half the system's wordsize.
Returns the true wordsize of the emulator, i.e. the size of a pointer, in bytes as an integer. On a pure 32-bit architecture 4 is returned, on both a halfword and pure 64-bit architecture, 8 is returned.
The
Returns the current system monitoring settings set by
When called with the argument
Calling the function with
Returns the previous system monitor settings just like
Sets system performance monitoring options.
If a garbage collection in the system takes at least
If a process or port in the system runs uninterrupted
for at least
This can be used to detect problems with NIF's or drivers that take too long to execute. Generally, 1 ms is considered a good maximum time for a driver callback or a NIF. However, a time sharing system should usually consider everything below 100 ms as "possible" and fairly "normal". Schedule times above that might however indicate swapping or a NIF/driver that is misbehaving. Misbehaving NIF's and drivers could cause bad resource utilization and bad overall performance of the system.
If a garbage collection in the system results in
the allocated size of a heap being at least
If a process in the system gets suspended because it
sends to a busy port, a message
If a process in the system gets suspended because it
sends to a process on a remote node whose inter-node
communication was handled by a busy port, a message
Returns the previous system monitor settings just like
If a monitoring process gets so large that it itself starts to cause system monitor messages when garbage collecting, the messages will enlarge the process's message queue and probably make the problem worse.
Keep the monitoring process neat and do not set the system monitor limits too tight.
Failure:
Returns the current system profiling settings set by
Sets system profiler options.
If a synchronous call to a port from a process is done, the
calling process is considered not runnable during the call
runtime to the port. The calling process is notified as
If a process is put into or removed from the run queue a message,
If a port is put into or removed from the run queue a message,
If a scheduler is put to sleep or awoken a message,
Returns current
Calling
This time is not a monotonically increasing time
in the general case. For more information, see the documentation of
Returns current
Calling
This time is not a monotonically increasing time
in the general case. For more information, see the documentation of
Returns a binary data object which is the result of encoding
This can be used for a variety of purposes, for example writing a term to a file in an efficient way, or sending an Erlang term to some type of communications channel not supported by distributed Erlang.
See also
Returns a binary data object which is the result of encoding
If the option
It is also possible to specify a compression level by giving
the option
Currently,
The option
See also
A non-local return from a function. If evaluated within a
> catch throw({hello, there}). {hello,there}
Failure:
Returns the current time as
The time zone and daylight saving time correction depend on the underlying OS.
> time(). {9,42,44}
Returns the current time offset between
The time offset may or may not change during operation depending
on the
A change in time offset may be observed at slightly different points in time by different processes.
If the runtime system is in
Returns the current time offset between
Same as calling
Returns current
The
timestamp() ->
ErlangSystemTime = erlang:system_time(micro_seconds),
MegaSecs = ErlangSystemTime div 1000000000000,
Secs = ErlangSystemTime div 1000000 - MegaSecs*1000000,
MicroSecs = ErlangSystemTime rem 1000000,
{MegaSecs, Secs, MicroSecs}.
It however use a native implementation which does not build garbage on the heap and with slightly better performance.
This time is not a monotonically increasing time
in the general case. For more information, see the documentation of
Returns the tail of
> tl([geesties, guilies, beasties]). [guilies, beasties]
Allowed in guard tests.
Failure:
Turns on (if
All processes currently existing.
All processes that will be created in the future.
All currently existing processes and all processes that will be created in the future.
Set all trace flags except
Trace sending of messages.
Message tags:
Trace receiving of messages.
Message tags:
Trace process related events.
Message tags:
Trace certain function calls. Specify which function
calls to trace by calling
Message tags:
Used in conjunction with the
Silent mode is inhibited by executing
The
Message tags:
Used in conjunction with the
The semantics is that a trace message is sent when a
call traced function actually returns, that is, when a
chain of tail recursive calls is ended. There will be
only one trace message sent per chain of tail recursive
calls, why the properties of tail recursiveness for
function calls are kept while tracing with this flag.
Using
To get trace messages containing return values from
functions, use the
Message tags:
Trace scheduling of processes.
Message tags:
Trace scheduling of an exiting processes.
Message tags:
Trace garbage collections of processes.
Message tags:
Include a time stamp in all trace messages. The time
stamp (Ts) is of the same form as returned by
A global trace flag for the Erlang node that makes all
trace timestamps be in CPU time, not wallclock. It is
only allowed with
Used in conjunction with the
Makes any process created by a traced process inherit
its trace flags, including the
Makes the first process created by a traced process
inherit its trace flags, excluding
the
Makes any process linked by a traced process inherit its
trace flags, including the
Makes the first process linked to by a traced process
inherit its trace flags, excluding
the
Specify where to send the trace messages.
The effect of combining
If the
If the
When
When
When
When
Note that the trace flag
When
When
When
When
Note that
When
When
When
When
When
When
When
When
When
Sent when garbage collection is about to be started.
All sizes are in words.
Sent when garbage collection is finished.
If the tracing process dies, the flags will be silently removed.
Only one process can trace a particular process. For this reason, attempts to trace an already traced process will fail.
Returns: A number indicating the number of processes that
matched
Failure: If specified arguments are not supported. For
example
The delivery of trace messages is dislocated on the time-line
compared to other events in the system. If you know that the
Note that the
Note that
An example: Process
Failure:
Returns trace information about a process or function.
To get information about a process,
Return a list of atoms indicating what kind of traces is
enabled for the process. The list will be empty if no
traces are enabled, and one or more of the followings
atoms if traces are enabled:
Return the identifier for process or port tracing this
process. If this process is not being traced, the return
value will be
To get information about a function,
Return
Return the match specification for this function, if it
has one. If the function is locally or globally traced but
has no match specification defined, the returned value
is
Return the meta trace tracer process or port for this
function, if it has one. If the function is not meta
traced the returned value is
Return the meta trace match specification for this
function, if it has one. If the function is meta traced
but has no match specification defined, the returned
value is
Return the call count value for this function or
Return the call time values for this function or
Return a list containing the
The actual return value will be
If
The same as
This BIF is used to enable or disable call tracing for
exported functions. It must be combined with
Conceptually, call tracing works like this: Inside the Erlang virtual machine there is a set of processes to be traced and a set of functions to be traced. Tracing will be enabled on the intersection of the set. That is, if a process included in the traced process set calls a function included in the traced function set, the trace action will be taken. Otherwise, nothing will happen.
Use
The
The
All exported functions of any arity named
All exported functions in module
All exported functions in all loaded modules.
Other combinations, such as
If the
The
Disable tracing for the matching function(s). Any match specification will be removed.
Enable tracing for the matching function(s).
A list of match specifications. An empty list is
equivalent to
For the
For the
The
Turn on or off call tracing for global function calls (that is, calls specifying the module explicitly). Only exported functions will match and only global calls will generate trace messages. This is the default.
Turn on or off call tracing for all types of function
calls. Trace messages will be sent whenever any of
the specified functions are called, regardless of how they
are called. If the
Turn on or off meta tracing for all types of function
calls. Trace messages will be sent to the tracer process
or port
Meta tracing traces all processes and does not care
about the process trace flags set by
The match spec function
Starts (
If call count tracing is started while already running,
the count is restarted from zero. Running counters can be
paused with
The counter value can be read with
Starts (
If call time tracing is started while already running,
the count and time is restarted from zero. Running counters can be
paused with
The counter value can be read with
The
When disabling trace, the option must match the type of trace
that is set on the function, so that local tracing must be
disabled with the
There is no way to directly change part of a match
specification list. If a function has a match specification,
you can replace it with a completely new one. If you need to
change an existing match specification, use the
Returns the number of exported functions that matched
the
Returns an integer by the truncating
> trunc(5.5). 5
Allowed in guard tests.
Returns an integer which is the number of elements in
> tuple_size({morni, mulle, bwange}). 3
Allowed in guard tests.
Returns a list which corresponds to
> tuple_to_list({share, {'Ericsson_B', 163}}). [share,{'Ericsson_B',163}]
Returns the current date and time according to Universal
Time Coordinated (UTC), also called GMT, in the form
> erlang:universaltime(). {{1996,11,6},{14,18,43}}
Converts Universal Time Coordinated (UTC) date and time to
local date and time, if this is supported by the underlying
OS. Otherwise, no conversion is done, and
> erlang:universaltime_to_localtime({{1996,11,6},{14,18,43}}). {{1996,11,7},{15,18,43}}
Failure:
Generates and returns an
Generates and returns an
By default, i.e. when
Currently valid
Return only positive integers.
Note that by passing the
Return
These values can be used when ordering events
on the runtime system instance. That is, if both
Strictly monotonically increasing values
are inherently quite expensive to generate and scales
poorly. This since the values needs to be
synchronized. That is, do not pass the
All currently valid
Note that the set of integers returned by
Failures:
Removes the link, if there is one, between the calling
process and the process or port referred to by
Returns
Once
unlink(Id),
receive
{'EXIT', Id, _} ->
true
after 0 ->
true
end
Prior to OTP release R11B (erts version 5.5)
Current behavior can be viewed as two combined operations: asynchronously send an "unlink signal" to the linked entity and ignore any future results of the link.
Removes the registered name
> unregister(db). true
Users are advised not to unregister system processes.
Failure:
Returns the pid or port identifier with the registered name
> whereis(db). <0.43.0>
Voluntarily let other processes (if any) get a chance to
execute. Using
There is seldom or never any need to use this BIF, especially in the SMP-emulator as other processes will have a chance to run in another scheduler thread anyway. Using this BIF without a thorough grasp of how the scheduler works may cause performance degradation.