[pypy-commit] stmgc rewind_setjmp: Adapt demo_random. Fails obscurely for now
arigo
noreply at buildbot.pypy.org
Sat Aug 9 17:40:16 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: rewind_setjmp
Changeset: r1282:3378f3c9e327
Date: 2014-08-09 17:40 +0200
http://bitbucket.org/pypy/stmgc/changeset/3378f3c9e327/
Log: Adapt demo_random. Fails obscurely for now
diff --git a/c7/demo/demo_random.c b/c7/demo/demo_random.c
--- a/c7/demo/demo_random.c
+++ b/c7/demo/demo_random.c
@@ -81,6 +81,15 @@
void stmcb_commit_soon() {}
+void stmcb_trace_cards(struct object_s *obj, void cb(object_t **),
+ uintptr_t start, uintptr_t stop) {
+ abort();
+}
+void stmcb_get_card_base_itemsize(struct object_s *obj,
+ uintptr_t offset_itemsize[2]) {
+ abort();
+}
+
int get_rand(int max)
{
if (max == 0)
@@ -323,15 +332,15 @@
void *demo_random(void *arg)
{
int status;
+ rewind_jmp_buf rjbuf;
stm_register_thread_local(&stm_thread_local);
+ stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
setup_thread();
objptr_t p;
- stm_jmpbuf_t here;
- volatile int call_fork = (arg != NULL);
- STM_START_TRANSACTION(&stm_thread_local, here);
+ stm_start_transaction(&stm_thread_local);
assert(td.num_roots >= td.num_roots_at_transaction_start);
td.num_roots = td.num_roots_at_transaction_start;
p = NULL;
@@ -349,11 +358,12 @@
if (p == (objptr_t)-1) {
push_roots();
+ long call_fork = (arg != NULL && *(long *)arg);
if (call_fork == 0) { /* common case */
stm_commit_transaction();
td.num_roots_at_transaction_start = td.num_roots;
if (get_rand(100) < 98) {
- STM_START_TRANSACTION(&stm_thread_local, here);
+ stm_start_transaction(&stm_thread_local);
} else {
stm_start_inevitable_transaction(&stm_thread_local);
}
@@ -365,7 +375,7 @@
else {
/* run a fork() inside the transaction */
printf("========== FORK =========\n");
- call_fork = 0;
+ *(long*)arg = 0;
pid_t child = fork();
printf("=== in process %d thread %lx, fork() returned %d\n",
(int)getpid(), (long)pthread_self(), (int)child);
@@ -385,6 +395,7 @@
}
stm_commit_transaction();
+ stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
stm_unregister_thread_local(&stm_thread_local);
status = sem_post(&done); assert(status == 0);
@@ -433,6 +444,7 @@
int main(void)
{
int i, status;
+ rewind_jmp_buf rjbuf;
/* pick a random seed from the time in seconds.
A bit pointless for now... because the interleaving of the
@@ -446,6 +458,7 @@
stm_setup();
stm_register_thread_local(&stm_thread_local);
+ stm_rewind_jmp_enterframe(&stm_thread_local, &rjbuf);
setup_globals();
@@ -463,7 +476,7 @@
long forkbase = NUMTHREADS * THREAD_STARTS / (FORKS + 1);
long _fork = (thread_starts % forkbase) == 0;
thread_starts--;
- newthread(demo_random, (void *)_fork);
+ newthread(demo_random, &_fork);
}
}
@@ -483,6 +496,7 @@
printf("Test OK!\n");
+ stm_rewind_jmp_leaveframe(&stm_thread_local, &rjbuf);
stm_unregister_thread_local(&stm_thread_local);
stm_teardown();
More information about the pypy-commit
mailing list