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.
This commit is contained in:
Ayke van Laethem
2021-05-08 20:05:34 +02:00
committed by Ron Evans
parent 25b045d0a7
commit 8cd2a462b9
25 changed files with 8 additions and 52 deletions
-2
View File
@@ -71,8 +71,6 @@ func ticks() timeUnit {
return 0
}
const asyncScheduler = false
func sleepTicks(d timeUnit) {
// TODO
}
-2
View File
@@ -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
-2
View File
@@ -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
-2
View File
@@ -58,8 +58,6 @@ func init() {
initUART()
}
const asyncScheduler = false
const tickNanos = 1024 * 16384 // roughly 16ms in nanoseconds
func ticksToNanoseconds(ticks timeUnit) int64 {
-2
View File
@@ -27,8 +27,6 @@ func main() {
abort()
}
const asyncScheduler = false
func ticksToNanoseconds(ticks timeUnit) int64 {
return int64(ticks)
}
-2
View File
@@ -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:
-2
View File
@@ -89,8 +89,6 @@ func ticks() timeUnit {
return currentTime
}
const asyncScheduler = false
const tickNanos = 3200 // time.Second / (80MHz / 256)
func ticksToNanoseconds(ticks timeUnit) int64 {
-2
View File
@@ -100,8 +100,6 @@ func putchar(c byte) {
machine.UART0.WriteByte(c)
}
const asyncScheduler = false
var timerWakeup volatile.Register8
func ticks() timeUnit {
-2
View File
@@ -112,8 +112,6 @@ func putchar(c byte) {
machine.UART0.WriteByte(c)
}
const asyncScheduler = false
var timerWakeup volatile.Register8
func ticks() timeUnit {
-2
View File
@@ -10,8 +10,6 @@ import (
"unsafe"
)
const asyncScheduler = false
//go:extern _svectors
var _svectors [0]byte
-2
View File
@@ -6,8 +6,6 @@ import "unsafe"
type timeUnit int64
const asyncScheduler = false
const (
// Handles
infoTypeTotalMemorySize = 6 // Total amount of memory available for process.
-2
View File
@@ -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)
-3
View File
@@ -232,9 +232,6 @@ func putchar(c byte) {
machine.PutcharUART(&machine.UART0, c)
}
// ???
const asyncScheduler = false
func abort() {
println("!!! ABORT !!!")
-2
View File
@@ -24,8 +24,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initCLK()
-2
View File
@@ -80,8 +80,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initOSC() // configure oscillators
initCLK()
-2
View File
@@ -42,8 +42,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initCLK()
-2
View File
@@ -41,8 +41,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initCLK()
-2
View File
@@ -13,8 +13,6 @@ const (
type arrtype = uint16
const asyncScheduler = false
func putchar(c byte) {
machine.UART0.WriteByte(c)
}
-2
View File
@@ -66,8 +66,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initCLK()
-2
View File
@@ -42,8 +42,6 @@ const (
type arrtype = uint32
const asyncScheduler = false
func init() {
initCLK()
-2
View File
@@ -24,8 +24,6 @@ func main() {
abort()
}
const asyncScheduler = false
func ticksToNanoseconds(ticks timeUnit) int64 {
return int64(ticks)
}
-2
View File
@@ -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)
-2
View File
@@ -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),
+1 -4
View File
@@ -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{
+7 -1
View File
@@ -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