@@ -2530,8 +2530,6 @@ gc_history_per_heap gc_heap::bgc_data_per_heap;
2530
2530
2531
2531
BOOL gc_heap::bgc_thread_running;
2532
2532
2533
- CLREvent gc_heap::background_gc_create_event;
2534
-
2535
2533
CLRCriticalSection gc_heap::bgc_threads_timeout_cs;
2536
2534
2537
2535
CLREvent gc_heap::gc_lh_block_event;
@@ -7136,7 +7134,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
7136
7134
dprintf (GC_TABLE_LOG, ("Table alloc for %Id bytes: [%Ix, %Ix[",
7137
7135
alloc_size, (size_t)mem, (size_t)((uint8_t*)mem+alloc_size)));
7138
7136
7139
- {
7137
+ {
7140
7138
// mark array will be committed separately (per segment).
7141
7139
size_t commit_size = alloc_size - ms;
7142
7140
@@ -24851,27 +24849,6 @@ void __stdcall gc_heap::gc_thread_stub (void* arg)
24851
24849
uint32_t __stdcall gc_heap::bgc_thread_stub (void* arg)
24852
24850
{
24853
24851
gc_heap* heap = (gc_heap*)arg;
24854
-
24855
- // TODO: need to check if we are still fine for these APIs:
24856
- // Thread::BeginThreadAffinity
24857
- // Thread::EndThreadAffinity()
24858
- // since now GC threads can be managed threads.
24859
- ClrFlsSetThreadType (ThreadType_GC);
24860
- assert (heap->bgc_thread != NULL);
24861
- GCToEEInterface::SetGCSpecial(heap->bgc_thread);
24862
- STRESS_LOG_RESERVE_MEM (GC_STRESSLOG_MULTIPLY);
24863
-
24864
- // We commit the thread's entire stack to ensure we're robust in low memory conditions.
24865
- /*
24866
- BOOL fSuccess = Thread::CommitThreadStack();
24867
-
24868
- if (!fSuccess)
24869
- {
24870
- // For background GC we revert to doing a blocking GC.
24871
- return 0;
24872
- }
24873
- */
24874
-
24875
24852
return heap->bgc_thread_function();
24876
24853
}
24877
24854
#ifdef _MSC_VER
@@ -26652,39 +26629,10 @@ BOOL gc_heap::create_bgc_thread(gc_heap* gh)
26652
26629
26653
26630
//dprintf (2, ("Creating BGC thread"));
26654
26631
26655
- if (GCToEEInterface::CreateBackgroundThread(&gh->bgc_thread, gh->bgc_thread_stub, gh))
26656
- {
26657
- dprintf (2, ("waiting for the thread to reach its main loop"));
26658
- // In chk builds this can easily time out since
26659
- // now we need to set the thread up into a managed thead.
26660
- // And since it's a managed thread we also need to make sure that we don't
26661
- // clean up here and are still executing code on that thread (it'll
26662
- // trigger all sorts of asserts.
26663
- //uint32_t res = gh->background_gc_create_event.Wait(20,FALSE);
26664
- uint32_t res = gh->background_gc_create_event.Wait(INFINITE,FALSE);
26665
- if (res == WAIT_TIMEOUT)
26666
- {
26667
- dprintf (2, ("waiting for the thread to reach its main loop Timeout."));
26668
- goto cleanup;
26669
- }
26670
- if (!gh->bgc_thread_running)
26671
- {
26672
- dprintf(2, ("background GC thread failed to start."));
26673
- goto cleanup;
26674
- }
26675
- //dprintf (2, ("waiting for the thread to reach its main loop Done."));
26632
+ gh->bgc_thread = GCToEEInterface::CreateBackgroundThread(gh->bgc_thread_stub, gh);
26633
+ gh->bgc_thread_running = (gh->bgc_thread != NULL);
26676
26634
26677
- return TRUE;
26678
- }
26679
-
26680
- cleanup:
26681
-
26682
- if (gh->bgc_thread)
26683
- {
26684
- gh->bgc_thread = 0;
26685
- }
26686
-
26687
- return FALSE;
26635
+ return gh->bgc_thread_running;
26688
26636
}
26689
26637
26690
26638
BOOL gc_heap::create_bgc_threads_support (int number_of_heaps)
@@ -26751,11 +26699,6 @@ BOOL gc_heap::create_bgc_thread_support()
26751
26699
goto cleanup;
26752
26700
}
26753
26701
26754
- if (!background_gc_create_event.CreateAutoEventNoThrow(FALSE))
26755
- {
26756
- goto cleanup;
26757
- }
26758
-
26759
26702
//needs to have room for enough smallest objects fitting on a page
26760
26703
parr = new (nothrow) (uint8_t* [1 + page_size / MIN_OBJECT_SIZE]);
26761
26704
if (!parr)
@@ -26775,10 +26718,6 @@ BOOL gc_heap::create_bgc_thread_support()
26775
26718
{
26776
26719
gc_lh_block_event.CloseEvent();
26777
26720
}
26778
- if (background_gc_create_event.IsValid())
26779
- {
26780
- background_gc_create_event.CloseEvent();
26781
- }
26782
26721
}
26783
26722
26784
26723
return ret;
@@ -26860,7 +26799,6 @@ void gc_heap::kill_gc_thread()
26860
26799
// In the first stage, we do minimum work, and call ExitProcess at the end.
26861
26800
// In the secodn stage, we have the Loader lock and only one thread is
26862
26801
// alive. Hence we do not need to kill gc thread.
26863
- DestroyThread (bgc_thread);
26864
26802
background_gc_done_event.CloseEvent();
26865
26803
gc_lh_block_event.CloseEvent();
26866
26804
bgc_start_event.CloseEvent();
@@ -26877,28 +26815,11 @@ uint32_t gc_heap::bgc_thread_function()
26877
26815
dprintf (3, ("gc_thread thread starting..."));
26878
26816
26879
26817
BOOL do_exit = FALSE;
26880
- Thread* thread_to_destroy = 0;
26881
26818
26882
- #ifndef FEATURE_REDHAWK
26883
- // see comments in create_bgc_thread - we need
26884
- // to make sure that thread doesn't clean up this thread
26885
- // while we run code here.
26886
- if (!bgc_thread->HasStarted(FALSE))
26887
- {
26888
- dprintf (2, ("HasStarted failed"));
26889
- bgc_thread_running = FALSE;
26890
- background_gc_create_event.Set();
26891
- return 0;
26892
- }
26893
- #endif //FEATURE_REDHAWK
26894
-
26895
- bgc_thread_running = TRUE;
26896
26819
Thread* current_thread = GetThread();
26897
26820
BOOL cooperative_mode = TRUE;
26898
26821
bgc_thread_id.SetToCurrentThread();
26899
26822
dprintf (1, ("bgc_thread_id is set to %x", (uint32_t)GCToOSInterface::GetCurrentThreadIdForLogging()));
26900
- //this also indicates that the thread is ready.
26901
- background_gc_create_event.Set();
26902
26823
while (1)
26903
26824
{
26904
26825
// Wait for work to do...
@@ -26938,10 +26859,6 @@ uint32_t gc_heap::bgc_thread_function()
26938
26859
{
26939
26860
dprintf (2, ("GC thread exiting"));
26940
26861
bgc_thread_running = FALSE;
26941
- // We can't call DestroyThread here 'cause EnterCriticalSection
26942
- // increases the thread's m_dwLockCount and DestroyThread will
26943
- // assert if the lock count is not 0.
26944
- thread_to_destroy = bgc_thread;
26945
26862
bgc_thread = 0;
26946
26863
bgc_thread_id.Clear();
26947
26864
do_exit = TRUE;
@@ -27045,11 +26962,6 @@ uint32_t gc_heap::bgc_thread_function()
27045
26962
//gc_heap::disable_preemptive (current_thread, TRUE);
27046
26963
}
27047
26964
27048
- if (thread_to_destroy)
27049
- {
27050
- DestroyThread(thread_to_destroy);
27051
- }
27052
-
27053
26965
FireEtwGCTerminateConcurrentThread_V1(GetClrInstanceId());
27054
26966
27055
26967
dprintf (3, ("bgc_thread thread exiting"));
0 commit comments