[pypy-commit] stmgc c7: add a teardown_pthread function to free the shadow stack
Remi Meier
noreply at buildbot.pypy.org
Fri Jan 31 14:18:42 CET 2014
Author: Remi Meier
Branch: c7
Changeset: r696:2a59456815d8
Date: 2014-01-31 13:41 +0100
http://bitbucket.org/pypy/stmgc/changeset/2a59456815d8/
Log: add a teardown_pthread function to free the shadow stack
diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -282,9 +282,6 @@
assert(stm_list_is_empty(_STM_TL->uncommitted_objects));
stm_list_free(_STM_TL->uncommitted_objects);
- assert(_STM_TL->shadow_stack == _STM_TL->shadow_stack_base);
- free(_STM_TL->shadow_stack);
-
assert(_STM_TL->old_objects_to_trace->count == 0);
stm_list_free(_STM_TL->old_objects_to_trace);
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -213,6 +213,7 @@
void _stm_restore_local_state(int thread_num);
void stm_teardown(void);
+void stm_teardown_pthread(void);
bool _stm_is_in_transaction(void);
void _stm_assert_clean_tl(void);
diff --git a/c7/stmsync.c b/c7/stmsync.c
--- a/c7/stmsync.c
+++ b/c7/stmsync.c
@@ -153,6 +153,14 @@
}
+void stm_teardown_pthread(void)
+{
+ free(pthread_tl->shadow_stack_base);
+
+ free(pthread_tl);
+ pthread_tl = NULL;
+}
+
diff --git a/duhton/demo/container_transaction.duh b/duhton/demo/container_transaction.duh
--- a/duhton/demo/container_transaction.duh
+++ b/duhton/demo/container_transaction.duh
@@ -3,11 +3,11 @@
(defun g (thread n)
(set c (+ (get c) 1))
- (if (> (get c) 200000)
+ (if (> (get c) 20000)
(print (quote overflow) (get c))
- (if (< n 100000)
+ (if (< n 10000)
(transaction f thread (+ n 1))
- (if (< (get c) 200000)
+ (if (< (get c) 20000)
(print (quote not-enough))
(print (quote ok))))))
@@ -17,3 +17,4 @@
(transaction f (quote t1) 1)
(transaction f (quote t2) 1)
+(transaction f (quote t3) 1)
diff --git a/duhton/demo/run_transactions.duh b/duhton/demo/run_transactions.duh
--- a/duhton/demo/run_transactions.duh
+++ b/duhton/demo/run_transactions.duh
@@ -15,9 +15,9 @@
(transaction f (quote t1) 10000)
(transaction f (quote t2) 20000)
-(transaction f (quote t2) 10002)
+(transaction f (quote t3) 10002)
(run-transactions)
-(transaction f (quote t2) 15)
+(transaction f (quote t1) 15)
(transaction f (quote t2) 15)
(run-transactions)
(print (quote result) (get c))
diff --git a/duhton/duhton.h b/duhton/duhton.h
--- a/duhton/duhton.h
+++ b/duhton/duhton.h
@@ -10,7 +10,7 @@
#define STM 1 /* hackish removal of all read/write
barriers. synchronization is up to
the program */
-#define DEFAULT_NUM_THREADS 2 /* required by stm-c7 */
+#define DEFAULT_NUM_THREADS 2
struct DuObject_s {
diff --git a/duhton/glob.c b/duhton/glob.c
--- a/duhton/glob.c
+++ b/duhton/glob.c
@@ -770,8 +770,6 @@
void Du_Initialize(int num_threads)
{
- assert(num_threads == 2);
-
stm_setup();
stm_setup_pthread();
@@ -834,5 +832,6 @@
void Du_Finalize(void)
{
+ stm_teardown_pthread();
stm_teardown();
}
diff --git a/duhton/transaction.c b/duhton/transaction.c
--- a/duhton/transaction.c
+++ b/duhton/transaction.c
@@ -198,5 +198,7 @@
}
+ stm_teardown_pthread();
+
return NULL;
}
More information about the pypy-commit
mailing list