You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/concurrency_guide.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,11 +45,16 @@ You can't:
45
45
46
46
Internally, the VM lock is the `vm->ractor.sync.lock`.
47
47
48
+
You need to be on a ruby thread to take the VM lock. You also can't take it inside any functions that could be called during sweeping, as MMTK sweeps
49
+
on another thread and you need a valid `ec` to grab the lock. For this same reason (among others), you can't take it from the timer thread either.
50
+
48
51
## Other Locks
49
52
50
53
All native locks that aren't the VM lock share a more strict set of rules for what's allowed during the critical section. By native locks, we mean
51
-
anything that uses `rb_native_mutex_lock`. Some important locks include the `interrupt_lock`, the ractor scheduling lock (global), the thread
52
-
scheduling lock (local to each ractor) and the ractor lock (local to each ractor).
54
+
anything that uses `rb_native_mutex_lock`. Some important locks include the `interrupt_lock`, the ractor scheduling lock (global, protects global scheduling data structures),
55
+
the thread scheduling lock (local to each ractor, protects per-ractor scheduling data structures) and the ractor lock (local to each ractor, protects ractor data structures).
56
+
57
+
When you acquire one of these locks,
53
58
54
59
You can:
55
60
@@ -58,7 +63,7 @@ ruby allocation through the use of macros!
58
63
59
64
* Use `ccan` lists, as they don't allocate.
60
65
61
-
* Do the usual things like set variables or struct fields, manipulate linked lists, etc.
66
+
* Do the usual things like set variables or struct fields, manipulate linked lists, signal condition variables etc.
62
67
63
68
You can't:
64
69
@@ -97,3 +102,7 @@ know about and is sometimes the only solution.
97
102
98
103
## Lock Hierarchy
99
104
105
+
## Ruby Interrupt Handling
106
+
107
+
When the VM runs ruby code, ruby's threads intermittently check ruby-level interrupts. These software interrupts
0 commit comments