runtime: remove the asyncScheduler constant
There is no reason to specialize this per chip as it is only ever used for JavaScript. Not only that, it is causing confusion and is yet another quirk to learn when porting the runtime to a new microcontroller.
Этот коммит содержится в:
родитель
25b045d0a7
коммит
8cd2a462b9
25 изменённых файлов: 8 добавлений и 52 удалений
|
@ -71,8 +71,6 @@ func ticks() timeUnit {
|
|||
return 0
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func sleepTicks(d timeUnit) {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
@ -243,8 +243,6 @@ var rtcOverflows volatile.Register32 // number of times the RTC wrapped around
|
|||
|
||||
var timerWakeup volatile.Register8
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
// ticksToNanoseconds converts RTC ticks (at 32768Hz) to nanoseconds.
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
// The following calculation is actually the following, but with both sides
|
||||
|
|
|
@ -232,8 +232,6 @@ var rtcOverflows volatile.Register32 // number of times the RTC wrapped around
|
|||
|
||||
var timerWakeup volatile.Register8
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
// ticksToNanoseconds converts RTC ticks (at 32768Hz) to nanoseconds.
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
// The following calculation is actually the following, but with both sides
|
||||
|
|
|
@ -58,8 +58,6 @@ func init() {
|
|||
initUART()
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
const tickNanos = 1024 * 16384 // roughly 16ms in nanoseconds
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
|
|
|
@ -27,8 +27,6 @@ func main() {
|
|||
abort()
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
return int64(ticks)
|
||||
}
|
||||
|
|
|
@ -97,8 +97,6 @@ func ticks() timeUnit {
|
|||
return timeUnit(uint64(esp.TIMG0.T0LO.Get()) | uint64(esp.TIMG0.T0HI.Get())<<32)
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func nanosecondsToTicks(ns int64) timeUnit {
|
||||
// Calculate the number of ticks from the number of nanoseconds. At a 80MHz
|
||||
// APB clock, that's 25 nanoseconds per tick with a timer prescaler of 2:
|
||||
|
|
|
@ -89,8 +89,6 @@ func ticks() timeUnit {
|
|||
return currentTime
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
const tickNanos = 3200 // time.Second / (80MHz / 256)
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
|
|
|
@ -100,8 +100,6 @@ func putchar(c byte) {
|
|||
machine.UART0.WriteByte(c)
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
var timerWakeup volatile.Register8
|
||||
|
||||
func ticks() timeUnit {
|
||||
|
|
|
@ -112,8 +112,6 @@ func putchar(c byte) {
|
|||
machine.UART0.WriteByte(c)
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
var timerWakeup volatile.Register8
|
||||
|
||||
func ticks() timeUnit {
|
||||
|
|
|
@ -10,8 +10,6 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
//go:extern _svectors
|
||||
var _svectors [0]byte
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ import "unsafe"
|
|||
|
||||
type timeUnit int64
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
const (
|
||||
// Handles
|
||||
infoTypeTotalMemorySize = 6 // Total amount of memory available for process.
|
||||
|
|
|
@ -67,8 +67,6 @@ func putchar(c byte) {
|
|||
machine.UART0.WriteByte(c)
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func sleepTicks(d timeUnit) {
|
||||
for d != 0 {
|
||||
ticks := uint32(d) & 0x7fffff // 23 bits (to be on the safe side)
|
||||
|
|
|
@ -232,9 +232,6 @@ func putchar(c byte) {
|
|||
machine.PutcharUART(&machine.UART0, c)
|
||||
}
|
||||
|
||||
// ???
|
||||
const asyncScheduler = false
|
||||
|
||||
func abort() {
|
||||
println("!!! ABORT !!!")
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initCLK()
|
||||
|
||||
|
|
|
@ -80,8 +80,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initOSC() // configure oscillators
|
||||
initCLK()
|
||||
|
|
|
@ -42,8 +42,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initCLK()
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initCLK()
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ const (
|
|||
|
||||
type arrtype = uint16
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func putchar(c byte) {
|
||||
machine.UART0.WriteByte(c)
|
||||
}
|
||||
|
|
|
@ -66,8 +66,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initCLK()
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ const (
|
|||
|
||||
type arrtype = uint32
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func init() {
|
||||
initCLK()
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ func main() {
|
|||
abort()
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
return int64(ticks)
|
||||
}
|
||||
|
|
|
@ -123,8 +123,6 @@ func putchar(c byte) {
|
|||
_putchar(int(c))
|
||||
}
|
||||
|
||||
const asyncScheduler = false
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
// The OS API works in nanoseconds so no conversion necessary.
|
||||
return int64(ticks)
|
||||
|
|
|
@ -40,8 +40,6 @@ func go_scheduler() {
|
|||
scheduler()
|
||||
}
|
||||
|
||||
const asyncScheduler = true
|
||||
|
||||
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
// The JavaScript API works in float64 milliseconds, so convert to
|
||||
// nanoseconds first before converting to a timeUnit (which is a float64),
|
||||
|
|
|
@ -59,10 +59,7 @@ func nanosecondsToTicks(ns int64) timeUnit {
|
|||
return timeUnit(ns)
|
||||
}
|
||||
|
||||
const (
|
||||
asyncScheduler = false
|
||||
timePrecisionNanoseconds = 1000 // TODO: how can we determine the appropriate `precision`?
|
||||
)
|
||||
const timePrecisionNanoseconds = 1000 // TODO: how can we determine the appropriate `precision`?
|
||||
|
||||
var (
|
||||
sleepTicksSubscription = __wasi_subscription_t{
|
||||
|
|
|
@ -20,6 +20,10 @@ import (
|
|||
|
||||
const schedulerDebug = false
|
||||
|
||||
// On JavaScript, we can't do a blocking sleep. Instead we have to return and
|
||||
// queue a new scheduler invocation using setTimeout.
|
||||
const asyncScheduler = GOOS == "js"
|
||||
|
||||
var schedulerDone bool
|
||||
|
||||
// Queues used by the scheduler.
|
||||
|
@ -138,6 +142,7 @@ func scheduler() {
|
|||
if t == nil {
|
||||
if sleepQueue == nil {
|
||||
if asyncScheduler {
|
||||
// JavaScript is treated specially, see below.
|
||||
return
|
||||
}
|
||||
waitForEvents()
|
||||
|
@ -154,7 +159,8 @@ func scheduler() {
|
|||
if asyncScheduler {
|
||||
// The sleepTicks function above only sets a timeout at which
|
||||
// point the scheduler will be called again. It does not really
|
||||
// sleep.
|
||||
// sleep. So instead of sleeping, we return and expect to be
|
||||
// called again.
|
||||
break
|
||||
}
|
||||
continue
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче