Prev Next

Word-Based STM

 void list_insert_wstm (list *l, int k)
 {
   node *n := new node(k);
   do {
      wstm transaction *tx := WSTMStartTransaction();
      node *prev := WSTMRead(tx, &(l->head));
      node *curr := WSTMRead(tx, &(prev->next));
      while ( curr->key < k ) {
         prev := curr;
         curr := WSTMRead(tx, &(curr->next));
      }
      n->next := curr;
      WSTMWrite(t, &(prev->next), n);
   } while ( !WSTMCommitTransaction(tx) );
 }
9