goya
14 years agoVisitor
the following code reboots my roku 2 xs
the following code reboots my roku 2 xs
the first 2 benchs if runned by themselves are not a problem.
it appears the code crashes if after integerArithmeticMix runs... My debug console closes and I do not see any messages. All that happens is the roku freezes then reboots on its on...
so why is messing up the vm, looks live vm bug... since the code runs by itself... it just leaves the vm unstable...
or its actually running... Maybe it's eval() that is causing the problem...
Are there any log files I can look at after a reboot to see why it reboots. Too bad I don't have access to linux/c level I could debug this one. And if I had source code to BrightScript I could fix it... π
here is the full source code listing that crashes (reboots) the box...
the first 2 benchs if runned by themselves are not a problem.
it appears the code crashes if after integerArithmeticMix runs... My debug console closes and I do not see any messages. All that happens is the roku freezes then reboots on its on...
so why is messing up the vm, looks live vm bug... since the code runs by itself... it just leaves the vm unstable...
or its actually running... Maybe it's eval() that is causing the problem...
Are there any log files I can look at after a reboot to see why it reboots. Too bad I don't have access to linux/c level I could debug this one. And if I had source code to BrightScript I could fix it... π
here is the full source code listing that crashes (reboots) the box...
sub bench(n)
end sub
sub sieve(n)
flags = CreateObject("roArray", 8192 + 1, true)
count = 0
while n > 0
n = n - 1
count = 0
for i = 2 to 8192
flags[i] = true
end for
for i = 2 to 8192
if (flags[i])
' remove all multiples of prime: i
for k = i + i to 8192 step i
flags[k] = false
end for
count = count + 1
end if
end for
end while
end sub
sub integerArithmeticMix(n%)
r% = 1%
for i% = 1% to n%
r% = r% - i%
r% = r% + i%
r% = r% * i%
r% = r% / i%
r% = r% ^ i%
end for
end sub
sub floatArithmeticMix(n!)
r! = 1.0!
for i! = 1.0! to n!
r! = r! - i!
r! = r! + i!
r! = r! * i!
r! = r! / i!
r! = r! ^ i!
end for
end sub
sub doubleArithmeticMix(n#)
r# = 1.0#
for i# = 1.0# to n#
r# = r# - i#
r# = r# + i#
r# = r# * i#
r# = r# / i#
r# = r# ^ i#
end for
end sub
sub RunBenchmarks()
benchmarks = [["bench",1],["sieve",10],["integerArithmeticMix",10],["floatArithmeticMix",10],["doubleArithmeticMix",10]]
screen = CreateObject("roParagraphScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetTitle("Benchmark Suite")
screen.AddButton(1, "Close")
screen.Show()
dialog = CreateObject("roOneLineDialog")
dialog.SetTitle("Running benchmarks ...")
dialog.ShowBusyAnimation()
dialog.Show()
for each benchmark in benchmarks
dialog.SetTitle("Running benchmark " + benchmark[0] + "(" + Stri(benchmark[1]) + ") ...")
st = UpTime(0)
Eval(benchmark[0] + "(" + Stri(benchmark[1]) + ")")
et = UpTime(0)
screen.AddHeaderText(benchmark[0] + "(" + Stri(benchmark[1]) + "): " + Str(et-st))
end for
dialog.Close()
closed = false
' event loop
while true
msg = wait(0, port) ' wait for an event
if type(msg) = "roParagraphScreenEvent"
if msg.isButtonPressed()
buttonIndex = msg.GetIndex()
if buttonIndex = 1
exit while
end if
else if msg.isScreenClosed()
exit while
end if
end if
end while
screen.Close()
end sub
sub DisplayMainScreen()
screen = CreateObject("roParagraphScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetTitle("Benchmark Suite")
screen.AddButton(1, "Start")
screen.AddButton(2, "Close")
screen.Show()
' event loop
while true
msg = wait(0, port) ' wait for an event
if type(msg) = "roParagraphScreenEvent"
if msg.isButtonPressed()
buttonIndex = msg.GetIndex()
if buttonIndex = 1
RunBenchmarks()
else
exit while
end if
else if msg.isScreenClosed()
exit while
end if
end if
end while
screen.Close()
' anytime all screens within a channel are closed, the channel will exit
end sub
sub Main()
DisplayMainScreen()
end sub