File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
)
15
15
16
16
const numCPU = 2
17
+ const numSpinlocks = 32
17
18
18
19
// machineTicks is provided by package machine.
19
20
func machineTicks () uint64
@@ -297,6 +298,13 @@ var (
297
298
futexLock = spinLock {id : 23 }
298
299
)
299
300
301
+ func resetSpinLocks () {
302
+ for i := uint8 (0 ); i < numSpinlocks ; i ++ {
303
+ l := & spinLock {id : i }
304
+ l .spinlock ().Set (0 )
305
+ }
306
+ }
307
+
300
308
// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
301
309
type spinLock struct {
302
310
id uint8
@@ -357,9 +365,16 @@ func init() {
357
365
machine .InitSerial ()
358
366
}
359
367
368
+ func prerun () {
369
+ // Reset spinlocks before the full machineInit() so the scheduler doesn't
370
+ // hang waiting for schedulerLock after a soft reset.
371
+ resetSpinLocks ()
372
+ }
373
+
360
374
//export Reset_Handler
361
375
func main () {
362
376
preinit ()
377
+ prerun ()
363
378
run ()
364
379
exit (0 )
365
380
}
You can’t perform that action at this time.
0 commit comments