Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1120:47c979dca6e6
Date: 2014-03-30 19:31 +0200
http://bitbucket.org/pypy/stmgc/changeset/47c979dca6e6/
Log: Adapt demo2.c to display the timers at the end
diff --git a/c7/demo/demo2.c b/c7/demo/demo2.c
--- a/c7/demo/demo2.c
+++ b/c7/demo/demo2.c
@@ -184,6 +184,18 @@
static sem_t done;
+void unregister_thread_local(void)
+{
+ int i;
+ stm_flush_timing(&stm_thread_local);
+ for (i = 0; i < _STM_TIME_N; i++) {
+ fprintf(stderr, "timer %2d: %.6f\n", i,
+ (double)stm_thread_local.timing[i]);
+ }
+
+ stm_unregister_thread_local(&stm_thread_local);
+}
+
void *demo2(void *arg)
{
int status;
@@ -198,7 +210,7 @@
STM_POP_ROOT(stm_thread_local, global_chained_list);
assert(stm_thread_local.shadowstack == stm_thread_local.shadowstack_base);
- stm_unregister_thread_local(&stm_thread_local);
+ unregister_thread_local();
status = sem_post(&done); assert(status == 0);
return NULL;
}
@@ -255,7 +267,7 @@
final_check();
- stm_unregister_thread_local(&stm_thread_local);
+ unregister_thread_local();
stm_teardown();
return 0;
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -459,6 +459,9 @@
minor_collection(/*commit=*/ true);
+ /* the call to minor_collection() above leaves us with
+ STM_TIME_BOOKKEEPING */
+
s_mutex_lock();
restart:
diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -134,7 +134,7 @@
if (is_major_collection_requested()) { /* if still true */
- enum stm_time_e oldstate = change_timing_state(STM_TIME_MAJOR_GC);
+ int oldstate = change_timing_state(STM_TIME_MAJOR_GC);
synchronize_all_threads(STOP_OTHERS_UNTIL_MUTEX_UNLOCK);
diff --git a/c7/stm/sync.c b/c7/stm/sync.c
--- a/c7/stm/sync.c
+++ b/c7/stm/sync.c
@@ -182,6 +182,7 @@
}
/* No segment available. Wait until release_thread_segment()
signals that one segment has been freed. */
+ change_timing_state_tl(tl, STM_TIME_WAIT_FREE_SEGMENT);
cond_wait(C_SEGMENT_FREE);
/* Return false to the caller, which will call us again */
@@ -309,6 +310,10 @@
static void enter_safe_point_if_requested(void)
{
+ if (STM_SEGMENT->nursery_end == NURSERY_END)
+ return; /* fast path: no safe point requested */
+
+ int previous_state = -1;
assert(_seems_to_be_running_transaction());
assert(_has_mutex());
while (1) {
@@ -325,11 +330,18 @@
#ifdef STM_TESTS
abort_with_mutex();
#endif
+ if (previous_state == -1) {
+ previous_state = change_timing_state(STM_TIME_SYNC_PAUSE);
+ }
cond_signal(C_AT_SAFE_POINT);
STM_PSEGMENT->safe_point = SP_WAIT_FOR_C_REQUEST_REMOVED;
cond_wait(C_REQUEST_REMOVED);
STM_PSEGMENT->safe_point = SP_RUNNING;
}
+
+ if (previous_state != -1) {
+ change_timing_state(previous_state);
+ }
}
static void synchronize_all_threads(enum sync_type_e sync_type)
diff --git a/c7/stm/timing.c b/c7/stm/timing.c
--- a/c7/stm/timing.c
+++ b/c7/stm/timing.c
@@ -40,5 +40,5 @@
void stm_flush_timing(stm_thread_local_t *tl)
{
- change_timing_state_tl(tl, tl->_timing_cur_state);
+ TIMING_CHANGE(tl, tl->_timing_cur_state);
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit