Skip to content

Commit ffa7ebb

Browse files
committed
tmp commit
1 parent 226f058 commit ffa7ebb

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

doc/concurrency_guide.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ You can't:
4545

4646
Internally, the VM lock is the `vm->ractor.sync.lock`.
4747

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+
4851
## Other Locks
4952

5053
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,
5358

5459
You can:
5560

@@ -58,7 +63,7 @@ ruby allocation through the use of macros!
5863

5964
* Use `ccan` lists, as they don't allocate.
6065

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.
6267

6368
You can't:
6469

@@ -97,3 +102,7 @@ know about and is sometimes the only solution.
97102

98103
## Lock Hierarchy
99104

105+
## Ruby Interrupt Handling
106+
107+
When the VM runs ruby code, ruby's threads intermittently check ruby-level interrupts. These software interrupts
108+
are for various things, like

0 commit comments

Comments
 (0)