File tree Expand file tree Collapse file tree 7 files changed +27
-0
lines changed Expand file tree Collapse file tree 7 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ extern "C" uint32_t g_num_processors;
138
138
139
139
extern VOLATILE (int32_t ) g_fSuspensionPending;
140
140
141
+ extern uint32_t g_yieldProcessorScalingFactor;
142
+
141
143
::IGCHandleManager* CreateGCHandleManager ();
142
144
143
145
namespace WKS {
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ uint32_t* g_gc_card_table;
37
37
38
38
VOLATILE (int32_t ) g_fSuspensionPending = 0;
39
39
40
+ uint32_t g_yieldProcessorScalingFactor = 1 ;
41
+
40
42
#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
41
43
uint32_t * g_gc_card_bundle_table;
42
44
#endif
Original file line number Diff line number Diff line change @@ -615,6 +615,11 @@ void GCHeap::SetSuspensionPending(bool fSuspensionPending)
615
615
}
616
616
}
617
617
618
+ void GCHeap::SetYieldProcessorScalingFactor (uint32_t yieldProcessorScalingFactor)
619
+ {
620
+ g_yieldProcessorScalingFactor = yieldProcessorScalingFactor;
621
+ }
622
+
618
623
void GCHeap::ControlEvents (GCEventKeyword keyword, GCEventLevel level)
619
624
{
620
625
GCEventStatus::Set (GCEventProvider_Default, keyword, level);
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ class GCHeap : public IGCHeapInternal
92
92
bool RuntimeStructuresValid ();
93
93
94
94
void SetSuspensionPending (bool fSuspensionPending );
95
+
96
+ void SetYieldProcessorScalingFactor (uint32_t yieldProcessorScalingFactor);
95
97
96
98
void SetWaitForGCEvent ();
97
99
void ResetWaitForGCEvent ();
Original file line number Diff line number Diff line change @@ -735,6 +735,9 @@ class IGCHeap {
735
735
// Tells the GC when the VM is suspending threads.
736
736
virtual void SetSuspensionPending (bool fSuspensionPending ) = 0;
737
737
738
+ // Tells the GC how many YieldProcessor calls are equal to one scaled yield processor call.
739
+ virtual void SetYieldProcessorScalingFactor (uint32_t yieldProcessorScalingFactor) = 0;
740
+
738
741
/*
739
742
============================================================================
740
743
Add/RemoveMemoryPressure support routines. These are on the interface
Original file line number Diff line number Diff line change @@ -4346,3 +4346,13 @@ size_t gcard_of (uint8_t* object)
4346
4346
return (size_t )(object) / card_size;
4347
4347
}
4348
4348
4349
+ inline
4350
+ void YieldProcessorScalingFactor ()
4351
+ {
4352
+ unsigned int n = g_yieldProcessorScalingFactor;
4353
+ _ASSERTE (n != 0 );
4354
+ do
4355
+ {
4356
+ YieldProcessor ();
4357
+ } while (--n != 0 );
4358
+ }
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ static void InitializeYieldProcessorNormalized()
92
92
g_yieldsPerNormalizedYield = yieldsPerNormalizedYield;
93
93
g_optimalMaxNormalizedYieldsPerSpinIteration = optimalMaxNormalizedYieldsPerSpinIteration;
94
94
s_isYieldProcessorNormalizedInitialized = true ;
95
+
96
+
97
+ GCHeapUtilities::GetGCHeap ()->SetYieldProcessorScalingFactor (yieldsPerNormalizedYield);
95
98
}
96
99
97
100
void EnsureYieldProcessorNormalizedInitialized ()
You can’t perform that action at this time.
0 commit comments