scheduler.h
Include dependency graph for scheduler.h:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"8" [label="stdbool.h" tooltip="stdbool.h"]
"5" [label="atom.h" tooltip="atom.h"]
"11" [label="assert.h" tooltip="assert.h"]
"16" [label="synclist.h" tooltip="synclist.h"]
"4" [label="stdint.h" tooltip="stdint.h"]
"6" [label="stdlib.h" tooltip="stdlib.h"]
"1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" fillcolor="#BFBFBF"]
"2" [label="context.h" tooltip="context.h"]
"22" [label="utils.h" tooltip="utils.h"]
"14" [label="ets.h" tooltip="ets.h"]
"7" [label="atom_table.h" tooltip="atom_table.h"]
"10" [label="term_typedef.h" tooltip="term_typedef.h"]
"23" [label="stddef.h" tooltip="stddef.h"]
"12" [label="limits.h" tooltip="limits.h"]
"24" [label="refc_binary.h" tooltip="refc_binary.h"]
"20" [label="string.h" tooltip="string.h"]
"26" [label="mailbox.h" tooltip="mailbox.h"]
"19" [label="term.h" tooltip="term.h"]
"9" [label="erl_nif.h" tooltip="erl_nif.h"]
"25" [label="resources.h" tooltip="resources.h"]
"18" [label="smp.h" tooltip="smp.h"]
"3" [label="globalcontext.h" tooltip="globalcontext.h"]
"21" [label="memory.h" tooltip="memory.h"]
"17" [label="stdio.h" tooltip="stdio.h"]
"27" [label="timer_list.h" tooltip="timer_list.h"]
"15" [label="list.h" tooltip="list.h"]
"13" [label="inttypes.h" tooltip="inttypes.h"]
"5" -> "4" [dir=forward tooltip="include"]
"5" -> "6" [dir=forward tooltip="include"]
"16" -> "17" [dir=forward tooltip="include"]
"16" -> "15" [dir=forward tooltip="include"]
"16" -> "18" [dir=forward tooltip="include"]
"1" -> "2" [dir=forward tooltip="include"]
"1" -> "3" [dir=forward tooltip="include"]
"2" -> "3" [dir=forward tooltip="include"]
"2" -> "15" [dir=forward tooltip="include"]
"2" -> "26" [dir=forward tooltip="include"]
"2" -> "18" [dir=forward tooltip="include"]
"2" -> "19" [dir=forward tooltip="include"]
"2" -> "27" [dir=forward tooltip="include"]
"22" -> "23" [dir=forward tooltip="include"]
"22" -> "17" [dir=forward tooltip="include"]
"22" -> "6" [dir=forward tooltip="include"]
"14" -> "15" [dir=forward tooltip="include"]
"14" -> "16" [dir=forward tooltip="include"]
"14" -> "19" [dir=forward tooltip="include"]
"7" -> "8" [dir=forward tooltip="include"]
"7" -> "5" [dir=forward tooltip="include"]
"10" -> "11" [dir=forward tooltip="include"]
"10" -> "12" [dir=forward tooltip="include"]
"10" -> "13" [dir=forward tooltip="include"]
"10" -> "4" [dir=forward tooltip="include"]
"24" -> "8" [dir=forward tooltip="include"]
"24" -> "6" [dir=forward tooltip="include"]
"24" -> "15" [dir=forward tooltip="include"]
"24" -> "25" [dir=forward tooltip="include"]
"26" -> "8" [dir=forward tooltip="include"]
"26" -> "15" [dir=forward tooltip="include"]
"26" -> "10" [dir=forward tooltip="include"]
"26" -> "22" [dir=forward tooltip="include"]
"19" -> "8" [dir=forward tooltip="include"]
"19" -> "4" [dir=forward tooltip="include"]
"19" -> "17" [dir=forward tooltip="include"]
"19" -> "6" [dir=forward tooltip="include"]
"19" -> "20" [dir=forward tooltip="include"]
"19" -> "21" [dir=forward tooltip="include"]
"19" -> "24" [dir=forward tooltip="include"]
"19" -> "22" [dir=forward tooltip="include"]
"19" -> "10" [dir=forward tooltip="include"]
"9" -> "10" [dir=forward tooltip="include"]
"25" -> "6" [dir=forward tooltip="include"]
"25" -> "9" [dir=forward tooltip="include"]
"25" -> "15" [dir=forward tooltip="include"]
"25" -> "21" [dir=forward tooltip="include"]
"18" -> "8" [dir=forward tooltip="include"]
"3" -> "4" [dir=forward tooltip="include"]
"3" -> "5" [dir=forward tooltip="include"]
"3" -> "7" [dir=forward tooltip="include"]
"3" -> "9" [dir=forward tooltip="include"]
"3" -> "14" [dir=forward tooltip="include"]
"3" -> "15" [dir=forward tooltip="include"]
"3" -> "26" [dir=forward tooltip="include"]
"3" -> "18" [dir=forward tooltip="include"]
"3" -> "16" [dir=forward tooltip="include"]
"3" -> "19" [dir=forward tooltip="include"]
"3" -> "27" [dir=forward tooltip="include"]
"21" -> "4" [dir=forward tooltip="include"]
"21" -> "6" [dir=forward tooltip="include"]
"21" -> "9" [dir=forward tooltip="include"]
"21" -> "10" [dir=forward tooltip="include"]
"21" -> "22" [dir=forward tooltip="include"]
"27" -> "8" [dir=forward tooltip="include"]
"27" -> "4" [dir=forward tooltip="include"]
"27" -> "15" [dir=forward tooltip="include"]
"15" -> "8" [dir=forward tooltip="include"]
}](../../../_images/graphviz-445b7c3d2f8981bb3010192af39d0300c8ac3a20.png)
This graph shows which files directly or indirectly include scheduler.h:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" fillcolor="#BFBFBF"]
"3" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c"]
"4" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c"]
"2" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c"]
"5" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c"]
"1" -> "2" [dir=back tooltip="include"]
"1" -> "3" [dir=back tooltip="include"]
"1" -> "4" [dir=back tooltip="include"]
"1" -> "5" [dir=back tooltip="include"]
}](../../../_images/graphviz-bf64d3f63a865897d467092f646c1db02b980590.png)
Scheduling functions.
Scheduling functions are used to schedule processes.
Defines
-
DEFAULT_REDUCTIONS_AMOUNT 1024
Functions
-
Context *scheduler_run(GlobalContext *global)
run the scheduler and return a process to be executed.
- Parameters:
global – the global context.
-
Context *scheduler_wait(Context *c)
move a process to waiting queue and wait a ready one
move current process to the waiting queue, and schedule the next one or sleep until an event is received.
- Parameters:
c – the process context.
-
void scheduler_init_ready(Context *c)
Init a process in the ready state, moving it to the scheduler queue.
- Parameters:
c – the process context.
-
void scheduler_signal_message(Context *c)
Signal a process that a message was inserted in the mailbox.
Cannot be called from a foreign task or from ISR.
- Parameters:
c – the process context.
-
void scheduler_signal_message_from_task(Context *c)
Signal a process that a message was inserted in the mailbox.
Must only be called while global->processes_spinlock is acquired.
- Parameters:
c – the process context.
-
void scheduler_kill(Context *ctx)
Signal a process that it was killed.
- Parameters:
ctx – the process context.
-
void scheduler_terminate(Context *c)
removes a process and terminates it from the scheduling queue
removes a process from the scheduling ready queue and destroys it if its not a leader process.
- Parameters:
c – the process that is going to be terminated.
-
void scheduler_stop_all(GlobalContext *global)
Terminate all schedulers. Every process is terminated gracefully at next scheduling point.
- Parameters:
global – the global context.
-
Context *scheduler_next(GlobalContext *global, Context *c)
gets next runnable process from the ready queue.
gets next runnable process from the ready queue, it may return current process if there isn’t any other runnable process.
- Parameters:
global – the global context.
c – the current process.
- Returns:
runnable process.
-
void scheduler_set_timeout(Context *ctx, avm_int64_t timeout)
sets context timeout
set context timeout timestamp, move context to wait queue and update global next timeout timestamp.
- Parameters:
ctx – the context that will be put on sleep
timeout – amount of time to be waited in milliseconds.
-
int scheduler_entry_point(GlobalContext *glb)
Entry point for schedulers.
- Parameters:
glb – the global context.