Created
March 8, 2019 17:51
-
-
Save hwayne/417eaed425463fa470bee0544baf3d7f to your computer and use it in GitHub Desktop.
PRISM example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int total_dropped; | |
S =? [ dropped = total_dropped] | |
P =? [ (F queue = MAX) & (F "done" & dropped = total_dropped)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int REQ; // requests | |
const int MAX; // maximum size | |
const double MSG_RATE; | |
formula rate_read = 1 / (1 + MSG_RATE); | |
formula rate_write = 1 - rate_read; | |
formula queue_empty = queue = 0; | |
formula queue_full = queue = MAX; | |
formula msg_left = mleft > 0; | |
//One module, so that we can leave out stutter steps. | |
// DECISION TABLE | |
// mleft queue | R? W? | |
// T empty | F T | |
// T med | T T | |
// T full | T F | |
// F empty | F F | |
// F med | T F | |
// F full | T F | |
module readwrite | |
mleft: [0..REQ] init REQ; | |
queue: [0..MAX] init 0; | |
dropped: [0..REQ] init 0; | |
[] msg_left & queue_empty -> (queue' = queue + 1) & (mleft' = mleft - 1); | |
[] msg_left & !(queue_empty | queue_full) -> | |
rate_read: (queue' = queue - 1) + | |
rate_write: (queue' = queue + 1) & (mleft' = mleft - 1); | |
[] msg_left & queue_full | |
& dropped < REQ -> //necessary so the model checker doesn't flip | |
rate_read: (queue' = queue - 1) + | |
rate_write: (mleft' = mleft - 1) & (dropped' = dropped + 1); | |
[] !msg_left & !queue_empty -> (queue' = queue - 1); | |
endmodule | |
label "done" = !msg_left & queue_empty; |
Author
hwayne
commented
Mar 8, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment