context.c
Include dependency graph for context.c:
Functions
-
static struct ResourceMonitor *context_monitors_handle_terminate(Context *ctx)
-
Context *context_new(GlobalContext *glb)
Creates a new context.
Allocates a new Context struct and initialize it. The newly created context is also inserted into the processes table, however it is not scheduled, allowing for further initialization.
- Parameters:
glb – The global context of this virtual machine instance.
- Returns:
created context.
-
void context_destroy(Context *ctx)
Destroys a context.
Frees context resources and memory and removes it from the processes table. This should be called from the scheduler only. To actually delete a context that was created with context_new, use scheduler_terminate.
- Parameters:
c – the context that will be destroyed.
-
void context_process_kill_signal(Context *ctx, struct TermSignal *signal)
Process a kill signal, setting the exit reason and changing the killed flag.
- Parameters:
ctx – the context being executed
signal – the kill message
-
void context_process_process_info_request_signal(Context *ctx, struct BuiltInAtomRequestSignal *signal)
Process a process info request signal.
- Parameters:
ctx – the context being executed
signal – the kill message
-
bool context_process_signal_trap_answer(Context *ctx, struct TermSignal *signal)
Process a trap answer signal.
- Parameters:
ctx – the context being executed
signal – the answer message
- Returns:
true
if successful,false
in case of memory error
-
void context_process_flush_monitor_signal(Context *ctx, uint64_t ref_ticks, bool info)
Process a flush monitor signal.
- Parameters:
ctx – the context being executed
ref_ticks – the monitor reference
info – whether to return FALSE_ATOM if no message was flushed.
- void context_update_flags (Context *ctx, int mask, int value) CLANG_THREAD_SANITIZE_SAFE
Set or clear a flag on another context.
atomically update flags <- (flags & mask) | value
- Parameters:
ctx – the context to set/clear flag on.
mask – the mask to apply on flags
value – the value to set
-
size_t context_message_queue_len(Context *ctx)
Returns number of messages in the process’s mailbox.
- Parameters:
ctx – a valid context.
- Returns:
the number of messages in the process’s mailbox
-
size_t context_size(Context *ctx)
Returns total amount of size (in byes) occupied by the process.
- Parameters:
ctx – a valid context.
- Returns:
total amount of size (in byes) occupied by the process
-
bool context_get_process_info(Context *ctx, term *out, term atom_key)
Get process information.
- Parameters:
ctx – the context being executed
out – the answer term
atom_key – the key representing the info to get
- Returns:
true
if successful,false
in case of an error in which case *out is filled with an exception atom
-
int context_link(Context *ctx, term link_pid)
Half-link process to another process.
Caller must hold the global process lock. This creates one half of the link.
- Parameters:
ctx – context to link
monitor_pid – process to link ctx to
- Returns:
0 on success
-
uint64_t context_monitor(Context *ctx, term monitor_pid)
Create a monitor on a process.
Caller must hold the global process lock.
- Parameters:
ctx – context to monitor
monitor_pid – monitoring process
- Returns:
the ref ticks
-
struct ResourceMonitor *context_resource_monitor(Context *ctx, void *resource)
Create a resource monitor on a process.
Caller must hold the global process lock. The returned resource monitor is not added to the monitors list on the resource type.
- Parameters:
ctx – context to monitor
resource – resource object
- Returns:
the resource monitor