runtime: make channels work in interrupts

This commit is contained in:
Jaden Weiss
2020-05-29 23:46:58 -04:00
committed by Ron Evans
parent aa3481e06a
commit a4f3457747
13 changed files with 232 additions and 33 deletions
+25
View File
@@ -0,0 +1,25 @@
// +build !baremetal
package interrupt
// State represents the previous global interrupt state.
type State uintptr
// Disable disables all interrupts and returns the previous interrupt state. It
// can be used in a critical section like this:
//
// state := interrupt.Disable()
// // critical section
// interrupt.Restore(state)
//
// Critical sections can be nested. Make sure to call Restore in the same order
// as you called Disable (this happens naturally with the pattern above).
func Disable() (state State) {
return 0
}
// Restore restores interrupts to what they were before. Give the previous state
// returned by Disable as a parameter. If interrupts were disabled before
// calling Disable, this will not re-enable interrupts, allowing for nested
// cricital sections.
func Restore(state State) {}