Embedded Multicore Building Blocks V1.0.0
Typedefs | Functions
Core Set

Core sets for thread-to-core affinities. More...

Typedefs

typedef opaque_type embb_core_set_t
 Opaque type representing a set of processor cores. More...
 

Functions

unsigned int embb_core_count_available ()
 Returns the number of available processor cores. More...
 
void embb_core_set_init (embb_core_set_t *core_set, int initializer)
 Initializes the specified core set. More...
 
void embb_core_set_add (embb_core_set_t *core_set, unsigned int core_number)
 Adds a core to the specified set. More...
 
void embb_core_set_remove (embb_core_set_t *core_set, unsigned int core_number)
 Removes a core from the specified set. More...
 
int embb_core_set_contains (const embb_core_set_t *core_set, unsigned int core_number)
 Determines whether a core is contained in the specified set. More...
 
void embb_core_set_intersection (embb_core_set_t *set1, const embb_core_set_t *set2)
 Computes the intersection of core set1 and set2. More...
 
void embb_core_set_union (embb_core_set_t *set1, const embb_core_set_t *set2)
 Computes the union of core set1 and set2. More...
 
unsigned int embb_core_set_count (const embb_core_set_t *core_set)
 Returns the number of cores contained in the specified set. More...
 

Detailed Description

Core sets for thread-to-core affinities.

Typedef Documentation

typedef opaque_type embb_core_set_t

Opaque type representing a set of processor cores.

An instance of this type represents a subset of processor cores. Core sets can be used to set thread-to-core affinities. A core in a core set might just represent a logical core (hyper-thread), depending on the underlying hardware. Each core is identified by a unique integer starting with 0. For example, the cores of a quad-core system are represented by the set {0,1,2,3}.

See also
embb_core_count_available()

Function Documentation

unsigned int embb_core_count_available ( )

Returns the number of available processor cores.

If the processor supports hyper-threading, each hyper-thread is treated as a separate processor core.

Returns
Number of cores including hyper-threads
Concurrency
Not thread-safe
void embb_core_set_init ( embb_core_set_t core_set,
int  initializer 
)

Initializes the specified core set.

The second parameter specifies whether the set is initially empty or contains all cores.

Precondition
core_set is not NULL.
Concurrency
Not thread-safe
Parameters
[out]core_setCore set to initialize
[in]initializerThe set is initially empty if initializer == 0, otherwise it contains all available processor cores.
void embb_core_set_add ( embb_core_set_t core_set,
unsigned int  core_number 
)

Adds a core to the specified set.

If the core is already contained in the set, the operation has no effect.

Precondition
core_set is not NULL and core_number is smaller than embb_core_count_available().
Concurrency
Not thread-safe
See also
embb_core_set_remove()
Parameters
[in,out]core_setCore set to be manipulated
[in]core_numberNumber of core to be added.
void embb_core_set_remove ( embb_core_set_t core_set,
unsigned int  core_number 
)

Removes a core from the specified set.

If the core is not in the set, the operation has no effect.

Precondition
core_set is not NULL and core_number is smaller than embb_core_count_available().
Concurrency
Not thread-safe
See also
embb_core_set_add()
Parameters
[in,out]core_setCore set to be manipulated
[in]core_numberNumber of core to be removed
int embb_core_set_contains ( const embb_core_set_t core_set,
unsigned int  core_number 
)

Determines whether a core is contained in the specified set.

Precondition
core_set is not NULL and core_number is smaller than embb_core_count_available().
Returns
0 if the core is not contained in the set, otherwise a number greater than zero.
Concurrency
Not thread-safe
Parameters
[in]core_setCore set
[in]core_numberNumber of core
void embb_core_set_intersection ( embb_core_set_t set1,
const embb_core_set_t set2 
)

Computes the intersection of core set1 and set2.

The result is stored in set1.

Precondition
set1 and set2 are not NULL.
Concurrency
Not thread-safe
See also
embb_core_set_union()
Parameters
[in,out]set1First set, gets overwritten by the result
[in]set2Second set
void embb_core_set_union ( embb_core_set_t set1,
const embb_core_set_t set2 
)

Computes the union of core set1 and set2.

The result is stored in set1.

Precondition
set1 and set2 are not NULL.
Concurrency
Not thread-safe
See also
embb_core_set_intersection()
Parameters
[in,out]set1First set
[in]set2Second set
unsigned int embb_core_set_count ( const embb_core_set_t core_set)

Returns the number of cores contained in the specified set.

Precondition
core_set is not NULL.
Concurrency
Not thread-safe
Returns
Number of cores in core_set
Parameters
[in]core_setCore set whose elements are counted