TinySTM
1.0.5
|
Module for dynamic memory management. More...
Go to the source code of this file.
Functions | |
void | mod_mem_init (int gc) |
Initialize the module. More... | |
void * | stm_malloc (size_t size) |
Allocate memory from inside a transaction. More... | |
void * | stm_malloc_tx (struct stm_tx *tx, size_t size) |
void * | stm_calloc (size_t nm, size_t size) |
Allocate initialized memory from inside a transaction. More... | |
void * | stm_calloc_tx (struct stm_tx *tx, size_t nm, size_t size) |
void | stm_free (void *addr, size_t size) |
Free memory from inside a transaction. More... | |
void | stm_free_tx (struct stm_tx *tx, void *addr, size_t size) |
void | stm_free2 (void *addr, size_t idx, size_t size) |
Free memory from inside a transaction. More... | |
void | stm_free2_tx (struct stm_tx *tx, void *addr, size_t idx, size_t size) |
Module for dynamic memory management.
This module provides functions for allocations and freeing memory inside transactions. A block allocated inside the transaction will be implicitly freed upon abort, and a block freed inside a transaction will only be returned to the system upon commit.
void mod_mem_init | ( | int | gc) |
Initialize the module.
This function must be called once, from the main thread, after initializing the STM library and before performing any transactional operation.
gc | True (non-zero) to enable epoch-based garbage collector when freeing memory in transactions. |
void* stm_calloc | ( | size_t | nm, |
size_t | size | ||
) |
Allocate initialized memory from inside a transaction.
Allocated memory is implicitly freed upon abort.
nm | Size of the array to allocate. |
size | Number of bytes to allocate. |
void stm_free | ( | void * | addr, |
size_t | size | ||
) |
Free memory from inside a transaction.
Freed memory is only returned to the system upon commit and can optionally be overwritten (more precisely, the locks protecting the memory are acquired) to prevent another transaction from accessing the freed memory and observe inconsistent states.
addr | Address of the memory block. |
size | Number of bytes to overwrite. |
void stm_free2 | ( | void * | addr, |
size_t | idx, | ||
size_t | size | ||
) |
Free memory from inside a transaction.
Freed memory is only returned to the system upon commit and can optionally be overwritten (more precisely, the locks protecting the memory are acquired) to prevent another transaction from accessing the freed memory and observe inconsistent states.
addr | Address of the memory block. |
idx | Index of the first byte to overwrite. |
size | Number of bytes to overwrite. |
void* stm_malloc | ( | size_t | size) |
Allocate memory from inside a transaction.
Allocated memory is implicitly freed upon abort.
size | Number of bytes to allocate. |