Author: Remi Meier <remi.me...@inf.ethz.ch>
Branch: 
Changeset: r1346:0fa234f3b87a
Date: 2014-09-04 11:14 +0200
http://bitbucket.org/pypy/stmgc/changeset/0fa234f3b87a/

Log:    attempt which ended in more questions

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -60,6 +60,14 @@
     }
 }
 
+static void _update_obj_from(int from_seg, object_t *obj)
+{
+    /* check if its pages are private, only then we need
+       to update them. If they are also still read-protected,
+       we may trigger the signal handler. This would cause
+       it to also enter stm_validate()..... */
+}
+
 void stm_validate(void *free_if_abort)
 {
     struct stm_commit_log_entry_s *cl = STM_PSEGMENT->last_commit_log_entry;
@@ -71,7 +79,12 @@
 
         object_t *obj;
         while ((obj = cl->written[i])) {
-            /* XXX: update our copies */
+            /* in case this entry's transaction has not yet discarded
+               the backup copies, wait. */
+            while (cl->committing)
+                spin_loop();
+
+            _update_obj_from(cl->segment_num, obj);
 
             if (_stm_was_read(obj)) {
                 free(free_if_abort);
@@ -100,11 +113,12 @@
         result->written[i] = (object_t*)list_item(lst, i);
     }
     result->written[count] = NULL;
+    spinlock_acquire(result->committing); /* =true */
 
     return result;
 }
 
-static void _validate_and_add_to_commit_log()
+static struct stm_commit_log_entry_s *_validate_and_add_to_commit_log()
 {
     struct stm_commit_log_entry_s *new;
     void* *to;
@@ -116,6 +130,8 @@
 
         to = (void **)&(STM_PSEGMENT->last_commit_log_entry->next);
     } while (!__sync_bool_compare_and_swap((void**)to, (void**)NULL, 
(void**)new));
+
+    return new;
 }
 
 /* ############# STM ############# */
@@ -242,9 +258,9 @@
 
     minor_collection(1);
 
-    _validate_and_add_to_commit_log();
-
+    struct stm_commit_log_entry_s* entry = _validate_and_add_to_commit_log();
     /* XXX:discard backup copies */
+    spinlock_release(entry->committing);
 
     s_mutex_lock();
 
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -65,6 +65,7 @@
 /* Commit Log things */
 struct stm_commit_log_entry_s {
     struct stm_commit_log_entry_s *next;
+    bool committing;            /* true while not yet removed backup copies */
     int segment_num;
     object_t *written[];        /* terminated with a NULL ptr */
 };
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to