Skip to content

Commit

Permalink
Don't wake up other GC threads when we decide to not proceed with the…
Browse files Browse the repository at this point in the history
… GC (dotnet/coreclr#14719)

Commit migrated from dotnet/coreclr@5b02b01
  • Loading branch information
Maoni0 authored Oct 28, 2017
1 parent e580383 commit 8b20afc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5401,16 +5401,20 @@ void gc_heap::gc_thread_function ()
proceed_with_gc_p = FALSE;
}
else
{
settings.init_mechanisms();
gc_start_event.Set();
}
dprintf (3, ("%d gc thread waiting...", heap_number));
gc_start_event.Set();
}
else
{
gc_start_event.Wait(INFINITE, FALSE);
dprintf (3, ("%d gc thread waiting... Done", heap_number));
}

assert ((heap_number == 0) || proceed_with_gc_p);

if (proceed_with_gc_p)
garbage_collect (GCHeap::GcCondemnedGeneration);

Expand Down Expand Up @@ -5447,7 +5451,18 @@ void gc_heap::gc_thread_function ()

gc_heap::internal_gc_done = true;

set_gc_done();
if (proceed_with_gc_p)
set_gc_done();
else
{
// If we didn't actually do a GC, it means we didn't wait up the other threads,
// we still need to set the gc_done_event for those threads.
for (int i = 0; i < gc_heap::n_heaps; i++)
{
gc_heap* hp = gc_heap::g_heaps[i];
hp->set_gc_done();
}
}
}
else
{
Expand Down

0 comments on commit 8b20afc

Please sign in to comment.