Skip to content

Commit

Permalink
Read-lock the memory object while running code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 25, 2017
1 parent 07c4ab8 commit ce9f624
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions emu/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@
flatten void cpu_run(struct cpu_state *cpu) {
int i = 0;
struct tlb *tlb = tlb_new(cpu->mem);
read_wrlock(&cpu->mem->lock);
int changes = cpu->mem->changes;
while (true) {
int interrupt = cpu_step32(cpu, tlb);
Expand All @@ -629,7 +630,9 @@ flatten void cpu_run(struct cpu_state *cpu) {
}
if (interrupt != INT_NONE) {
cpu->trapno = interrupt;
read_wrunlock(&cpu->mem->lock);
handle_interrupt(interrupt);
read_wrlock(&cpu->mem->lock);
if (tlb->mem != cpu->mem)
tlb->mem = cpu->mem;
if (cpu->mem->changes != changes) {
Expand Down

0 comments on commit ce9f624

Please sign in to comment.