resource test_sched_expr() op f(x : int), guard_has_changed() var global_var : int := 5 process service write("age=", age(), "process `service' will handle calls to f") do true -> write("age=", age(), "f: ready") in f(x) st global_var > x -> write("age=", age(), "f: x=", x, "global_var=", global_var) [] guard_has_changed() -> write("age=", age(), "`guard_has_changed' dequeued") ni od end service nap(1000) write("age=", age(), "global_var=", global_var) nap(1000) send f(10) # `in f(x)' blocked since false guard nap(1000) global_var := 15 # `in f(x)' still blocked nap(1000) write("age=", age(), "global_var=", global_var) nap(1000) send guard_has_changed() # give `in' a kick nap(1000) send f(20) # `in f(x)' blocked since false guard nap(1000) global_var := 25 # `in f(x)' still blocked nap(1000) write("age=", age(), "global_var=", global_var) nap(1000) send guard_has_changed() # give `in' a kick nap(1000) send f(1) # `in f(x)' takes f(1) nap(1000) write("age=", age(), "stopping") stop end test_sched_expr /* ............... Example compile and run(s) % sr -v; sr -o test_sched_expr test_sched_expr.sr MultiSR version 2.3, October 1994 % ./test_sched_expr age= 30 process `service' will handle calls to f age= 34 f: ready age= 1031 global_var= 5 age= 4040 global_var= 15 age= 5051 f: x= 10 global_var= 15 age= 5052 f: ready age= 5054 `guard_has_changed' dequeued age= 5055 f: ready age= 8060 global_var= 25 age= 9071 f: x= 20 global_var= 25 age= 9072 f: ready age= 9074 `guard_has_changed' dequeued age= 9075 f: ready age= 10071 f: x= 1 global_var= 25 age= 10073 f: ready age= 11070 stopping */