Module for dynamic memory management. More...
Go to the source code of this file.
Functions | |
void * | stm_malloc (size_t size) |
Allocate memory from inside a transaction. | |
void | stm_free (void *addr, size_t size) |
Free memory from inside a transaction. | |
void | stm_free2 (void *addr, size_t idx, size_t size) |
Free memory from inside a transaction. | |
void | mod_mem_init (int gc) |
Initialize the module. |
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_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. |