usermode/library/mtm/src/mode/pwbnl/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_pwbnl_beginTransaction_internal (mtm_tx_t *tx, 
00039                                    uint32_t prop, 
00040                                    _ITM_srcLocation *srcloc)
00041 {
00042         return beginTransaction_internal (tx, prop, srcloc, 0);
00043 }
00044 
00045 
00046 void _ITM_CALL_CONVENTION
00047 mtm_pwbnl_rollbackTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00048 {
00049 #if (!defined(ALLOW_ABORTS))
00050         assert(0 && "Aborts disabled but want to abort.\n");
00051 #endif
00052 
00053         assert ((tx->prop & pr_hasNoAbort) == 0);
00054         //assert ((mtm_tx()->state & STATE_ABORTING) == 0);
00055 
00056         rollback_transaction (tx);
00057         //tx->status |= STATE_ABORTING;
00058 }
00059 
00060 
00061 void _ITM_CALL_CONVENTION
00062 mtm_pwbnl_abortTransaction (mtm_tx_t *tx, 
00063                             _ITM_abortReason reason,
00064                             const _ITM_srcLocation *loc)
00065 {
00066 #if (!defined(ALLOW_ABORTS))
00067         assert(0 && "Aborts disabled but want to abort.\n");
00068 #endif
00069 
00070         assert (reason == userAbort || reason == userRetry);
00071         /* Compiler Bug: pr_hasNoRetry seems to be wrong */
00072         assert ((reason == userAbort && (tx->prop & pr_hasNoAbort) == 0) || 
00073                 (reason == userRetry && 1));
00074         //assert ((tx->state & STATE_ABORTING) == 0);
00075 
00076         if (tx->status & TX_IRREVOCABLE) {
00077                 abort ();
00078         }       
00079 
00080         if (reason == userAbort) {
00081                 rollback_transaction (tx);
00082                 /* FIXME: Currently we don't support true nesting, but only flatten
00083                  *        nested transactions.
00084                  * 
00085                  * pwb_fini (td);             
00086                  * set_mtm_tx (tx->prev);     
00087                  * free_tx (td, tx);
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_pwbnl_tryCommitTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00098 {
00099         return trycommit_transaction(tx, 0);
00100 }
00101 
00102 
00103 void _ITM_CALL_CONVENTION
00104 mtm_pwbnl_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, 0)) {
00108 #if (!defined(ALLOW_ABORTS))
00109                 assert(0 && "Aborts disabled but want to rollback...\n");
00110 #endif
00111                 mtm_pwb_restart_transaction(tx, RESTART_VALIDATE_COMMIT);
00112         }
00113         if (tx->status == TX_COMMITTED) {
00114                 tx->status = TX_IDLE; //FIXME: Can we set IDLE here ? Don't others depend
00115                                       // on seeing our state as TX_COMMITTED. For example, 
00116                                       // do we need to quiesce first? TinySTM 1.0.0 has 
00117                                       // quiescence support.
00118         }                                                         
00119 
00120         MTM_DEBUG_PRINT("==> mtm_pwb_commitTransaction(%p): DONE\n", tx);
00121 }
00122 
00123 
00124 void _ITM_CALL_CONVENTION
00125 mtm_pwbnl_commitTransactionToId(mtm_tx_t *tx, 
00126                                 const _ITM_transactionId tid,
00127                                 const _ITM_srcLocation *loc)
00128 {
00129         //TODO
00130         assert(0);
00131 }

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