TinySTM  1.0.5
Functions
mod_mem.h File Reference

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)
 

Detailed Description

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.

Author
Pascal Felber pasca.nosp@m.l.fe.nosp@m.lber@.nosp@m.unin.nosp@m.e.ch Patrick Marlier patri.nosp@m.ck.m.nosp@m.arlie.nosp@m.r@un.nosp@m.ine.c.nosp@m.h
Date
2007-2014

Function Documentation

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.

Parameters
gcTrue (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.

Parameters
nmSize of the array to allocate.
sizeNumber of bytes to allocate.
Returns
Pointer to the allocated memory block.
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.

Parameters
addrAddress of the memory block.
sizeNumber 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.

Parameters
addrAddress of the memory block.
idxIndex of the first byte to overwrite.
sizeNumber of bytes to overwrite.
void* stm_malloc ( size_t  size)

Allocate memory from inside a transaction.

Allocated memory is implicitly freed upon abort.

Parameters
sizeNumber of bytes to allocate.
Returns
Pointer to the allocated memory block.