tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
stamp.hpp File Reference
#include <setjmp.h>
#include <cstdlib>
#include <cassert>
#include <api/library.hpp>
Include dependency graph for stamp.hpp:

Go to the source code of this file.

Macros

#define STM_THREAD_T   stm::TxThread
 
#define STM_SELF   tm_descriptor
 
#define STM_STARTUP(numThread)   tm_main_startup()
 
#define STM_SHUTDOWN()   stm::sys_shutdown()
 
#define STM_NEW_THREAD()   0
 
#define STM_INIT_THREAD(t, id)   tm_start(&t, thread_getId())
 
#define STM_FREE_THREAD(t)
 
#define STM_RESTART()   stm::restart()
 
#define STM_LOCAL_WRITE_I(var, val)   ({var = val; var;})
 
#define STM_LOCAL_WRITE_L(var, val)   ({var = val; var;})
 
#define STM_LOCAL_WRITE_F(var, val)   ({var = val; var;})
 
#define STM_LOCAL_WRITE_P(var, val)   ({var = val; var;})
 
#define STM_BEGIN_WR()
 
#define STM_END()
 
#define STM_BEGIN_RD()   STM_BEGIN_WR()
 

Functions

void * tx_safe_non_tx_alloc (size_t size)
 
void tx_safe_non_tx_free (void *ptr)
 
void tm_main_startup ()
 
void tm_start (stm::TxThread **desc, int id)
 

Macro Definition Documentation

#define STM_BEGIN_RD ( )    STM_BEGIN_WR()
#define STM_BEGIN_WR ( )
Value:
{ \
jmp_buf jmpbuf_; \
uint32_t abort_flags = setjmp(jmpbuf_); \
begin(static_cast<stm::TxThread*>(STM_SELF), &jmpbuf_, abort_flags);\
CFENCE; \
{
#define STM_SELF
Definition: stamp.hpp:30
TM_INLINE void begin(TxThread *tx, scope_t *s, uint32_t)
Definition: library.hpp:71

The begin and commit instrumentation are straightforward

#define STM_END ( )
Value:
} \
commit(static_cast<stm::TxThread*>(STM_SELF)); \
}
#define STM_SELF
Definition: stamp.hpp:30
TM_INLINE void commit(TxThread *tx)
Definition: library.hpp:104
#define STM_FREE_THREAD (   t)
#define STM_INIT_THREAD (   t,
  id 
)    tm_start(&t, thread_getId())
#define STM_LOCAL_WRITE_F (   var,
  val 
)    ({var = val; var;})
#define STM_LOCAL_WRITE_I (   var,
  val 
)    ({var = val; var;})
#define STM_LOCAL_WRITE_L (   var,
  val 
)    ({var = val; var;})
#define STM_LOCAL_WRITE_P (   var,
  val 
)    ({var = val; var;})
#define STM_NEW_THREAD ( )    0
#define STM_RESTART ( )    stm::restart()
#define STM_SELF   tm_descriptor
#define STM_SHUTDOWN ( )    stm::sys_shutdown()
#define STM_STARTUP (   numThread)    tm_main_startup()
#define STM_THREAD_T   stm::TxThread

Copyright (C) 2011 University of Rochester Department of Computer Science and Lehigh University Department of Computer Science and Engineering

License: Modified BSD Please see the file LICENSE.RSTM for licensing information We are gradually moving to a state where STAMP will be in pure C++. Clearly we are not there yet, but currently we have STAMP set to build with g++ instead of gcc.

That being the case, we're going to avoid some cruft by mapping MACROs directly to c++ functions, instead of hiding code within an 'extern C' block with C-style wrapper functions.

Function Documentation

void tm_main_startup ( )
inline

tm_main_startup()

call before any threads try to run transactions, in order to ensure that the TM library is properly configured.

multiple calls are safe, since the library protects itself

Here is the call graph for this function:

void tm_start ( stm::TxThread **  desc,
int  id 
)
inline

tm_start(desc, id)

STAMP uses this during its main processing loop, once all of the threads have been created and are sitting at a barrier waiting to start. We expect it to be only called once per thread, but it is ok if it is called more than once.

The thread that called tm_main_startup(...) /can/, but does not have to, call this routine.

Here is the call graph for this function:

void* tx_safe_non_tx_alloc ( size_t  size)
inline

Special alloc for STAMP, used to detect nontransactional mallocs from within transactions

void tx_safe_non_tx_free ( void *  ptr)
inline

Special free for STAMP, used to detect nontransactional frees from within transactions