Erlang Central

Difference between revisions of "A Guide To The Erlang Source"

From ErlangCentral Wiki

Line 17: Line 17:
 
== Scheduler ==
 
== Scheduler ==
 
The process struct is defined in erts/emulator/beam/process.h. The important function is Process *schedule(Process *p, int calls) in process.c . The next process is picked in "pick_next_process" of that method.
 
The process struct is defined in erts/emulator/beam/process.h. The important function is Process *schedule(Process *p, int calls) in process.c . The next process is picked in "pick_next_process" of that method.
 +
 +
== Process ==
 +
Process statuses are:
 +
#define P_FREE      0
 +
#define P_RUNABLE  1
 +
#define P_WAITING  2
 +
#define P_RUNNING  3
 +
#define P_EXITING  4
 +
#define P_GARBING  5
 +
#define P_SUSPENDED 6
 +
  
 
== Monitors and links ==
 
== Monitors and links ==
 
See erl_monitor.c and .h. The main structs are ErtsLinks and ErtsMonitor.
 
See erl_monitor.c and .h. The main structs are ErtsLinks and ErtsMonitor.
 
Each process has a *ErtLinks and *ErtsMonitor (herein all its links/monitors are kept as an AVL tree). Actions are done with erts_sweep_links(ErtsLink *root, ...) and  erts_sweep_monitors(ErtsMonitor *root, ...).
 
Each process has a *ErtLinks and *ErtsMonitor (herein all its links/monitors are kept as an AVL tree). Actions are done with erts_sweep_links(ErtsLink *root, ...) and  erts_sweep_monitors(ErtsMonitor *root, ...).

Revision as of 20:19, 19 August 2009

A guide to the erlang source.

Contents

Download

The source can be downloaded from: http://erlang.org/download.html or http://github.com/mfoemmel/erlang-otp/tree/master

Tree

Most of the interesting code is in: erts/emulator/beam

Atoms

The atoms used in erlang are listed in erts/emulator/beam/atom.names and are referenced in the code as am_foo. So the 'EXIT' atom is am_EXIT in the code.

Types

Most used types are: Sint, Uint, Eterm, ... Conversion is done in erts/emulator/beam/big.c. For example uint_to_big(Uint x, Eterm *y). term_to_Uint(Eterm term, Uint *up)

Scheduler

The process struct is defined in erts/emulator/beam/process.h. The important function is Process *schedule(Process *p, int calls) in process.c . The next process is picked in "pick_next_process" of that method.

Process

Process statuses are:

  1. define P_FREE 0
  2. define P_RUNABLE 1
  3. define P_WAITING 2
  4. define P_RUNNING 3
  5. define P_EXITING 4
  6. define P_GARBING 5
  7. define P_SUSPENDED 6


Monitors and links

See erl_monitor.c and .h. The main structs are ErtsLinks and ErtsMonitor. Each process has a *ErtLinks and *ErtsMonitor (herein all its links/monitors are kept as an AVL tree). Actions are done with erts_sweep_links(ErtsLink *root, ...) and erts_sweep_monitors(ErtsMonitor *root, ...).