An Erlang driver is a library containing a set of native driver callback functions that the Erlang Virtual Machine calls when certain events occur. There can be multiple instances of a driver, each instance is associated with an Erlang port.
Use this functionality with extreme care.
A driver callback is executed as a direct extension of the native code of the VM. Execution is not made in a safe environment. The VM cannot provide the same services as provided when executing Erlang code, such as pre-emptive scheduling or memory protection. If the driver callback function does not behave well, the whole VM will misbehave.
A driver callback that crash will crash the whole VM.
An erroneously implemented driver callback can cause a VM internal state inconsistency, which can cause a crash of the VM, or miscellaneous misbehaviors of the VM at any point after the call to the driver callback.
A driver callback doing
As from ERTS 5.5.3 the driver interface has been extended
(see
As from ERTS 5.9 old drivers must be recompiled
and use the extended interface. They must also be adjusted to the
The driver calls back to the emulator, using the API
functions declared in
Each driver instance is associated with a port. Every port
has a port owner process. Communication with the port is normally
done through the port owner process. Most of the functions take
the
Some of the functions take a parameter of type
Many of the output functions have a "header buffer", with
Most drivers written before the runtime system with SMP support existed can run in the runtime system with SMP support, without being rewritten, if driver level locking is used.
It is assumed that drivers do not access other drivers. If drivers access each other, they must provide their own mechanism for thread-safe synchronization. Such "inter-driver communication" is strongly discouraged.
Previously, in the runtime system without SMP support, specific driver callbacks were always called from the same thread. This is not the case in the runtime system with SMP support. Regardless of locking scheme used, calls to driver callbacks can be made from different threads. For example, two consecutive calls to exactly the same callback for exactly the same port can be made from two different threads. This is for most drivers not a problem, but it can be. Drivers that depend on all callbacks that are called in the same thread, must be rewritten before they are used in the runtime system with SMP support.
Regardless of locking scheme used, calls to driver callbacks can be made from different threads.
Most functions in this API are not thread-safe, that is, they cannot be called from any thread. Functions that are not documented as thread-safe can only be called from driver callbacks or function calls descending from a driver callback call. Notice that driver callbacks can be called from different threads. This, however, is not a problem for any function in this API, as the emulator has control over these threads.
Functions not explicitly documented as thread-safe are not thread safe. Also notice that some functions are only thread-safe when used in a runtime system with SMP support.
A function not explicitly documented as thread-safe can, at some point in time, have a thread-safe implementation in the runtime system. Such an implementation can however change to a thread unsafe implementation at any time without any notice.
Only use functions explicitly documented as thread-safe from arbitrary threads.
All functions that a driver needs to do with Erlang are performed through driver API functions. Functions exist for the following functionality:
Control the timer that a driver can use. The timer has the
emulator call the
Every driver instance has an associated queue. This queue is a
The queue can be manipulated from any threads if
a port data lock is used. For more information, see
With these functions, the driver sends data back to the emulator.
The data is received as messages by the port owner process, see
The driver can exit and signal errors up to Erlang. This is only for severe errors, when the driver cannot possibly keep open.
Erlang/OTP R7B and later versions have provision for asynchronous function calls, using a thread pool provided by Erlang. There is also a select call, which can be used for asynchronous drivers.
A POSIX thread like API for multi-threading is provided. The Erlang driver thread API only provides a subset of the functionality provided by the POSIX thread API. The subset provided is more or less the basic functionality needed for multi-threaded programming:
The Erlang driver thread API can be used in conjunction with the POSIX thread API on UN-ices and with the Windows native thread API on Windows. The Erlang driver thread API has the advantage of being portable, but there can exist situations where you want to use functionality from the POSIX thread API or the Windows native thread API.
The Erlang driver thread API only returns error codes when it is reasonable to recover from an error condition. If it is not reasonable to recover from an error condition, the whole runtime system is terminated. For example, if a create mutex operation fails, an error code is returned, but if a lock operation on a mutex fails, the whole runtime system is terminated.
Notice that there is no "condition variable wait with time-out" in
the Erlang driver thread API. This because of issues with
In order for the Erlang driver thread API to function, thread
support must be enabled in the runtime system. An Erlang driver
can check if thread support is enabled by use of
When executing in an emulator thread, it is very important that you unlock all locks you have locked before letting the thread out of your control; otherwise you are very likely to deadlock the whole emulator.
If you need to use thread-specific data in an emulator thread, only have the thread-specific data set while the thread is under your control, and clear the thread-specific data before you let the thread out of your control.
In the future, debug functionality will probably be
integrated with the Erlang driver thread API. All functions
that create entities take a
A driver can add and later remove drivers.
A driver can monitor a process that does not own a port.
Version management is enabled for drivers that have set the
The runtime system normally refuses to load a driver if the major versions differ, or if the major versions are equal and the minor version used by the driver is greater than the one used by the runtime system. Old drivers with lower major versions are however allowed after a bump of the major version during a transition period of two major releases. Such old drivers can, however, fail if deprecated features are used.
The emulator refuses to load a driver that does not use
the extended driver interface, to allow for 64-bit capable drivers,
as incompatible type changes for the callbacks
Therefore it is not enough to only recompile drivers written with version management for pre R15B types; the types must be changed in the driver suggesting other rewrites, especially regarding size variables. Investigate all warnings when recompiling.
Also, the API driver functions
Support for time measurement in drivers:
ERTS 5.9 introduced two new integer types,
To not update a driver and only recompile, it probably works when building for a 32-bit machine creating a false sense of security. Hopefully that will generate many important warnings. But when recompiling the same driver later on for a 64-bit machine, there will be warnings and almost certainly crashes. So it is a bad idea to postpone updating the driver and not fixing the warnings.
When recompiling with
The following is a checklist for rewriting a pre ERTS 5.9 driver, most important first:
Rrewrite driver callback
Rewrite driver callback
These changes are essential not to crash the emulator or worse cause malfunction. Without them a driver can return garbage in the high 32 bits to the emulator, causing it to build a huge result from random bytes, either crashing on memory allocation or succeeding with a random result from the driver call.
Driver callback
Driver callback
Driver callback
Sane compiler's calling conventions probably make these changes
necessary only for a driver to handle data chunks that require
64-bit size fields (mostly larger than 2 GB, as that is what
an
The argument type change is from signed to unsigned. This can cause problems for, for example, loop termination conditions or error conditions if you only change the types all over the place.
The
Automatic type-casting probably makes these changes necessary only for a driver that encounters sizes > 32 bits.
The
Many driver API functions have changed argument type
and/or return value to
This is a change from signed to unsigned. This can cause problems for, for example, loop termination conditions and error conditions if you only change the types all over the place.
An unsigned integer type to be used as
A signed integer type, the size of
typedef struct ErlDrvSysInfo {
int driver_major_version;
int driver_minor_version;
char *erts_version;
char *otp_release;
int thread_support;
int smp_support;
int async_threads;
int scheduler_threads;
int nif_major_version;
int nif_minor_version;
int dirty_scheduler_support;
} ErlDrvSysInfo;
The
The value of
The value of
A string containing the version number of the runtime system
(the same as returned by
A string containing the OTP release number
(the same as returned by
A value
A value
The number of async threads in the async thread pool used by
The number of scheduler threads used by the runtime system
(the same as returned by
The value of
The value of
A value
typedef struct ErlDrvBinary {
ErlDrvSint orig_size;
char orig_bytes[];
} ErlDrvBinary;
The
The
Some driver calls, such as
Using a driver binary instead of a normal buffer is often faster, as the emulator needs not to copy the data, only the pointer is used.
A driver binary allocated in the driver, with
Driver binaries are used in the
If the driver for some reason wants to keep a
driver binary around, for example in a static variable, the
reference count is to be incremented, and the binary can later
be freed in the
Notice that as a driver binary is shared by the driver and the emulator. A binary received from the emulator or sent to the emulator must not be changed by the driver.
Since ERTS 5.5 (Erlang/OTP R11B),
A handle to driver-specific data, passed to the driver callbacks. It is a pointer, and is most often type cast to a specific pointer in the driver.
A system I/O vector, as used by
typedef struct ErlIOVec {
int vsize;
ErlDrvSizeT size;
SysIOVec* iov;
ErlDrvBinary** binv;
} ErlIOVec;
The I/O vector used by the emulator and drivers is a list
of binaries, with a
When a driver creates a monitor for a process, a
The driver writer is to provide the memory for storing the
monitor when calling
The
If certain port-specific data must be accessed from other threads than those calling the driver callbacks, a port data lock can be used to synchronize the operations on the data. Currently, the only port-specific data that the emulator associates with the port data lock is the driver queue.
Normally a driver instance has no port data lock. If
the driver instance wants to use a port data lock, it must
create the port data lock by calling
Once the port data lock has been created, every
access to data associated with the port data lock must be done
while the port data lock is locked. The port data lock is
locked and unlocked by
A port data lock is reference counted, and when the reference
count reaches zero, it is destroyed. The emulator at
least increments the reference count once when the lock is
created and decrements it once the port associated with
the lock terminates. The emulator also increments the
reference count when an async job is enqueued and decrements
it when an async job has been invoked.
Also, the driver is responsible for ensuring that
the reference count does not reach zero before the last use
of the lock by the driver has been made. The reference count
can be read, incremented, and decremented by
Thread identifier.
See also
int suggested_stack_size;
Thread options structure passed to
See also
Mutual exclusion lock. Used for synchronizing access to shared data. Only one thread at a time can lock a mutex.
See also
Condition variable. Used when threads must wait for a specific condition to appear before continuing execution. Condition variables must be used with associated mutexes.
See also
Read/write lock. Used to allow multiple threads to read shared data while only allowing one thread to write the same data. Multiple threads can read lock an rwlock at the same time, while only one thread can read/write lock an rwlock at a time.
See also
Key that thread-specific data can be associated with.
See also
A signed 64-bit integer type for time representation.
An enumeration of time units supported by the driver API:
Adds a driver entry to the list of drivers known by Erlang.
The
To use this function for adding drivers residing in
dynamically loaded code is dangerous. If the driver code
for the added driver resides in the same dynamically
loaded module (that is,
Use of this function is generally deprecated.
Allocates a memory block of the size specified
in
Memory allocated must be explicitly freed with a corresponding
call to
This function is thread-safe.
Allocates a driver binary with a memory block
of at least
Notice that a driver binary has an internal reference counter.
This means that calling
The driver binary has a field,
This function is thread-safe.
Performs an asynchronous call. The function
The async thread pool size can be set with command-line argument
If a thread pool is available, a thread is used.
If argument
To ensure that a driver instance always uses the same thread, the following call can be used:
It is enough to initialize
If a thread is already working, the calls are queued up and executed in order. Using the same thread for each driver instance ensures that the calls are made in sequence.
The
When the async operation is done,
The return value is
As from ERTS 5.5.4.3 the default stack size for
threads in the async-thread pool is 16 kilowords,
that is, 64 kilobyte on 32-bit architectures.
This small default size has been chosen because the
amount of async-threads can be quite large. The
default stack size is enough for drivers delivered
with Erlang/OTP, but is possibly not sufficiently large
for other dynamically linked-in drivers that use the
Calculates a key for later use in
Before Erlang/OTP R16, the port ID could be used as a key with proper casting, but after the rewrite of the port subsystem, this is no longer the case. With this function, you can achieve the same distribution based on port IDs as before Erlang/OTP R16.
Decrements the reference count on
This function is only thread-safe when the emulator with SMP support is used.
The reference count of driver binary is normally to be decremented
by calling
Returns the current reference count on
This function is only thread-safe when the emulator with SMP support is used.
Increments the reference count on
This function is only thread-safe when the emulator with SMP support is used.
Returns the process ID of the process that
made the current call to the driver. The process ID can be used with
Notice that this function is not thread-safe, not even when the emulator with SMP support is used.
Cancels a timer set with
The return value is
Compares two
Returns
Returns the port owner process.
Notice that this function is not thread-safe, not even when the emulator with SMP support is used.
Creates a new port executing the same driver code as the port creating the new port.
The caller of
Cancels a monitor created earlier.
Returns
Dequeues data by moving the head pointer
forward in the driver queue by
Returns the number of bytes remaining in the queue on success,
otherwise
This function can be called from any thread if a
Enqueues data in the driver queue. The data in
The driver queue is available to queue output from the
emulator to the driver (data from the driver to the emulator
is queued by the emulator in normal Erlang message
queues). This can be useful if the driver must wait for
slow devices, and so on, and wants to yield back to the
emulator. The driver queue is implemented as an
When the queue contains data, the driver does not close until the queue is empty.
The return value is
This function can be called from any thread if a
Enqueues a driver binary in the driver
queue. The data in
This function can be called from any thread if a
The return value is
Enqueues the data in
The return value is
This function can be called from any thread if a
Signals to Erlang that the driver has
encountered an error and is to be closed. The port is
closed and the tuple
The driver is to fail only when in severe error situations,
when the driver cannot possibly keep open, for example,
buffer allocation gets out of memory. For normal errors
it is more appropriate to send error codes with
The return value is
Signals to Erlang that the driver has
encountered an EOF and is to be closed, unless the port was
opened with option
The return value is
Frees the memory pointed to by
This function is thread-safe.
Frees a driver binary
This function is only thread-safe when the emulator with SMP support is used.
Returns the process ID associated with a living
monitor. It can be used in the
Returns
This function is deprecated. Do not use it. Use
Reads a time stamp into the memory pointed to by
parameter
The return value is
Locks the driver used by the port
Returns an atom given a name
Notice that this function is not thread-safe, not even when the emulator with SMP support is used.
Converts a port handle to the Erlang term format, usable in
Notice that this function is not thread-safe, not even when the emulator with SMP support is used.
Starts monitoring a process from a driver. When a process is
monitored, a process exit results in a call to the provided
Parameter
Returns
Sends data from the driver up to the emulator. The data is received as terms or binary data, depending on how the driver port was opened.
The data is queued in the port owner process' message queue. Notice that this does not yield to the emulator (as the driver and the emulator run in the same thread).
Parameter
The return value for all output functions is
Sends data to a port owner process from a
driver binary. It has a header buffer (
Parameter
Driver binaries are created with
The data in the header is sent as a list and the binary as an Erlang binary in the tail of the list.
For example, if
The return value is
Notice that, using the binary syntax in Erlang, the driver
application can match the header directly from the binary,
so the header can be put in the binary, and
This function is deprecated.
Use
Parameters
Notice that this function is not thread-safe, not even when the emulator with SMP support is used.
First sends
The point of sending data as a list header, is to facilitate matching on the data received.
The return value is
Sends data from an I/O vector,
Parameter
You get vectors of
For example, if
The return value is
The comment for
Creates a port data lock associated with the
Once a port data lock has been created, it must be locked during
all operations on the driver queue of the
Returns a newly created port data lock on success,
otherwise
Decrements the reference count of
the port data lock passed as argument (
The current reference count after the decrement has been performed is returned.
This function is thread-safe.
Returns the current reference count of
the port data lock passed as argument (
This function is thread-safe.
Increments the reference count of
the port data lock passed as argument (
The current reference count after the increment has been performed is returned.
This function is thread-safe.
Locks the port data lock passed as argument (
This function is thread-safe.
Unlocks the port data lock passed as argument (
This function is thread-safe.
Retrieves the driver queue as a pointer to an
array of
Nothing is removed from the queue by this function, that must be done
with
The returned array is suitable to use with the Unix system
call
This function can be called from any thread if a
Retrieves the driver queue into a supplied
If
Nothing is removed from the queue by this function, that must be done
with
This function can be called from any thread if a
Puts data at the head of the driver queue. The
data in
The return value is
This function can be called from any thread if a
Puts data in the binary
This function can be called from any thread if a
The return value is
Puts the data in
The return value is
This function can be called from any thread if a
Reads the current time of a timer, and places
the result in
The return value is
Resizes a memory block, either in place, or by
allocating a new block, copying the data, and freeing the old
block. A pointer is returned to the reallocated memory. On
failure (out of memory),
This function is thread-safe.
Resizes a driver binary, while keeping the data.
Returns the resized driver binary on success. Returns
This function is only thread-safe when the emulator with SMP support is used.
This function is used by drivers to provide the emulator with events to check for. This enables the emulator to call the driver when something has occurred asynchronously.
Parameter
Parameter
Parameter
Some OS (Windows) do not differentiate between read and write
events. The callback for a fired event then only depends on the
value of
The return value is
This function is deprecated.
Use
The parameters of this function cannot be properly checked by the runtime system when executed by arbitrary threads. This can cause the function not to fail when it should.
Parameters
This function is only thread-safe when the emulator with SMP support is used.
Sets a timer on the driver, which will count
down and call the driver when it is timed out. Parameter
When the timer reaches
Notice that only one timer exists on each driver instance; setting a new timer replaces an older one.
Return value is
Returns the number of bytes currently in the driver queue.
This function can be called from any thread if a
Writes information about the Erlang runtime system into the
For information about specific fields, see
Collects several segments of data, referenced
by
If the data is to be sent from the driver to the port owner
process, it is faster to use
The return value is the space left in the buffer, that is, if
Sets and gets limits that will be used for controlling the busy state of the port message queue.
The port message queue is set into a busy
state when the amount of command data queued on the
message queue reaches the
Valid limits are values in the range
By passing a pointer to an integer variable containing
the value
The busy message queue feature can be disabled either
by setting the
Processes sending command data to the port are suspended if either the port is busy or if the port message queue is busy. Suspended processes are resumed when neither the port or the port message queue is busy.
For information about busy port functionality, see
Broadcasts on a condition variable. That is, if other threads are waiting on the condition variable being broadcast on, all of them are woken.
This function is thread-safe.
Creates a condition variable and returns a pointer to it.
Returns
This function is thread-safe.
Destroys a condition variable previously created by
This function is thread-safe.
Returns a pointer to the name of the condition.
This function is intended for debugging purposes only.
Signals on a condition variable. That is, if other threads are waiting on the condition variable being signaled, one of them is woken.
This function is thread-safe.
Waits on a condition variable. The calling thread is blocked until another thread wakes it by signaling or broadcasting on the condition variable. Before the calling thread is blocked, it unlocks the mutex passed as argument. When the calling thread is woken, it locks the same mutex before returning. That is, the mutex currently must be locked by the calling thread when calling this function.
This function is thread-safe.
Gives the runtime system a hint about how much CPU time the current driver callback call has consumed since the last hint, or since the the start of the callback if no previous hint has been given.
The time is specified as a fraction, in percent, of a full time-slice
that a port is allowed to execute before it is to surrender the
CPU to other runnable ports or processes. Valid range is
Notice that it is up to the runtime system to determine if and how to use this information. Implementations on some platforms can use other means to determine the consumed fraction of the time-slice. Lengthy driver callbacks should, regardless of this, frequently call this function to determine if it is allowed to continue execution or not.
This function returns a non-zero value if the time-slice has been exhausted, and zero if the callback is allowed to continue execution. If a non-zero value is returned, the driver callback is to return as soon as possible in order for the port to be able to yield.
This function is provided to better support co-operative scheduling, improve system responsiveness, and to make it easier to prevent misbehaviors of the VM because of a port monopolizing a scheduler thread. It can be used when dividing lengthy work into some repeated driver callback calls, without the need to use threads.
See also the important
Converts the
Returns
See also
Compares two thread identifiers,
Returns
A thread identifier can be reused very quickly after
a thread has terminated. Therefore, if a thread
corresponding to one of the involved thread identifiers
has terminated since the thread identifier was saved,
the result of
This function is thread-safe.
Retrieves the value of an environment variable.
When this function is called,
On success,
On failure, that is, no such environment variable was found,
a value <
Do not use libc's
This function is thread-safe.
Acknowledges the start of the port.
When this function is called the initiating
Returns
Returns
See also
Creates a mutex and returns a pointer to it.
Returns
This function is thread-safe.
Destroys a mutex previously created by
This function is thread-safe.
Locks a mutex. The calling thread is blocked until the mutex has been locked. A thread that has currently locked the mutex cannot lock the same mutex again.
If you leave a mutex locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
Returns a pointer to the mutex name.
This function is intended for debugging purposes only.
Tries to lock a mutex. A thread that has currently locked the mutex cannot try to lock the same mutex again.
Returns
If you leave a mutex locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
Unlocks a mutex. The mutex currently must be locked by the calling thread.
This function is thread-safe.
Sends data in the special driver term
format to the port owner process. This is a fast way to
deliver term data from a driver. It needs no binary
conversion, so the port owner process receives data as
normal Erlang terms. The
Parameter
Parameter
Tuples, maps, and lists (except strings, see below) are built in reverse polish notation, so that to build a tuple, the elements are specified first, and then the tuple term, with a count. Likewise for lists and maps.
A tuple must be specified with the number of elements. (The
elements precede the
A map must be specified with the number of key-value pairs
A list must be specified with the number of elements,
including the tail, which is the last term preceding
The special term
Term type Arguments --------- --------- ERL_DRV_NIL ERL_DRV_ATOM ErlDrvTermData atom (from driver_mk_atom(char *string)) ERL_DRV_INT ErlDrvSInt integer ERL_DRV_UINT ErlDrvUInt integer ERL_DRV_INT64 ErlDrvSInt64 *integer_ptr ERL_DRV_UINT64 ErlDrvUInt64 *integer_ptr ERL_DRV_PORT ErlDrvTermData port (from driver_mk_port(ErlDrvPort port)) ERL_DRV_BINARY ErlDrvBinary *bin, ErlDrvUInt len, ErlDrvUInt offset ERL_DRV_BUF2BINARY char *buf, ErlDrvUInt len ERL_DRV_STRING char *str, int len ERL_DRV_TUPLE int sz ERL_DRV_LIST int sz ERL_DRV_PID ErlDrvTermData pid (from driver_connected(ErlDrvPort port) or driver_caller(ErlDrvPort port)) ERL_DRV_STRING_CONS char *str, int len ERL_DRV_FLOAT double *dbl ERL_DRV_EXT2TERM char *buf, ErlDrvUInt len ERL_DRV_MAP int sz
The unsigned integer data type
The unsigned integer data type
To build the tuple
Here
The
The
orig_bytes, binp->orig_size
ERL_DRV_TUPLE, 2,
};
erl_drv_output_term(driver_mk_port(drvport), spec, sizeof(spec) / sizeof(spec[0])); ]]>
To build the map
If you want to pass a binary and do not already have the content
of the binary in an
The
This function is only thread-safe when the emulator with SMP support is used.
Sets the value of an environment variable.
Returns
The result of passing the empty string (
Do not use libc's
This function is thread-safe.
Creates an rwlock and returns a pointer to it.
Returns
This function is thread-safe.
Destroys an rwlock previously created by
This function is thread-safe.
Returns a pointer to the name of the rwlock.
This function is intended for debugging purposes only.
Read locks an rwlock. The calling thread is blocked until the rwlock has been read locked. A thread that currently has read or read/write locked the rwlock cannot lock the same rwlock again.
If you leave an rwlock locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
Read unlocks an rwlock. The rwlock currently must be read locked by the calling thread.
This function is thread-safe.
Read/write locks an rwlock. The calling thread is blocked until the rwlock has been read/write locked. A thread that currently has read or read/write locked the rwlock cannot lock the same rwlock again.
If you leave an rwlock locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
Read/write unlocks an rwlock. The rwlock currently must be read/write locked by the calling thread.
This function is thread-safe.
Tries to read lock an rwlock.
Returns
If you leave an rwlock locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
Tries to read/write lock an rwlock. A thread that currently has read or read/write locked the rwlock cannot try to lock the same rwlock again.
Returns
If you leave an rwlock locked in an emulator thread when you let the thread out of your control, you will very likely deadlock the whole emulator.
This function is thread-safe.
This function is the only way for a driver to send data to
other processes than the port owner process. Parameter
Parameter
Parameters
This function is only thread-safe when the emulator with SMP support is used.
Sets the
Creates a new thread.
Returns
You are not allowed to allocate the
The created thread terminates either when
All created threads must be joined by the driver before it is unloaded. If the driver fails to join all threads created before it is unloaded, the runtime system most likely crashes when the driver code is unloaded.
This function is thread-safe.
Terminates the calling thread with the exit value passed as
argument.
You are only allowed to terminate threads created with
The exit value can later be retrieved by another thread through
This function is thread-safe.
Joins the calling thread with another thread, that is,
the calling thread is blocked until the thread identified by
Returns
A thread can only be joined once. The behavior of joining
more than once is undefined, an emulator crash is likely. If
This function is thread-safe.
Returns a pointer to the name of the thread.
This function is intended for debugging purposes only.
Allocates and initializes a thread option structure.
Returns
You are not allowed to allocate the
This function is thread-safe.
Destroys thread options previously created by
This function is thread-safe.
Returns the thread identifier of the calling thread.
This function is thread-safe.
Returns the current time offset between
Returns
See also
Returns the thread-specific data
associated with
Returns
This function is thread-safe.
Creates a thread-specific data key.
Returns
This function is thread-safe.
Destroys a thread-specific data key previously created by
A destroyed key is very likely to be reused soon. Therefore, if you fail to clear the thread-specific data using this key in a thread before destroying the key, you will very likely get unexpected errors in other parts of the system.
This function is thread-safe.
Sets thread-specific data associated with
If you fail to clear thread-specific data in an emulator thread before letting it out of your control, you might never be able to clear this data with later unexpected errors in other parts of the system as a result.
This function is thread-safe.
Returns the atom name of the Erlang error,
given the error number in
Removes a driver entry
Driver entries added by the
Sets and unsets the busy state of the port. If
Processes sending command data to the port are suspended
if either the port or the port message queue
is busy. Suspended processes are resumed when neither the
port or the port message queue is busy. Command data
is in this context data passed to the port using either
If the
For information about busy port message queue functionality, see
Sets flags for how the
Currently there are only two meaningful values for