Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
3354 - support multiple routines at a source/sink
Browse files Browse the repository at this point in the history
This commit completes the final step: fixing the final failing tests (in
chessboard.mu) by teaching `restart` about the block signal.
  • Loading branch information
akkartik committed Sep 15, 2016
1 parent 05fe4be commit 36b927a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
27 changes: 27 additions & 0 deletions 073wait.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ case RESTART: {
if (Routines.at(i)->id == id) {
if (Routines.at(i)->state == WAITING)
Routines.at(i)->state = RUNNING;
Routines.at(i)->blocked = false;
break;
}
}
Expand All @@ -571,3 +572,29 @@ def f [
1:number/raw <- copy 1
]
# shouldn't crash

:(scenario restart_blocked_routine)
% Scheduling_interval = 1;
def main [
local-scope
r:number/routine-id <- start-running f
wait-for-routine-to-block r # get past the block in f below
restart r
wait-for-routine-to-block r # should run f to completion
]
# function with one block
def f [
current-routine-is-blocked
# 8 instructions of padding, many more than 'main' above
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
1:number <- add 1:number, 1
]
# make sure all of f ran
+mem: storing 8 in location 1
26 changes: 13 additions & 13 deletions chessboard.mu
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ scenario read-move-blocking [
# 'read-move' is waiting for input
wait-for-routine-to-block read-move-routine
read-move-state:number <- routine-state read-move-routine
waiting?:boolean <- equal read-move-state, 3/waiting
waiting?:boolean <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]
# press 'a'
Expand All @@ -381,7 +381,7 @@ F read-move-blocking: routine failed to pause after coming up (before any keys w
# 'read-move' still waiting for input
wait-for-routine-to-block read-move-routine
read-move-state <- routine-state read-move-routine
waiting? <- equal read-move-state, 3/waiting
waiting? <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after rank 'a']
# press '2'
Expand All @@ -390,7 +390,7 @@ F read-move-blocking: routine failed to pause after rank 'a']
# 'read-move' still waiting for input
wait-for-routine-to-block read-move-routine
read-move-state <- routine-state read-move-routine
waiting? <- equal read-move-state, 3/waiting
waiting? <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after file 'a2']
# press '-'
Expand All @@ -399,7 +399,7 @@ F read-move-blocking: routine failed to pause after file 'a2']
# 'read-move' still waiting for input
wait-for-routine-to-block read-move-routine
read-move-state <- routine-state read-move-routine
waiting? <- equal read-move-state, 3/waiting
waiting? <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after hyphen 'a2-']
# press 'a'
Expand All @@ -408,7 +408,7 @@ F read-move-blocking: routine failed to pause after hyphen 'a2-']
# 'read-move' still waiting for input
wait-for-routine-to-block read-move-routine
read-move-state <- routine-state read-move-routine
waiting? <- equal read-move-state, 3/waiting
waiting? <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after rank 'a2-a']
# press '4'
Expand All @@ -417,7 +417,7 @@ F read-move-blocking: routine failed to pause after rank 'a2-a']
# 'read-move' still waiting for input
wait-for-routine-to-block read-move-routine
read-move-state <- routine-state read-move-routine
waiting? <- equal read-move-state, 3/waiting
waiting? <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-blocking: routine failed to pause after file 'a2-a4']
# press 'newline'
Expand Down Expand Up @@ -445,7 +445,7 @@ scenario read-move-quit [
# 'read-move' is waiting for input
wait-for-routine-to-block read-move-routine
read-move-state:number <- routine-state read-move-routine
waiting?:boolean <- equal read-move-state, 3/waiting
waiting?:boolean <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-quit: routine failed to pause after coming up (before any keys were pressed)]
# press 'q'
Expand Down Expand Up @@ -473,9 +473,9 @@ scenario read-move-illegal-file [
# 'read-move' is waiting for input
wait-for-routine-to-block read-move-routine
read-move-state:number <- routine-state read-move-routine
waiting?:boolean <- equal read-move-state, 3/waiting
waiting?:boolean <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-file: routine failed to pause after coming up (before any keys were pressed)]
F read-move-illegal-file: routine failed to pause after coming up (before any keys were pressed)]
sink <- write sink, 50/'2'
restart read-move-routine
wait-for-routine-to-block read-move-routine
Expand All @@ -495,9 +495,9 @@ scenario read-move-illegal-rank [
# 'read-move' is waiting for input
wait-for-routine-to-block read-move-routine
read-move-state:number <- routine-state read-move-routine
waiting?:boolean <- equal read-move-state, 3/waiting
waiting?:boolean <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-file: routine failed to pause after coming up (before any keys were pressed)]
F read-move-illegal-rank: routine failed to pause after coming up (before any keys were pressed)]
sink <- write sink, 97/a
sink <- write sink, 97/a
restart read-move-routine
Expand All @@ -518,9 +518,9 @@ scenario read-move-empty [
# 'read-move' is waiting for input
wait-for-routine-to-block read-move-routine
read-move-state:number <- routine-state read-move-routine
waiting?:boolean <- equal read-move-state, 3/waiting
waiting?:boolean <- not-equal read-move-state, 2/discontinued
assert waiting?, [
F read-move-file: routine failed to pause after coming up (before any keys were pressed)]
F read-move-empty: routine failed to pause after coming up (before any keys were pressed)]
sink <- write sink, 10/newline
sink <- write sink, 97/a
restart read-move-routine
Expand Down

0 comments on commit 36b927a

Please sign in to comment.