tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tml_inline.hpp
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2011
3  * University of Rochester Department of Computer Science
4  * and
5  * Lehigh University Department of Computer Science and Engineering
6  *
7  * License: Modified BSD
8  * Please see the file LICENSE.RSTM for licensing information
9  */
10 
11 #ifndef TMLINLINE_HPP__
12 #define TMLINLINE_HPP__
13 
14 /**
15  * In order to support inlining of TML instrumentation, we must make some
16  * metadata and implementation code visible in this file. It is provided
17  * below:
18  */
19 
20 #include "algs.hpp"
21 
22 namespace stm
23 {
24  /**
25  * TML requires this to be called after every read
26  */
27  inline void afterread_TML(TxThread* tx)
28  {
29  CFENCE;
30  if (__builtin_expect(timestamp.val != tx->start_time, false))
31  tx->tmabort(tx);
32  }
33 
34  /**
35  * TML requires this to be called before every write
36  */
37  inline void beforewrite_TML(TxThread* tx) {
38  // acquire the lock, abort on failure
39  if (!bcasptr(&timestamp.val, tx->start_time, tx->start_time + 1))
40  tx->tmabort(tx);
41  ++tx->start_time;
42  tx->tmlHasLock = true;
43  }
44 
45 } // namespace stm
46 
47 #endif // TMLINLINE_HPP__
Definition: stm_fraser.c:61
static NORETURN void(* tmabort)(TxThread *)
Definition: txthread.hpp:139
volatile uintptr_t val
Definition: metadata.hpp:117
void beforewrite_TML(TxThread *tx)
Definition: tml_inline.hpp:37
stm_tx * tx
Definition: stmskip.cc:245
void afterread_TML(TxThread *tx)
Definition: tml_inline.hpp:27
Definition: txthread.hpp:47
uintptr_t start_time
Definition: txthread.hpp:58
bool tmlHasLock
Definition: txthread.hpp:61
pad_word_t timestamp
Definition: algs.cpp:22