Skip to content

Commit

Permalink
Defer to Immix marker at checkpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Dec 31, 2015
1 parent 899dca7 commit d265ed9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions vm/gc/immix_marker.cpp
Expand Up @@ -82,15 +82,18 @@ namespace rubinius {
timer::StopWatch<timer::milliseconds> timer(
state->vm()->metrics().gc.immix_concurrent_ms);

// TODO: Set status of this thread so STW won't consider it a
// possible deadlock when the thread doesn't yield soon enough.
state->shared().thread_nexus()->blocking(state->vm());

while(immix_->process_mark_stack(immix_->memory()->collect_mature_now)) {
if(state->shared().thread_nexus()->stop_p()) {
state->shared().thread_nexus()->yielding(state->vm());
}
state->shared().thread_nexus()->blocking(state->vm());
}
}

state->vm()->become_managed();

if(thread_exit_) break;

{
Expand Down
12 changes: 12 additions & 0 deletions vm/thread_nexus.cpp
Expand Up @@ -13,6 +13,10 @@
#include <time.h>

namespace rubinius {
bool ThreadNexus::blocking_p(VM* vm) {
return (vm->thread_phase() & cBlocking) == cBlocking;
}

bool ThreadNexus::yielding_p(VM* vm) {
return (vm->thread_phase() & cYielding) == cYielding;
}
Expand Down Expand Up @@ -97,6 +101,8 @@ namespace rubinius {
return "cWaiting";
case ThreadNexus::cYielding:
return "cYielding";
case ThreadNexus::cBlocking:
return "cBlocking";
}
}

Expand All @@ -117,6 +123,10 @@ namespace rubinius {
rubinius::abort();
}

void ThreadNexus::blocking(VM* vm) {
vm->set_thread_phase(cBlocking);
}

#define RBX_MAX_STOP_ITERATIONS 10000

bool ThreadNexus::locking(VM* vm) {
Expand All @@ -137,6 +147,8 @@ namespace rubinius {
if(yielding_p(other_vm)) {
yielding = true;
break;
} else if(blocking_p(other_vm)) {
return false;
}

static int delay[] = { 1, 21, 270, 482, 268, 169, 224, 481,
Expand Down
3 changes: 3 additions & 0 deletions vm/thread_nexus.hpp
Expand Up @@ -32,6 +32,7 @@ namespace rubinius {
enum Phase {
cStop = 0x01,
cManaged = 0x02,
cBlocking = 0x04,
cUnmanaged = 0x81,
cWaiting = 0x82,
cYielding = 0x80
Expand Down Expand Up @@ -70,6 +71,8 @@ namespace rubinius {
lock_.unlock();
}

bool blocking_p(VM* vm);
void blocking(VM* vm);
bool yielding_p(VM* vm);
void yielding(VM* vm);
bool locking(VM* vm);
Expand Down
2 changes: 1 addition & 1 deletion vm/util/immix.hpp
Expand Up @@ -1097,7 +1097,7 @@ namespace immix {
desc.walk_pointers(addr, mark);
}

return true;
return !exit;
}

/**
Expand Down

0 comments on commit d265ed9

Please sign in to comment.