summaryrefslogtreecommitdiff
path: root/src/gc/gcinterface.ee.h
diff options
context:
space:
mode:
authorSean Gillespie <segilles@microsoft.com>2017-11-09 09:58:47 -0800
committerGitHub <noreply@github.com>2017-11-09 09:58:47 -0800
commite64cbb5c722ab9b7d93ca32445e17df1115be70c (patch)
tree493ffcbff24c7d14c950187606a3635e51c05bec /src/gc/gcinterface.ee.h
parentb45e91e74ff4d721e3b44e260e673ef024ddb774 (diff)
downloadcoreclr-e64cbb5c722ab9b7d93ca32445e17df1115be70c.tar.gz
coreclr-e64cbb5c722ab9b7d93ca32445e17df1115be70c.tar.bz2
coreclr-e64cbb5c722ab9b7d93ca32445e17df1115be70c.zip
[Local GC] Unify background GC thread and server GC thread creation (#14821)
* Initial cut, ignoring thread affinity * Integrate thread affinity * Affinity for standalone Windows * Add 'specialness' and the thread name as arguments to CreateThread * First crack at unified implementation * Set priority for server GC threads * Remove unused parameter * Address code review feedback and remove some dead code that broke the clang build * Use char* on the interface instead of wchar_t (doesn't play well cross-platform) * Rename IsGCSpecialThread -> CurrentThreadWasCreatedByGC * Code review feedback and fix up the build * rename CurrentThreadWasCreatedByGC -> WasCurrentThreadCreatedByGC * Fix a contract violation when converting string encodings * Thread::CreateUtilityThread returns a thread that is not suspended - restarting a non-suspended thread is incorrect * CreateUnsuspendableThread -> CreateNonSuspendableThread
Diffstat (limited to 'src/gc/gcinterface.ee.h')
-rw-r--r--src/gc/gcinterface.ee.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/gc/gcinterface.ee.h b/src/gc/gcinterface.ee.h
index d65da60678..84578b6d8a 100644
--- a/src/gc/gcinterface.ee.h
+++ b/src/gc/gcinterface.ee.h
@@ -79,6 +79,9 @@ public:
// Gets the Thread instance for the current thread, or null if no thread
// instance is associated with this thread.
+ //
+ // If the GC created the current thread, GetThread returns null for threads
+ // that were not created as suspendable (see `IGCHeap::CreateThread`).
virtual
Thread* GetThread() = 0;
@@ -98,9 +101,21 @@ public:
virtual
void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param) = 0;
- // Creates and returns a new background thread.
- virtual
- Thread* CreateBackgroundThread(GCBackgroundThreadFunction threadStart, void* arg) = 0;
+ // Creates and returns a new thread.
+ // Parameters:
+ // threadStart - The function that will serve as the thread stub for the
+ // new thread. It will be invoked immediately upon the
+ // new thread upon creation.
+ // arg - The argument that will be passed verbatim to threadStart.
+ // is_suspendable - Whether or not the thread that is created should be suspendable
+ // from a runtime perspective. Threads that are suspendable have
+ // a VM Thread object associated with them that can be accessed
+ // using `IGCHeap::GetThread`.
+ // name - The name of this thread, optionally used for diagnostic purposes.
+ // Returns:
+ // true if the thread was started successfully, false if not.
+ virtual
+ bool CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name) = 0;
// When a GC starts, gives the diagnostics code a chance to run.
virtual
@@ -192,16 +207,18 @@ public:
virtual
void FreeStringConfigValue(const char* value) = 0;
- // Asks the EE about whether or not the current thread is a GC thread:
- // a server GC thread, background GC thread, or the thread that suspended
- // the EE at the start of a GC.
+ // Returns true if this thread is a "GC thread", or a thread capable of
+ // doing GC work. Threads are either /always/ GC threads
+ // (if they were created for this purpose - background GC threads
+ // and server GC threads) or they became GC threads by suspending the EE
+ // and initiating a collection.
virtual
bool IsGCThread() = 0;
- // Asks the EE about whether or not the current thread is a GC "special"
- // thread: a server GC thread or a background GC thread.
+ // Returns true if the current thread is either a background GC thread
+ // or a server GC thread.
virtual
- bool IsGCSpecialThread() = 0;
+ bool WasCurrentThreadCreatedByGC() = 0;
};
#endif // _GCINTERFACE_EE_H_