timer (simple periodic task) works now

parent 41c2dfb9
......@@ -21,11 +21,11 @@ mu:test_other:
- cd $MU_TEST_DIR
- $PYTEST test_exctran.py
mu:test_impl_dep:
script:
- git clone https://gitlab.anu.edu.au/mu/mu-impl-ref2 && cd mu-impl-ref2
- git checkout master
- sbt clean && sbt compile && cd cbinding && make
- cd $MU_TEST_DIR
# tests that depend on mu-impl-ref2 go here
- $PYTEST test_ll2mu.py test_mutyper.py test_database.py test_genmu.py
#mu:test_impl_dep:
# script:
# - git clone https://gitlab.anu.edu.au/mu/mu-impl-ref2 && cd mu-impl-ref2
# - git checkout master
# - sbt clean && sbt compile && cd cbinding && make
# - cd $MU_TEST_DIR
# # tests that depend on mu-impl-ref2 go here
# - $PYTEST test_ll2mu.py test_mutyper.py test_database.py test_genmu.py
# from rpython.rlib.rthread import *
from rpython.rlib.rrtmu.rtzebu import new_timer, arm_timer, new_futex, wait_futex, wake_futex, get_time_ns
from rpython.rlib.rrtmu.rtzebu import \
new_timer, arm_timer, new_futex, wait_futex, wake_futex, get_time_ns, start_new_rt_thread, new_attr
from rpython.rlib.rrtmu import rtzebu
import time
# global_counter = 10
NUM_OF_REPS = 10
NUM_OF_REPS = 25
class MyG:
__slots__ = ("counter", "ftx")
__slots__ = ("counter", "ftx1", "ftx2", "finished")
# counter = NUM_OF_THREADS
# ftx = new_futex()
def __init__(self):
self.counter = NUM_OF_REPS
self.ftx = new_futex()
self.ftx1 = new_futex()
self.ftx2 = new_futex()
self.finished = False
mg = MyG()
def entry_point():
def timer_entry_point():
# global global_counter
global mg
f = mg.ftx
f1 = mg.ftx1
# c1 = mg.counter
wake_futex(f)
wait_futex(f1)
c1 = mg.counter
mg.counter = c1 - 1
wake_futex(f1)
def thread_entry_point():
global mg
f1 = mg.ftx1
f2 = mg.ftx2
while True:
wait_futex(f1)
if mg.counter < 1:
wake_futex(f1)
break
else:
wake_futex(f1)
wait_futex(f2)
mg.finished = True
wake_futex(f2)
def test_simple_timer():
# global global_counter
global mg
f = new_futex()
mg.ftx = f
wait_futex(f)
f1 = new_futex()
mg.ftx1 = f1
f2 = new_futex()
mg.ftx2 = f2
my_tmr = new_timer()
tm = 100000000
period = 500000000
start = get_time_ns()
arm_timer(my_tmr, entry_point, tm, period)
arm_timer(my_tmr, timer_entry_point, tm, period)
for i in range(0, NUM_OF_REPS + 1):
wait_futex(f)
a = new_attr()
start_new_rt_thread(thread_entry_point, a)
while True:
wait_futex(f2)
if mg.finished:
wake_futex(f2)
break
else:
wake_futex(f2)
end = get_time_ns()
dur = end - start
exp_dur = NUM_OF_REPS * period + tm
return dur - exp_dur
res_ms = (dur - exp_dur) // 1000000
# res_ms = dur // 100000000
rtzebu.os_exit(res_ms)
def test_while(lc):
while lc > 0:
lc = lc - 1
return lc
......@@ -220,6 +220,7 @@ def is_rtmu_untraced(graph):
def os_exit(res):
c_exit(rffi.cast(rffi.INT, res))
return 0
def delete_self():
......
......@@ -173,7 +173,7 @@ class MuBundleGen:
def gen_boot_image(self, targetname):
self.log.gen_boot_image("gen_boot_image")
self.build_and_load_bundle()
# self.build_and_load_bundle()
self.log.gen_boot_image("gen_boot_image, bundle loaded")
......@@ -249,7 +249,7 @@ class MuBundleGen:
self.log.gen_types("declaring %d types..." % len(self.db.types))
for T in self.db.types:
_id = self._id_of(T)
# self.log.info('id: %d, type: %s' % (_id, T.__str__()))
self.log.info('id: %d, type: %s' % (_id, T))
if isinstance(T, mutype.MuIntType):
self.bdr.new_type_int(_id, T.BITS)
elif T == mutype.MU_FLOAT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment