uninit_id = id_to_int(uninit->get_tid());
list->push_front(uninit);
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_wr_thrd_map, act->get_location());
- if (uninit_id >= (int)vec->size())
- vec->resize(uninit_id + 1);
+ if (uninit_id >= (int)vec->size()) {
+ int oldsize = (int) vec->size();
+ vec->resize(uninit_id + 1);
+ for(int i=oldsize; i<uninit_id+1; i++)
+ new (&vec[i]) action_list_t();
+ }
(*vec)[uninit_id].push_front(uninit);
}
list->push_back(act);
// Update obj_thrd_map, a per location, per thread, order of actions
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_thrd_map, act->get_location());
- if (tid >= (int)vec->size())
- vec->resize(priv->next_thread_id);
+ if (tid >= (int)vec->size()) {
+ uint oldsize =vec->size();
+ vec->resize(priv->next_thread_id);
+ for(uint i=oldsize; i<priv->next_thread_id; i++)
+ new (&vec[i]) action_list_t();
+ }
(*vec)[tid].push_back(act);
if (uninit)
(*vec)[uninit_id].push_front(uninit);
get_safe_ptr_action(&obj_map, mutex_loc)->push_back(act);
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_thrd_map, mutex_loc);
- if (tid >= (int)vec->size())
- vec->resize(priv->next_thread_id);
+ if (tid >= (int)vec->size()) {
+ uint oldsize = vec->size();
+ vec->resize(priv->next_thread_id);
+ for(uint i=oldsize; i<priv->next_thread_id; i++)
+ new (&vec[i]) action_list_t();
+ }
(*vec)[tid].push_back(act);
}
}
// Update obj_thrd_map, a per location, per thread, order of actions
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_thrd_map, act->get_location());
- if (tid >= (int)vec->size())
- vec->resize(priv->next_thread_id);
+ if (tid >= (int)vec->size()) {
+ uint oldsize =vec->size();
+ vec->resize(priv->next_thread_id);
+ for(uint i=oldsize; i<priv->next_thread_id; i++)
+ new (&vec[i]) action_list_t();
+ }
insertIntoActionList(&(*vec)[tid],act);
// Update thrd_last_action, the last action taken by each thrad
void ModelExecution::add_write_to_lists(ModelAction *write) {
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_wr_thrd_map, write->get_location());
int tid = id_to_int(write->get_tid());
- if (tid >= (int)vec->size())
- vec->resize(priv->next_thread_id);
+ if (tid >= (int)vec->size()) {
+ uint oldsize =vec->size();
+ vec->resize(priv->next_thread_id);
+ for(uint i=oldsize; i<priv->next_thread_id; i++)
+ new (&vec[i]) action_list_t();
+ }
(*vec)[tid].push_back(write);
}
* thread which just took a step--plus the first step
* for any newly-created thread
*/
- ModelAction * pending;
for (unsigned int i = 0;i < get_num_threads();i++) {
thread_id_t tid = int_to_id(i);
Thread *thr = get_thread(tid);
- if (!thr->is_model_thread() && !thr->is_complete() && ((!(pending=thr->get_pending())) || is_nonsc_write(pending)) ) {
+ if (!thr->is_model_thread() && !thr->is_complete() && (!thr->get_pending())) {
switch_from_master(thr); // L: context swapped, and action type of thr changed.
if (thr->is_waiting_on(thr))
assert_bug("Deadlock detected (thread %u)", i);
#include "mymemory.h"
template<typename _Tp>
-class ModelList : public std::list<_Tp, ModelAlloc<_Tp> >
-{
-public:
- typedef std::list< _Tp, ModelAlloc<_Tp> > list;
-
- ModelList() :
- list()
- { }
-
- ModelList(size_t n, const _Tp& val = _Tp()) :
- list(n, val)
- { }
-
- MEMALLOC
+class mllnode {
+ public:
+ _Tp getVal() {return val;}
+ mllnode<_Tp> * getNext() {return next;}
+ mllnode<_Tp> * getPrev() {return prev;}
+ MEMALLOC;
+
+ private:
+ mllnode<_Tp> * next;
+ mllnode<_Tp> * prev;
+ _Tp val;
+ friend class ModelList;
};
template<typename _Tp>
-class SnapList : public std::list<_Tp, SnapshotAlloc<_Tp> >
+class ModelList
{
-public:
- typedef std::list<_Tp, SnapshotAlloc<_Tp> > list;
-
- SnapList() :
- list()
- { }
+public:
+ ModelList() : head(NULL),
+ tail(NULL) {
+ }
+
+ void push_front(_Tp val) {
+ mllnode<_Tp> * tmp = new mllnode<_Tp>();
+ tmp->prev = NULL;
+ tmp->next = head;
+ tmp->val = val;
+ if (head == NULL)
+ tail = tmp;
+ else
+ head->prev = tmp;
+ head = tmp;
+ }
+
+ void push_back(_Tp val) {
+ mllnode<_Tp> * tmp = new mllnode<_Tp>();
+ tmp->prev = tail;
+ tmp->next = NULL;
+ tmp->val = val;
+ if (tail == NULL)
+ head = tmp;
+ else tail->next = tmp;
+ tail = tmp;
+ }
+
+ void insertAfter(mllnode<_Tp> * node, _Tp val) {
+ mllnode<_Tp> *tmp = new mllnode<_Tp>();
+ tmp->val = val;
+ tmp->prev = node;
+ tmp->next = node->next;
+ node->next = tmp;
+ if (tmp->next == NULL) {
+ tail = tmp;
+ } else {
+ tmp->next->prev = tmp;
+ }
+ }
+
+ void insertBefore(mllnode<_Tp> * node, _Tp val) {
+ mllnode<_Tp> *tmp = new mllnode<_Tp>();
+ tmp->val = val;
+ tmp->next = node;
+ tmp->prev = node->prev;
+ node->prev = tmp;
+ if (tmp->prev == NULL) {
+ head = tmp;
+ } else {
+ tmp->prev->next = tmp;
+ }
+ }
+
+ void erase(mllnode<_Tp> * node) {
+ if (head == node) {
+ head = node->next;
+ } else {
+ node->prev->next = node->next;
+ }
+
+ if (tail == node) {
+ tail = node->prev;
+ } else {
+ tail->next->prev = node->prev;
+ }
+
+ delete node;
+ }
+
+ mllnode<_Tp> begin() {
+ return head;
+ }
+
+ mllnode<_Tp> end() {
+ return tail;
+ }
+
+ _Tp front() {
+ return head->val;
+ }
+
+ _Tp back() {
+ return tail->val;
+ }
+
+
+ MEMALLOC;
+ private:
+ mllnode<_Tp> *head;
+ mllnode<_Tp> *tail;
+};
- SnapList(size_t n, const _Tp& val = _Tp()) :
- list(n, val)
- { }
+template<typename _Tp>
+class sllnode {
+ public:
+ _Tp getVal() {return val;}
+ sllnode<_Tp> * getNext() {return next;}
+ sllnode<_Tp> * getPrev() {return prev;}
+ SNAPSHOTALLOC;
+
+ private:
+ sllnode<_Tp> * next;
+ sllnode<_Tp> * prev;
+ _Tp val;
+ friend class SnapList;
+};
- SNAPSHOTALLOC
+template<typename _Tp>
+class SnapList
+{
+public:
+ SnapList() : head(NULL),
+ tail(NULL) {
+ }
+
+ void push_front(_Tp val) {
+ sllnode<_Tp> * tmp = new sllnode<_Tp>();
+ tmp->prev = NULL;
+ tmp->next = head;
+ tmp->val = val;
+ if (head == NULL)
+ tail = tmp;
+ else
+ head->prev = tmp;
+ head = tmp;
+ }
+
+ void push_back(_Tp val) {
+ sllnode<_Tp> * tmp = new sllnode<_Tp>();
+ tmp->prev = tail;
+ tmp->next = NULL;
+ tmp->val = val;
+ if (tail == NULL)
+ head = tmp;
+ else tail->next = tmp;
+ tail = tmp;
+ }
+
+ void insertAfter(sllnode<_Tp> * node, _Tp val) {
+ sllnode<_Tp> *tmp = new sllnode<_Tp>();
+ tmp->val = val;
+ tmp->prev = node;
+ tmp->next = node->next;
+ node->next = tmp;
+ if (tmp->next == NULL) {
+ tail = tmp;
+ } else {
+ tmp->next->prev = tmp;
+ }
+ }
+
+ void insertBefore(sllnode<_Tp> * node, _Tp val) {
+ sllnode<_Tp> *tmp = new sllnode<_Tp>();
+ tmp->val = val;
+ tmp->next = node;
+ tmp->prev = node->prev;
+ node->prev = tmp;
+ if (tmp->prev == NULL) {
+ head = tmp;
+ } else {
+ tmp->prev->next = tmp;
+ }
+ }
+
+ void erase(sllnode<_Tp> * node) {
+ if (head == node) {
+ head = node->next;
+ } else {
+ node->prev->next = node->next;
+ }
+
+ if (tail == node) {
+ tail = node->prev;
+ } else {
+ tail->next->prev = node->prev;
+ }
+
+ delete node;
+ }
+
+ sllnode<_Tp> begin() {
+ return head;
+ }
+
+ sllnode<_Tp> end() {
+ return tail;
+ }
+
+ _Tp front() {
+ return head->val;
+ }
+
+ _Tp back() {
+ return tail->val;
+ }
+
+
+ SNAPSHOTALLOC;
+ private:
+ sllnode<_Tp> *head;
+ sllnode<_Tp> *tail;
};
+
#define VECTOR_DEFCAP 8
typedef unsigned int uint;