00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <pcm.h>
00034 #include <log.h>
00035
00036 #include "pwb_i.h"
00037
00038
00039 #ifndef RW_SET_SIZE
00040 #define RW_SET_SIZE (256*1024)
00041 #endif
00042
00043 #undef _DTABLE_MEMBER
00044 #define _DTABLE_MEMBER(result, function, args, ARG) ARG##function,
00045
00046
00047 mtm_dtable_t mtm_pwbnl_dtable =
00048 {
00049 FOREACH_ABI_FUNCTION (_DTABLE_MEMBER, mtm_pwbnl_)
00050 FOREACH_READ_BARRIER (_DTABLE_MEMBER, mtm_pwbnl_)
00051 FOREACH_WRITE_BARRIER (_DTABLE_MEMBER, mtm_pwbnl_)
00052 _ITM_FOREACH_MEMCPY (_DTABLE_MEMBER, mtm_pwbnl_)
00053 _ITM_FOREACH_LOG_TRANSFER (_DTABLE_MEMBER, mtm_local_)
00054 _ITM_FOREACH_MEMSET (_DTABLE_MEMBER, mtm_pwbnl_)
00055 _ITM_FOREACH_MEMMOVE (_DTABLE_MEMBER, mtm_pwbnl_)
00056 };
00057
00058
00059
00060 m_result_t
00061 mtm_pwbnl_create(mtm_tx_t *tx, mtm_mode_data_t **datap)
00062 {
00063 mtm_pwb_mode_data_t *data;
00064
00065 #if CM == CM_PRIORITY
00066 COMPILE_TIME_ASSERT((sizeof(w_entry_t) & ALIGNMENT_MASK) == 0);
00067 #endif
00068
00069 if ((data = (mtm_pwb_mode_data_t *) malloc(sizeof(mtm_pwb_mode_data_t)))
00070 == NULL)
00071 {
00072 return M_R_FAILURE;
00073 }
00074
00075
00076 data->r_set.nb_entries = 0;
00077 data->r_set.size = RW_SET_SIZE;
00078 mtm_allocate_rs_entries(tx, data, 0);
00079
00080
00081 data->w_set.nb_entries = 0;
00082 data->w_set.size = RW_SET_SIZE;
00083 data->w_set.reallocate = 0;
00084 mtm_allocate_ws_entries(tx, data, 0);
00085
00086
00087 #ifdef SYNC_TRUNCATION
00088 m_logmgr_alloc_log(tx->pcm_storeset, M_TMLOG_LF_TYPE, 0, &data->ptmlog_dsc);
00089 #else
00090 m_logmgr_alloc_log(tx->pcm_storeset, M_TMLOG_LF_TYPE, LF_ASYNC_TRUNCATION, &data->ptmlog_dsc);
00091 #endif
00092 data->ptmlog = (M_TMLOG_T *) data->ptmlog_dsc->log;
00093
00094 *datap = (mtm_mode_data_t *) data;
00095
00096 return M_R_SUCCESS;
00097 }
00098
00099
00100 m_result_t
00101 mtm_pwbnl_destroy(mtm_mode_data_t *_data)
00102 {
00103 mode_data_t *data = (mode_data_t *) _data;
00104 #ifdef EPOCH_GC
00105 mtm_word_t t;
00106 #endif
00107
00108 m_logmgr_free_log(data->ptmlog_dsc);
00109
00110 #ifdef EPOCH_GC
00111 t = GET_CLOCK;
00112 gc_free(data->r_set.entries, t);
00113 gc_free(data->w_set.entries, t);
00114 #else
00115 free(data->r_set.entries);
00116 free(data->w_set.entries);
00117 #endif
00118 }