EM-ODP  3.7.0
Event Machine on ODP
Initialization and termination

Event Machine initialization and termination. More...

Data Structures

struct  em_conf_t
 

Functions

void em_conf_init (em_conf_t *conf)
 
em_status_t em_init (const em_conf_t *conf)
 
em_status_t em_init_core (void)
 
em_status_t em_term (const em_conf_t *conf)
 
em_status_t em_term_core (void)
 
uint16_t em_device_id (void)
 

Detailed Description

Event Machine initialization and termination.

The Event Machine must be initialized before use. One core that will be part of EM calls em_init(). Additionally, after the user has set up the threads, or processes and pinned those to HW-cores, each participating core, i.e. EM-core, needs to run em_init_core(). Only now is an EM-core ready to use the other EM API functions and can finally enter the dispatch-loop via em_dispath() on each core that should handle events.

The EM termination sequence runs in the opposite order: each core needs to call em_term_core() before one last call to em_term().

The 'em_conf_t' type given to em_init() and em_term() is HW/platform specific and is defined in event_machine_hw_types.h

Do not include this from the application, event_machine.h will do it for you.

Function Documentation

◆ em_conf_init()

void em_conf_init ( em_conf_t conf)

Initialize configuration parameters for em_init()

Initialize em_conf_t to default values for all fields. After initialization, the user further needs to set the mandatory fields of 'em_conf_t' before calling em_init(). Always initialize 'conf' first with em_conf_init(&conf) to ensure backwards compatibility with potentially added new options.

Parameters
confAddress of the em_conf_t to be initialized
See also
em_init()
Examples
bench_event.c, and bench_pool.c.

Definition at line 54 of file event_machine_init.c.

◆ em_device_id()

uint16_t em_device_id ( void  )

Return the EM device-id for this instance.

This is a convenience function that returns the EM device-id given by the user to em_init() via the em_conf_t::device_id field.

The function should only be called after a successful EM initialization.

Returns
the device-id of this EM instance.

Definition at line 468 of file event_machine_init.c.

◆ em_init()

em_status_t em_init ( const em_conf_t conf)

Initialize the Event Machine.

Must be called once at startup. Additionally each EM-core needs to call the em_init_core() function before using any further EM API functions/resources.

Parameters
confEM runtime config options, HW/platform specific: see event_machine_hw_types.h
Returns
EM_OK if successful.
See also
em_init_core() for EM-core specific Initialization and termination after em_init().
Examples
bench_event.c, and bench_pool.c.

Definition at line 65 of file event_machine_init.c.

◆ em_init_core()

em_status_t em_init_core ( void  )

Initialize an EM-core.

Must be called once by each EM-core (= process, thread or bare metal core). EM queues, EOs, queue groups etc. can be created after a successful return from this function. Note, the thread or process must be pinned to a unique physical core before running em_init_core().

Returns
EM_OK if successful.
See also
em_init()
Examples
bench_event.c, and bench_pool.c.

Definition at line 247 of file event_machine_init.c.

◆ em_term()

em_status_t em_term ( const em_conf_t conf)

Terminate the Event Machine.

Called once at exit. Additionally, before the one call to em_term(), each EM-core needs to call the em_term_core() function to free up local resources.

Parameters
confEM runtime config options
Returns
EM_OK if successful.
See also
em_term_core() for EM-core specific termination before em_term().
Examples
bench_event.c, and bench_pool.c.

Definition at line 351 of file event_machine_init.c.

◆ em_term_core()

em_status_t em_term_core ( void  )

Terminate an EM-core.

Called by each EM-core (= process, thread or bare metal core) before one call to em_term().

Returns
EM_OK if successful.
See also
em_term()
Examples
bench_event.c, and bench_pool.c.

Definition at line 416 of file event_machine_init.c.