usermode/library/mtm/src/mode/pwbetl/beginend.c

00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00033 #include "pwb_i.h"
00034 #include "mode/pwb-common/beginend-bits.h"
00035 
00036 
00037 uint32_t
00038 mtm_pwbetl_beginTransaction_internal (mtm_tx_t *tx, 
00039                                    uint32_t prop, 
00040                                    _ITM_srcLocation *srcloc)
00041 {
00042         return beginTransaction_internal (tx, prop, srcloc, 1);
00043 }
00044 
00045 
00046 void _ITM_CALL_CONVENTION
00047 mtm_pwbetl_rollbackTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00048 {
00049         assert ((tx->prop & pr_hasNoAbort) == 0);
00050         //assert ((mtm_tx()->state & STATE_ABORTING) == 0);
00051 
00052         rollback_transaction (tx);
00053         //tx->status |= STATE_ABORTING;
00054 }
00055 
00056 
00057 void _ITM_CALL_CONVENTION
00058 mtm_pwbetl_abortTransaction (mtm_tx_t *tx, 
00059                             _ITM_abortReason reason,
00060                             const _ITM_srcLocation *loc)
00061 {
00062         assert (reason == userAbort || reason == userRetry);
00063         /* Compiler Bug: pr_hasNoRetry seems to be wrong */
00064         assert ((reason == userAbort && (tx->prop & pr_hasNoAbort) == 0) || 
00065                 (reason == userRetry && 1));
00066         //assert ((tx->state & STATE_ABORTING) == 0);
00067 
00068         if (tx->status & TX_IRREVOCABLE) {
00069                 abort ();
00070         }       
00071 
00072         if (reason == userAbort) {
00073                 rollback_transaction (tx);
00074                 //pwb_fini (td);
00075 
00076                 /* TODO: Implement serial mode to support irrevocable actions such as I/O
00077                  * 
00078                  * mtm_rwlock_unlock (&mtm_serial_lock);
00079                  * 
00080                  */
00081 
00082                 /* TODO: Implement true nesting. Currently we only flatten  nested 
00083                  * transactions.
00084                  * 
00085                  * set_mtm_tx (tx->prev);     
00086                  * free_tx (td, tx);
00087                  */
00088 
00089                 mtm_longjmp (&tx->jb, a_abortTransaction | a_restoreLiveVariables);
00090         } else if (reason == userRetry) {
00091                 mtm_pwb_restart_transaction(tx, RESTART_USER_RETRY);
00092         }
00093 }
00094 
00095 
00096 bool _ITM_CALL_CONVENTION
00097 mtm_pwbetl_tryCommitTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00098 {
00099         return trycommit_transaction(tx, 1);
00100 }
00101 
00102 
00103 void _ITM_CALL_CONVENTION
00104 mtm_pwbetl_commitTransaction(mtm_tx_t *tx, const _ITM_srcLocation *loc)
00105 {
00106         MTM_DEBUG_PRINT("==> mtm_pwb_commitTransaction(%p)\n", tx);
00107         if (!trycommit_transaction(tx, 1)) {
00108                 mtm_pwb_restart_transaction(tx, RESTART_VALIDATE_COMMIT);
00109         }
00110         if (tx->status == TX_COMMITTED) {
00111                 tx->status = TX_IDLE; //FIXME: Can we set IDLE here ? Don't others depend
00112                                       // on seeing our state as TX_COMMITTED. For example, 
00113                                       // do we need to quiesce first? TinySTM 1.0.0 has 
00114                                       // quiescence support.
00115         }                                                         
00116 
00117         MTM_DEBUG_PRINT("==> mtm_pwb_commitTransaction(%p): DONE\n", tx);
00118 }
00119 
00120 
00121 void _ITM_CALL_CONVENTION
00122 mtm_pwbetl_commitTransactionToId(mtm_tx_t *tx, 
00123                                 const _ITM_transactionId tid,
00124                                 const _ITM_srcLocation *loc)
00125 {
00126         //TODO
00127         assert(0);
00128 }
00129 
00130 
00131 

Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7