Skip to content

Commit

Permalink
Implemented interrupts in direct mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert van Renesse committed Jan 21, 2024
1 parent 8760cca commit 58a1f51
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions harmony_model_checker/charm/charm.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ static void run_direct(struct state *state){
struct step step;
memset(&step, 0, sizeof(step));
step.ctx = &fullctx.ctx;
unsigned int interrupt_count = 1;

while (state->bagsize > 0) {
unsigned int total = 0, ctx_index = 0;
Expand Down Expand Up @@ -338,6 +339,14 @@ static void run_direct(struct state *state){
assert(!cc->failed);
memcpy(&fullctx, cc, ctx_size(cc));

// Check if an interrupt is in order
if (cc->extended && ctx_trap_pc(cc) != 0 && !cc->interruptlevel) {
interrupt_count += 1;
if (random() % interrupt_count == 0) {
interrupt_invoke(&step);
}
}

for (;;) {
int pc = step.ctx->pc;
struct instr *instrs = global.code.instrs;
Expand Down

0 comments on commit 58a1f51

Please sign in to comment.