[pypy-commit] pypy stm-gc-2: Trying to apply a read-write lock to the issue of waiting for a global

arigo noreply at buildbot.pypy.org
Sun Apr 7 16:57:08 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc-2
Changeset: r63115:339cc84ccd49
Date: 2013-04-07 16:52 +0200
http://bitbucket.org/pypy/pypy/changeset/339cc84ccd49/

Log:	Trying to apply a read-write lock to the issue of waiting for a
	global pause to do a major GC. Tests coming.

diff --git a/rpython/translator/stm/src_stm/et.c b/rpython/translator/stm/src_stm/et.c
--- a/rpython/translator/stm/src_stm/et.c
+++ b/rpython/translator/stm/src_stm/et.c
@@ -67,6 +67,9 @@
 static volatile revision_t next_locked_value = LOCKED + 3;   /* always odd */
 static __thread struct tx_descriptor *thread_descriptor = NULL;
 
+static pthread_rwlock_t rwlock_in_transaction =
+         PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
+
 /************************************************************/
 
 static void ValidateNow(struct tx_descriptor *);
@@ -466,6 +469,7 @@
   SpinLoop(0);
   // jump back to the setjmp_buf (this call does not return)
   d->active = 0;
+  pthread_rwlock_unlock(&rwlock_in_transaction);
   longjmp(*d->setjmp_buf, 1);
 }
 
@@ -480,10 +484,11 @@
 
 static void init_transaction(struct tx_descriptor *d)
 {
+  assert(d->active == 0);
+  pthread_rwlock_rdlock(&rwlock_in_transaction);
   if (clock_gettime(CLOCK_MONOTONIC, &d->start_real_time) < 0) {
     d->start_real_time.tv_nsec = -1;
   }
-  assert(d->active == 0);
   assert(d->list_of_read_objects.size == 0);
   assert(d->gcroots.size == 0);
   assert(!g2l_any_entry(&d->global_to_local));
@@ -677,6 +682,7 @@
   gcptrlist_clear(&d->gcroots);
   d->num_commits++;
   d->active = 0;
+  pthread_rwlock_unlock(&rwlock_in_transaction);
 }
 
 /************************************************************/


More information about the pypy-commit mailing list