File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
1414)
1515
1616const numCPU = 2
17+ const numSpinlocks = 32
1718
1819// machineTicks is provided by package machine.
1920func machineTicks () uint64
@@ -297,6 +298,14 @@ var (
297298 futexLock = spinLock {id : 23 }
298299)
299300
301+ func resetSpinLocks () {
302+ l := & spinLock {id : 0 }
303+ for i := uint8 (0 ); i < numSpinlocks ; i ++ {
304+ l .id = i
305+ l .spinlock ().Set (0 )
306+ }
307+ }
308+
300309// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
301310type spinLock struct {
302311 id uint8
@@ -360,6 +369,9 @@ func init() {
360369//export Reset_Handler
361370func main () {
362371 preinit ()
372+ // Reset spinlocks so the scheduler doesn't hang waiting for a lock after
373+ // a soft reset.
374+ resetSpinLocks ()
363375 run ()
364376 exit (0 )
365377}
You can’t perform that action at this time.
0 commit comments