Skip to content

Commit d2cc4c7

Browse files
committed
threads.h: Fix up grammar/spelling in vm/threads.h
1 parent 9a6aead commit d2cc4c7

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/coreclr/vm/threads.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
// in the GC heap, causing data corruption. This is a 'GC Hole', and is very bad. We have special modes (see
2323
// code:EEConfig.GetGCStressLevel) called GCStress to help find such issues.
2424
//
25-
// In order to find all GC references on the stacks we need insure that no thread is manipulating a GC
26-
// reference at the time of the scan. This is the job of code:Thread.SuspendRuntime. Logically it suspends
27-
// every thread in the process. Unfortunately it can not literally simply call the OS SuspendThread API on
28-
// all threads. The reason is that the other threads MIGHT hold important locks (for example there is a lock
29-
// that is taken when unmanaged heap memory is requested, or when a DLL is loaded). In general process
25+
// In order to find all GC references on the stacks, we need to ensure that no thread is manipulating a GC
26+
// reference at the time of the scan. This is the job of code:Thread.SuspendRuntime. Logically, it suspends
27+
// every thread in the process. Unfortunately, it can not literally simply call the OS SuspendThread API on
28+
// all threads. The reason is that the other threads MIGHT hold important locks (for example, there is a lock
29+
// that is taken when unmanaged heap memory is requested, or when a DLL is loaded). In general, process
3030
// global structures in the OS will be protected by locks, and if you suspend a thread it might hold that
31-
// lock. If you happen to need that OS service (eg you might need to allocated unmanaged memory), then
31+
// lock. If you happen to need that OS service (eg you might need to allocate unmanaged memory), then
3232
// deadlock will occur (as you wait on the suspended thread, that never wakes up).
3333
//
34-
// Luckily, we don't need to actually suspend the threads, we just need to insure that all GC references on
34+
// Luckily, we don't need to actually suspend the threads, we just need to ensure that all GC references on
3535
// the stack are stable. This is where the concept of cooperative mode and preemptive mode (a bad name) come
3636
// from.
3737
//
@@ -40,22 +40,22 @@
4040
// The runtime keeps a table of all threads that have ever run managed code in the code:ThreadStore table.
4141
// The ThreadStore table holds a list of Thread objects (see code:#ThreadClass). This object holds all
4242
// information about managed threads. Cooperative mode is defined as the mode the thread is in when the field
43-
// code:Thread.m_fPreemptiveGCDisabled is non-zero. When this field is zero the thread is said to be in
43+
// code:Thread.m_fPreemptiveGCDisabled is non-zero. When this field is zero, the thread is said to be in
4444
// Preemptive mode (named because if you preempt the thread in this mode, it is guaranteed to be in a place
4545
// where a GC can occur).
4646
//
4747
// When a thread is in cooperative mode, it is basically saying that it is potentially modifying GC
4848
// references, and so the runtime must Cooperate with it to get to a 'GC Safe' location where the GC
4949
// references can be enumerated. This is the mode that a thread is in MOST times when it is running managed
50-
// code (in fact if the EIP is in JIT compiled code, there is only one place where you are NOT in cooperative
50+
// code (in fact, if the EIP is in JIT compiled code, there is only one place where you are NOT in cooperative
5151
// mode (Inlined PINVOKE transition code)). Conversely, any time non-runtime unmanaged code is running, the
5252
// thread MUST NOT be in cooperative mode (you risk deadlock otherwise). Only code in mscorwks.dll might be
5353
// running in either cooperative or preemptive mode.
5454
//
5555
// It is easier to describe the invariant associated with being in Preemptive mode. When the thread is in
5656
// preemptive mode (when code:Thread.m_fPreemptiveGCDisabled is zero), the thread guarantees two things
5757
//
58-
// * That it not currently running code that manipulates GC references.
58+
// * That it is not currently running code that manipulates GC references.
5959
// * That it has set the code:Thread.m_pFrame pointer in the code:Thread to be a subclass of the class
6060
// code:Frame which marks the location on the stack where the last managed method frame is. This
6161
// allows the GC to start crawling the stack from there (essentially skip over the unmanaged frames).
@@ -70,8 +70,8 @@
7070
// the deadlock problem mentioned earlier, because threads that are running unmanaged code are allowed to
7171
// run. Enumeration of GC references starts at the first managed frame (pointed at by code:Thread.m_pFrame).
7272
//
73-
// When a thread is in cooperative mode, it means that GC references might be being manipulated. There are
74-
// two important possibilities
73+
// When a thread is in cooperative mode, it means that GC references might be in the process of being
74+
// manipulated. There are two important possibilities
7575
//
7676
// * The CPU is running JIT compiled code
7777
// * The CPU is running code elsewhere (which should only be in mscorwks.dll, because everywhere else a
@@ -87,23 +87,23 @@
8787
// what is called FullyInterruptible, then we have information for any possible instruction pointer in the
8888
// method and we can simply stop the thread (however we have to do this carefully TODO explain).
8989
//
90-
// However for most methods, we only keep GC information for paticular EIP's, in particular we keep track of
91-
// GC reference liveness only at call sites. Thus not every location is 'GC Safe' (that is we can enumerate
90+
// However for most methods, we only keep GC information for particular EIPs, in particular we keep track of
91+
// GC reference liveness only at call sites. Thus, not every location is 'GC Safe' (that is, we can enumerate
9292
// all references, but must be 'driven' to a GC safe location).
9393
//
9494
// We drive threads to GC safe locations by hijacking. This is a term for updating the return address on the
9595
// stack so that we gain control when a method returns. If we find that we are in JITTed code but NOT at a GC
96-
// safe location, then we find the return address for the method and modfiy it to cause the runtime to stop.
96+
// safe location, then we find the return address for the method and modify it to cause the runtime to stop.
9797
// We then let the method run. Hopefully the method quickly returns, and hits our hijack, and we are now at a
98-
// GC-safe location (all call sites are GC-safe). If not we repeat the procedure (possibly moving the
99-
// hijack). At some point a method returns, and we get control. For methods that have loops that don't make
100-
// calls, we are forced to make the method FullyInterruptible, so we can be sure to stop the mehod.
98+
// GC-safe location (all call sites are GC-safe). If not, we repeat the procedure (possibly moving the
99+
// hijack). At some point, a method returns, and we get control. For methods that have loops that don't make
100+
// calls, we are forced to make the method FullyInterruptible, so we can be sure to stop the method.
101101
//
102102
// This leaves only the case where we are in cooperative modes, but not in JIT compiled code (we should be in
103-
// clr.dll). In this case we simply let the thread run. The idea is that code in clr.dll makes the
103+
// clr.dll). In this case, we simply let the thread run. The idea is that code in clr.dll makes the
104104
// promise that it will not do ANYTHING that will block (which includes taking a lock), while in cooperative
105-
// mode, or do anything that might take a long time without polling to see if a GC is needed. Thus this code
106-
// 'cooperates' to insure that GCs can happen in a timely fashion.
105+
// mode, or do anything that might take a long time without polling to see if a GC is needed. Thus, this code
106+
// 'cooperates' to ensure that GCs can happen in a timely fashion.
107107
//
108108
// If you need to switch the GC mode of the current thread, look for the GCX_COOP() and GCX_PREEMP() macros.
109109
//

0 commit comments

Comments
 (0)