@@ -191,10 +191,11 @@ thread safe classes offered here do not yet support Unix.
191
191
192
192
Globals are implemented as a ` dict ` . Adding or deleting an entry is unsafe in
193
193
the main program if there is a context which accesses global data and does not
194
- use the GIL. This means hard ISR's and code running on another core. Given that
195
- shared global data is widely used, the following guidelines should be followed.
196
- ([ This pr] ( https://github.com/micropython/micropython/pull/11604 ) aims to fix
197
- this issue).
194
+ use the GIL. This means hard ISR's and code running on another core. The
195
+ following guidelines should be followed.
196
+
197
+ Note that [ PR 11604] ( https://github.com/micropython/micropython/pull/11604 )
198
+ aims to fix this issue. Once merged, the use of globals will be threadsafe.
198
199
199
200
All globals should be declared in the main program before an ISR starts to run,
200
201
and before code on another core is started. It is valid to insert placeholder
@@ -215,10 +216,10 @@ def foo():
215
216
global bar
216
217
bar = 42
217
218
```
218
- Once again the hazard is avoided by, in global scope, populating ` bar ` prior
219
- with a placeholder before allowing other contexts to run.
219
+ The hazard is avoided by instantiating ` bar ` in global scope (populated with a
220
+ placeholder) before allowing other contexts to run.
220
221
221
- If globals must be created and destroyed dynamically, a lock must be used.
222
+ If globals must be created or destroyed dynamically, a lock must be used.
222
223
223
224
## 1.6 Debugging
224
225
0 commit comments