Skip to content

Commit 3dce224

Browse files
mikesmittydeadprogram
authored andcommitted
fix(rp2): switch spinlock busy loop to wfe
1 parent 5d8afa2 commit 3dce224

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/runtime/runtime_rp2.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,13 @@ func (l *spinLock) Lock() {
311311
// Wait for the lock to be available.
312312
spinlock := l.spinlock()
313313
for spinlock.Get() == 0 {
314-
// TODO: use wfe and send an event when unlocking so the CPU can go to
315-
// sleep while waiting for the lock.
316-
// Unfortunately when doing that, time.Sleep() seems to hang somewhere.
317-
// This needs some debugging to figure out.
314+
arm.Asm("wfe")
318315
}
319316
}
320317

321318
func (l *spinLock) Unlock() {
322319
l.spinlock().Set(0)
320+
arm.Asm("sev")
323321
}
324322

325323
// Wait until a signal is received, indicating that it can resume from the

0 commit comments

Comments
 (0)