globalcontext.h

Include dependency graph for globalcontext.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "6" [label="stdbool.h" tooltip="stdbool.h"]
    "3" [label="atom.h" tooltip="atom.h"]
    "9" [label="assert.h" tooltip="assert.h"]
    "17" [label="synclist.h" tooltip="synclist.h"]
    "2" [label="stdint.h" tooltip="stdint.h"]
    "4" [label="stdlib.h" tooltip="stdlib.h"]
    "14" [label="utils.h" tooltip="utils.h"]
    "5" [label="atom_table.h" tooltip="atom_table.h"]
    "8" [label="term_typedef.h" tooltip="term_typedef.h"]
    "15" [label="stddef.h" tooltip="stddef.h"]
    "10" [label="limits.h" tooltip="limits.h"]
    "22" [label="refc_binary.h" tooltip="refc_binary.h"]
    "20" [label="string.h" tooltip="string.h"]
    "13" [label="mailbox.h" tooltip="mailbox.h"]
    "19" [label="term.h" tooltip="term.h"]
    "7" [label="erl_nif.h" tooltip="erl_nif.h"]
    "23" [label="resources.h" tooltip="resources.h"]
    "16" [label="smp.h" tooltip="smp.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h" fillcolor="#BFBFBF"]
    "21" [label="memory.h" tooltip="memory.h"]
    "18" [label="stdio.h" tooltip="stdio.h"]
    "24" [label="timer_list.h" tooltip="timer_list.h"]
    "12" [label="list.h" tooltip="list.h"]
    "11" [label="inttypes.h" tooltip="inttypes.h"]
    "3" -> "2" [dir=forward tooltip="include"]
    "3" -> "4" [dir=forward tooltip="include"]
    "17" -> "12" [dir=forward tooltip="include"]
    "17" -> "18" [dir=forward tooltip="include"]
    "17" -> "16" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "5" -> "6" [dir=forward tooltip="include"]
    "5" -> "3" [dir=forward tooltip="include"]
    "8" -> "9" [dir=forward tooltip="include"]
    "8" -> "10" [dir=forward tooltip="include"]
    "8" -> "11" [dir=forward tooltip="include"]
    "8" -> "2" [dir=forward tooltip="include"]
    "22" -> "6" [dir=forward tooltip="include"]
    "22" -> "4" [dir=forward tooltip="include"]
    "22" -> "12" [dir=forward tooltip="include"]
    "22" -> "23" [dir=forward tooltip="include"]
    "13" -> "6" [dir=forward tooltip="include"]
    "13" -> "12" [dir=forward tooltip="include"]
    "13" -> "8" [dir=forward tooltip="include"]
    "13" -> "14" [dir=forward tooltip="include"]
    "19" -> "6" [dir=forward tooltip="include"]
    "19" -> "2" [dir=forward tooltip="include"]
    "19" -> "18" [dir=forward tooltip="include"]
    "19" -> "4" [dir=forward tooltip="include"]
    "19" -> "20" [dir=forward tooltip="include"]
    "19" -> "21" [dir=forward tooltip="include"]
    "19" -> "22" [dir=forward tooltip="include"]
    "19" -> "14" [dir=forward tooltip="include"]
    "19" -> "8" [dir=forward tooltip="include"]
    "7" -> "8" [dir=forward tooltip="include"]
    "23" -> "4" [dir=forward tooltip="include"]
    "23" -> "7" [dir=forward tooltip="include"]
    "23" -> "12" [dir=forward tooltip="include"]
    "23" -> "21" [dir=forward tooltip="include"]
    "16" -> "6" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "5" [dir=forward tooltip="include"]
    "1" -> "7" [dir=forward tooltip="include"]
    "1" -> "12" [dir=forward tooltip="include"]
    "1" -> "13" [dir=forward tooltip="include"]
    "1" -> "16" [dir=forward tooltip="include"]
    "1" -> "17" [dir=forward tooltip="include"]
    "1" -> "19" [dir=forward tooltip="include"]
    "1" -> "24" [dir=forward tooltip="include"]
    "21" -> "7" [dir=forward tooltip="include"]
    "21" -> "8" [dir=forward tooltip="include"]
    "21" -> "14" [dir=forward tooltip="include"]
    "21" -> "2" [dir=forward tooltip="include"]
    "21" -> "4" [dir=forward tooltip="include"]
    "24" -> "6" [dir=forward tooltip="include"]
    "24" -> "2" [dir=forward tooltip="include"]
    "24" -> "12" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include globalcontext.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "9" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.c"]
    "45" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/dictionary.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/dictionary.c"]
    "8" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.h"]
    "30" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/platform_nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/platform_nifs.h"]
    "18" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.c"]
    "46" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.h"]
    "44" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.c"]
    "43" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.h"]
    "24" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.c"]
    "23" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.h"]
    "14" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.c"]
    "41" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h"]
    "6" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.c"]
    "7" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.h"]
    "39" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.c"]
    "40" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.h"]
    "32" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.c"]
    "31" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.h"]
    "19" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c"]
    "42" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c"]
    "10" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.c"]
    "29" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.h"]
    "3" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c"]
    "2" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h"]
    "28" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c"]
    "26" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.c"]
    "17" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c"]
    "22" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.h"]
    "38" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.h"]
    "20" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/resources.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/resources.c"]
    "27" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.c"]
    "35" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.h"]
    "25" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.c"]
    "36" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.h"]
    "15" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/erl_nif_priv.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/erl_nif_priv.h"]
    "33" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/sys.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/sys.h"]
    "5" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c"]
    "34" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.h"]
    "12" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.c"]
    "11" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.h"]
    "4" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h" fillcolor="#BFBFBF"]
    "13" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/memory.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/memory.c"]
    "16" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c"]
    "37" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.h"]
    "21" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/externalterm.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/externalterm.c"]
    "8" -> "9" [dir=back tooltip="include"]
    "8" -> "10" [dir=back tooltip="include"]
    "8" -> "5" [dir=back tooltip="include"]
    "30" -> "5" [dir=back tooltip="include"]
    "46" -> "4" [dir=back tooltip="include"]
    "46" -> "5" [dir=back tooltip="include"]
    "46" -> "16" [dir=back tooltip="include"]
    "46" -> "18" [dir=back tooltip="include"]
    "43" -> "9" [dir=back tooltip="include"]
    "43" -> "44" [dir=back tooltip="include"]
    "43" -> "45" [dir=back tooltip="include"]
    "43" -> "4" [dir=back tooltip="include"]
    "43" -> "26" [dir=back tooltip="include"]
    "43" -> "5" [dir=back tooltip="include"]
    "43" -> "27" [dir=back tooltip="include"]
    "43" -> "25" [dir=back tooltip="include"]
    "43" -> "16" [dir=back tooltip="include"]
    "43" -> "17" [dir=back tooltip="include"]
    "43" -> "39" [dir=back tooltip="include"]
    "43" -> "40" [dir=back tooltip="include"]
    "43" -> "18" [dir=back tooltip="include"]
    "43" -> "20" [dir=back tooltip="include"]
    "43" -> "32" [dir=back tooltip="include"]
    "23" -> "24" [dir=back tooltip="include"]
    "23" -> "25" [dir=back tooltip="include"]
    "23" -> "16" [dir=back tooltip="include"]
    "23" -> "17" [dir=back tooltip="include"]
    "41" -> "4" [dir=back tooltip="include"]
    "41" -> "42" [dir=back tooltip="include"]
    "41" -> "5" [dir=back tooltip="include"]
    "41" -> "16" [dir=back tooltip="include"]
    "41" -> "14" [dir=back tooltip="include"]
    "7" -> "8" [dir=back tooltip="include"]
    "7" -> "6" [dir=back tooltip="include"]
    "7" -> "11" [dir=back tooltip="include"]
    "7" -> "15" [dir=back tooltip="include"]
    "7" -> "21" [dir=back tooltip="include"]
    "7" -> "4" [dir=back tooltip="include"]
    "7" -> "22" [dir=back tooltip="include"]
    "7" -> "13" [dir=back tooltip="include"]
    "7" -> "10" [dir=back tooltip="include"]
    "7" -> "29" [dir=back tooltip="include"]
    "7" -> "5" [dir=back tooltip="include"]
    "7" -> "34" [dir=back tooltip="include"]
    "7" -> "27" [dir=back tooltip="include"]
    "7" -> "25" [dir=back tooltip="include"]
    "7" -> "16" [dir=back tooltip="include"]
    "7" -> "17" [dir=back tooltip="include"]
    "7" -> "39" [dir=back tooltip="include"]
    "7" -> "40" [dir=back tooltip="include"]
    "7" -> "19" [dir=back tooltip="include"]
    "7" -> "20" [dir=back tooltip="include"]
    "7" -> "41" [dir=back tooltip="include"]
    "7" -> "31" [dir=back tooltip="include"]
    "7" -> "28" [dir=back tooltip="include"]
    "40" -> "24" [dir=back tooltip="include"]
    "40" -> "5" [dir=back tooltip="include"]
    "40" -> "25" [dir=back tooltip="include"]
    "40" -> "16" [dir=back tooltip="include"]
    "40" -> "17" [dir=back tooltip="include"]
    "40" -> "39" [dir=back tooltip="include"]
    "31" -> "32" [dir=back tooltip="include"]
    "29" -> "8" [dir=back tooltip="include"]
    "29" -> "10" [dir=back tooltip="include"]
    "29" -> "5" [dir=back tooltip="include"]
    "29" -> "30" [dir=back tooltip="include"]
    "29" -> "31" [dir=back tooltip="include"]
    "29" -> "33" [dir=back tooltip="include"]
    "2" -> "3" [dir=back tooltip="include"]
    "2" -> "4" [dir=back tooltip="include"]
    "2" -> "5" [dir=back tooltip="include"]
    "22" -> "23" [dir=back tooltip="include"]
    "22" -> "26" [dir=back tooltip="include"]
    "22" -> "5" [dir=back tooltip="include"]
    "22" -> "27" [dir=back tooltip="include"]
    "22" -> "25" [dir=back tooltip="include"]
    "22" -> "16" [dir=back tooltip="include"]
    "22" -> "17" [dir=back tooltip="include"]
    "22" -> "18" [dir=back tooltip="include"]
    "22" -> "28" [dir=back tooltip="include"]
    "38" -> "17" [dir=back tooltip="include"]
    "35" -> "27" [dir=back tooltip="include"]
    "36" -> "25" [dir=back tooltip="include"]
    "15" -> "6" [dir=back tooltip="include"]
    "15" -> "4" [dir=back tooltip="include"]
    "15" -> "13" [dir=back tooltip="include"]
    "15" -> "16" [dir=back tooltip="include"]
    "15" -> "17" [dir=back tooltip="include"]
    "15" -> "18" [dir=back tooltip="include"]
    "15" -> "19" [dir=back tooltip="include"]
    "15" -> "20" [dir=back tooltip="include"]
    "33" -> "6" [dir=back tooltip="include"]
    "33" -> "4" [dir=back tooltip="include"]
    "33" -> "10" [dir=back tooltip="include"]
    "33" -> "5" [dir=back tooltip="include"]
    "33" -> "16" [dir=back tooltip="include"]
    "33" -> "20" [dir=back tooltip="include"]
    "33" -> "14" [dir=back tooltip="include"]
    "34" -> "10" [dir=back tooltip="include"]
    "34" -> "5" [dir=back tooltip="include"]
    "34" -> "27" [dir=back tooltip="include"]
    "34" -> "35" [dir=back tooltip="include"]
    "34" -> "25" [dir=back tooltip="include"]
    "34" -> "36" [dir=back tooltip="include"]
    "34" -> "16" [dir=back tooltip="include"]
    "34" -> "37" [dir=back tooltip="include"]
    "34" -> "17" [dir=back tooltip="include"]
    "34" -> "38" [dir=back tooltip="include"]
    "34" -> "18" [dir=back tooltip="include"]
    "11" -> "12" [dir=back tooltip="include"]
    "11" -> "13" [dir=back tooltip="include"]
    "11" -> "14" [dir=back tooltip="include"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "6" [dir=back tooltip="include"]
    "1" -> "7" [dir=back tooltip="include"]
    "1" -> "43" [dir=back tooltip="include"]
    "1" -> "4" [dir=back tooltip="include"]
    "1" -> "13" [dir=back tooltip="include"]
    "1" -> "10" [dir=back tooltip="include"]
    "1" -> "29" [dir=back tooltip="include"]
    "1" -> "5" [dir=back tooltip="include"]
    "1" -> "27" [dir=back tooltip="include"]
    "1" -> "25" [dir=back tooltip="include"]
    "1" -> "36" [dir=back tooltip="include"]
    "1" -> "16" [dir=back tooltip="include"]
    "1" -> "37" [dir=back tooltip="include"]
    "1" -> "17" [dir=back tooltip="include"]
    "1" -> "38" [dir=back tooltip="include"]
    "1" -> "39" [dir=back tooltip="include"]
    "1" -> "40" [dir=back tooltip="include"]
    "1" -> "18" [dir=back tooltip="include"]
    "1" -> "46" [dir=back tooltip="include"]
    "1" -> "41" [dir=back tooltip="include"]
    "1" -> "32" [dir=back tooltip="include"]
    "1" -> "33" [dir=back tooltip="include"]
    "37" -> "16" [dir=back tooltip="include"]
    "37" -> "17" [dir=back tooltip="include"]
}

GlobalContext struct and related management functions.

GlobalContext keeps the state of an AtomVM instance, multiple instances can run simultaneously.

Defines

INVALID_PROCESS_ID 0
TYPEDEF_MODULE

Typedefs

typedef struct Module Module

Functions

GlobalContext *globalcontext_new()

Creates a new GlobalContext.

Allocates a new GlobalContext struct and initialize it, the newly created global context is a new AtomVM instance.

Returns:

A newly created GlobalContext.

void globalcontext_destroy(GlobalContext *glb)

Destoys an existing GlobalContext.

Frees global context resources and memory and removes it from the processes table.

Parameters:
  • glb – the global context that will be destroyed.

Context *globalcontext_get_process_nolock(GlobalContext *glb, int32_t process_id)

Gets a Context from the process table, without acquiring a lock on the process table.

Retrieves from the process table the context with the given local process id. If the process can be found, without locking the process table. This is unsafe unless a lock on the process table has been obtained previously.

Parameters:
  • glb – the global context (that owns the process table).

  • process_id – the local process id.

Returns:

a Context * with the requested local process id or NULL if not found.

Context *globalcontext_get_process_lock(GlobalContext *glb, int32_t process_id)

Gets a Context from the process table, acquiring a lock on the process table.

Retrieves from the process table the context with the given local process id. If the process can be found, the process table is locked.

Parameters:
  • glb – the global context (that owns the process table).

  • process_id – the local process id.

Returns:

a Context * with the requested local process id or NULL if not found.

void globalcontext_get_process_unlock(GlobalContext *glb, Context *c)

Unlock the process table after c was gotten.

Parameters:
  • glb – the global context (that owns the process table).

  • c – the result of globalcontext_get_process_lock. If NULL, does nothing, otherwise releases the lock on process table.

bool globalcontext_process_exists(GlobalContext *glb, int32_t process_id)

Determine if a process exists.

Parameters:
  • glb – the global context (that owns the process table).

  • process_id – the local process id.

Returns:

true if a process exists with this id.

void globalcontext_send_message(GlobalContext *glb, int32_t process_id, term t)

Send a message to a process identified by its id.

Safely send a message to the process, doing nothing is the process cannot be found.

Parameters:
  • glb – the global context (that owns the process table).

  • process_id – the local process id.

  • t – the message to send.

void globalcontext_send_message_nolock(GlobalContext *glb, int32_t process_id, term t)

Send a message to a process from another process. There should be a lock on the process table. This variant can be used by listener handlers as an optimization (instead of sending a message to the port context which should then forward it to the target context).

Safely send a message to the process, doing nothing if the process cannot be found.

Parameters:
  • glb – the global context (that owns the process table).

  • process_id – the target process id.

  • t – the message to send.

void globalcontext_init_process(GlobalContext *glb, Context *ctx)

Initialize a new process, providing it with a process id.

This function also inserts the process into the process and waiting tables.

Parameters:
  • glb – the global context.

  • ctx – the process to initialize

bool globalcontext_register_process(GlobalContext *glb, int atom_index, int local_process_id)

Register a process.

Register a process with a certain name (atom) so it can be easily retrieved later.

Parameters:
  • glb – the global context, each registered process will be globally available for that context.

  • atom_index – the atom table index.

  • local_process_id – the process local id.

Returns:

true if the process was registered, false if another process with the same name already existed

int globalcontext_get_registered_process(GlobalContext *glb, int atom_index)

Get a registered process.

Returns the local process id of a previously registered process.

Parameters:
  • glb – the global context.

  • atom_index – the atom table index.

Returns:

a previously registered process local id.

bool globalcontext_unregister_process(GlobalContext *glb, int atom_index)

Unregister a process by name.

Unregister a process with a certain name (atom).

Parameters:
  • glb – the global context, each registered process will be globally available for that context.

  • atom_index – the atom table index.

Returns:

true if the process was unregistered, false otherwise

void globalcontext_maybe_unregister_process_id(GlobalContext *glb, int process_id)

Remove entry(ies) from registered atoms by process id.

Unregister a process with a certain process id. This is used when a process dies to ensure the process is not registered and remove it from the registered atoms table if it is.

Parameters:
  • glb – the global context, each registered process will be globally available for that context.

  • process_id – the process id of the entry to remove.

static inline int globalcontext_insert_atom_maybe_copy(GlobalContext *glb, AtomString atom_string, int copy)

Inserts an atom into the global atoms table, making a copy of the supplied atom string, if copy is non-zero.

Inserts an atom into the global atoms table and returns its id.

Parameters:
  • glb – the global context.

  • atom_string – the atom string that will be added to the global atoms table, it will not be copied so it must stay allocated and valid.

  • copy – if non-zero, make a copy of the input atom_string if the atom is not already in the table. The table assumes “ownership” of the allocated memory.

Returns:

newly added atom id or -1 in case of failure.

static inline int globalcontext_insert_atom(GlobalContext *glb, AtomString atom_string)

equivalent to globalcontext_insert_atom_maybe_copy(glb, atom_string, 0);

bool globalcontext_is_atom_index_equal_to_atom_string(GlobalContext *glb, int atom_index_a, AtomString atom_string_b)

Compares an atom table index with an AtomString.

Checks if the given atom table index and the given AtomString refers to the same atom.

Parameters:
  • glb – the global context.

  • atom_index_a – an atom table index.

  • atom_string_b – an atom string, which is the atom length followed by atom characters.

Returns:

true if they both refer to the same atom, otherwise false.

static inline bool globalcontext_is_term_equal_to_atom_string(GlobalContext *global, term atom_a, AtomString atom_string_b)

Compares a term with an AtomString.

Checks if the given term and the given AtomString refers to the same atom.

Parameters:
  • global – the global context.

  • atom_a – any term of any type, when it is not an atom false is always returned.

  • atom_string_b – an atom string, which is the atom length followed by atom characters.

Returns:

true if they both refer to the same atom, otherwise false.

static inline term globalcontext_make_atom(GlobalContext *glb, AtomString string)

Returns a term representing an atom, from the suppliend string.

Converts a string to an atom. Note that this function may have a side-effect on the global context.

Parameters:
  • glb – pointer to the global context

  • string – an AtomString

Returns:

an atom term formed from the supplied atom string.

AtomString globalcontext_atomstring_from_term(GlobalContext *glb, term t)

Returns the AtomString value of a term.

This function fetches the AtomString value of the atom associated with the supplied term. The input term must be an atom type. If no such atom is registered in the global table, this function returns NULL. The caller should NOT free the data associated with the returned value.

Parameters:
  • glb – the global context

  • t – the atom term

Returns:

the AtomString associated with the supplied atom term.

term globalcontext_existing_term_from_atom_string(GlobalContext *glb, AtomString atom_string)

Returns the term for an existing atom.

This function allows to get an atom term associated to the given atom string, if and only if the given atom is already in the atom table, otherwise an invalid term is returned.

Parameters:
  • glb – the global context.

  • atom_string – the atom string that will be looked into the atom table.

Returns:

the term associated with the supplied atom string when already existing in the atom table, otherwise an invalid term.

int globalcontext_insert_module(GlobalContext *global, Module *module)

Inserts a module to the modules table.

Inserts an already loaded module to the modules table and assigns and index to it so it can be retrieved later by name or index.

Parameters:
  • global – the global context.

  • module – the module that will be added to the modules table.

Returns:

the module index if successful, otherwise -1.

Module *globalcontext_get_module_by_index(GlobalContext *global, int index)

Get a module by index.

Safely retrieve the module by index considering the table can be reallocated by globalcontext_insert_module.

Parameters:
  • global – the global context.

  • index – the module index.

Returns:

the module

Module *globalcontext_get_module(GlobalContext *global, AtomString module_name_atom)

Returns the module with the given name.

Tries to get the module with the given name from the modules table and eventually loads it.

Parameters:
  • global – the global context.

  • module_name_atom – the module name.

Returns:

a pointer to a Module struct.

bool globalcontext_demonitor(GlobalContext *global, uint64_t ref_ticks)

remove a monitor

iterate on the list of all processes and then on each monitor to find a given monitor, and remove it

Parameters:
  • global – the global context

  • ref_ticks – the reference to the monitor

Returns:

true if the monitor was found

static inline uint64_t globalcontext_get_ref_ticks(GlobalContext *global)
struct MessageQueueItem
#include <globalcontext.h>

Collaboration diagram for MessageQueueItem:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="MailboxMessage" tooltip="MailboxMessage"]
    "1" [label="MessageQueueItem" tooltip="MessageQueueItem" fillcolor="#BFBFBF"]
    "2" -> "2" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "1" [dir=forward tooltip="usage"]
}

Public Members

struct MessageQueueItem *next
MailboxMessage *message
int32_t process_id
struct RefcBinaryQueueItem
#include <globalcontext.h>

Collaboration diagram for RefcBinaryQueueItem:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "16" [label="SpinLock" tooltip="SpinLock"]
    "3" [label="ResourceType" tooltip="ResourceType"]
    "10" [label="Module" tooltip="Module"]
    "9" [label="ListHead" tooltip="ListHead"]
    "1" [label="RefcBinaryQueueItem" tooltip="RefcBinaryQueueItem" fillcolor="#BFBFBF"]
    "4" [label="GlobalContext" tooltip="GlobalContext"]
    "12" [label="ModuleFilename" tooltip="ModuleFilename"]
    "7" [label="HNodeGroup" tooltip="HNodeGroup"]
    "15" [label="TimerList" tooltip="TimerList"]
    "13" [label="LiteralEntry" tooltip="LiteralEntry"]
    "14" [label="AtomsHashTable" tooltip="AtomsHashTable"]
    "2" [label="RefcBinary" tooltip="RefcBinary"]
    "5" [label="AtomTable" tooltip="AtomTable"]
    "11" [label="ExportedFunction" tooltip="ExportedFunction"]
    "8" [label="SyncList" tooltip="SyncList"]
    "6" [label="HNode" tooltip="HNode"]
    "3" -> "4" [dir=forward tooltip="usage"]
    "3" -> "9" [dir=forward tooltip="usage"]
    "10" -> "11" [dir=forward tooltip="usage"]
    "10" -> "12" [dir=forward tooltip="usage"]
    "10" -> "13" [dir=forward tooltip="usage"]
    "10" -> "9" [dir=forward tooltip="usage"]
    "9" -> "9" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "1" [dir=forward tooltip="usage"]
    "4" -> "5" [dir=forward tooltip="usage"]
    "4" -> "8" [dir=forward tooltip="usage"]
    "4" -> "10" [dir=forward tooltip="usage"]
    "4" -> "14" [dir=forward tooltip="usage"]
    "4" -> "15" [dir=forward tooltip="usage"]
    "4" -> "16" [dir=forward tooltip="usage"]
    "4" -> "9" [dir=forward tooltip="usage"]
    "7" -> "6" [dir=forward tooltip="usage"]
    "7" -> "7" [dir=forward tooltip="usage"]
    "15" -> "9" [dir=forward tooltip="usage"]
    "14" -> "6" [dir=forward tooltip="usage"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "2" -> "9" [dir=forward tooltip="usage"]
    "5" -> "6" [dir=forward tooltip="usage"]
    "5" -> "7" [dir=forward tooltip="usage"]
    "8" -> "9" [dir=forward tooltip="usage"]
    "6" -> "6" [dir=forward tooltip="usage"]
}

Public Members

struct RefcBinaryQueueItem *next
struct RefcBinary *refc
struct GlobalContext
#include <globalcontext.h>

Collaboration diagram for GlobalContext:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "13" [label="SpinLock" tooltip="SpinLock"]
    "7" [label="Module" tooltip="Module"]
    "6" [label="ListHead" tooltip="ListHead"]
    "1" [label="GlobalContext" tooltip="GlobalContext" fillcolor="#BFBFBF"]
    "9" [label="ModuleFilename" tooltip="ModuleFilename"]
    "4" [label="HNodeGroup" tooltip="HNodeGroup"]
    "12" [label="TimerList" tooltip="TimerList"]
    "10" [label="LiteralEntry" tooltip="LiteralEntry"]
    "11" [label="AtomsHashTable" tooltip="AtomsHashTable"]
    "2" [label="AtomTable" tooltip="AtomTable"]
    "8" [label="ExportedFunction" tooltip="ExportedFunction"]
    "5" [label="SyncList" tooltip="SyncList"]
    "3" [label="HNode" tooltip="HNode"]
    "7" -> "8" [dir=forward tooltip="usage"]
    "7" -> "9" [dir=forward tooltip="usage"]
    "7" -> "10" [dir=forward tooltip="usage"]
    "7" -> "6" [dir=forward tooltip="usage"]
    "6" -> "6" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "5" [dir=forward tooltip="usage"]
    "1" -> "7" [dir=forward tooltip="usage"]
    "1" -> "11" [dir=forward tooltip="usage"]
    "1" -> "12" [dir=forward tooltip="usage"]
    "1" -> "13" [dir=forward tooltip="usage"]
    "1" -> "6" [dir=forward tooltip="usage"]
    "4" -> "3" [dir=forward tooltip="usage"]
    "4" -> "4" [dir=forward tooltip="usage"]
    "12" -> "6" [dir=forward tooltip="usage"]
    "11" -> "3" [dir=forward tooltip="usage"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "2" -> "4" [dir=forward tooltip="usage"]
    "5" -> "6" [dir=forward tooltip="usage"]
    "3" -> "3" [dir=forward tooltip="usage"]
}

Public Members

struct ListHead ready_processes
struct ListHead running_processes
struct ListHead waiting_processes
SpinLock processes_spinlock
struct SyncList refc_binaries
struct SyncList processes_table
struct SyncList registered_processes
struct SyncList listeners
struct SyncList resource_types
struct SyncList select_events
int32_t last_process_id
struct AtomTable *atom_table
struct AtomsHashTable *modules_table
RWLock *modules_lock
Module **modules_by_index
int loaded_modules_count
struct SyncList avmpack_data
struct TimerList timer_list
SpinLock timer_spinlock
unsigned long long ref_ticks
SpinLock ref_ticks_spinlock
int ATOMIC online_schedulers
int running_schedulers
bool ATOMIC waiting_scheduler
Mutex *schedulers_mutex
CondVar *schedulers_cv
bool ATOMIC scheduler_stop_all
SpinLock env_spinlock
void *platform_data