diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-16 10:47:53 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-16 10:47:53 +0100 |
| commit | 471a5da32d4b41a71ef74dbca46fd88493ad0948 (patch) | |
| tree | 02535554db0fc3e726f83452ec5cadbf573a7369 /src/devices | |
| parent | cc12754676993c3033ba9d64d5dda1ef9f2c50b0 (diff) | |
| download | pintos-471a5da32d4b41a71ef74dbca46fd88493ad0948.tar.gz | |
disable interrupts when queueing threadslab2
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/timer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/devices/timer.c b/src/devices/timer.c index 856a14e..aea6aa2 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -114,6 +114,9 @@ timer_sleep (int64_t ticks) new_waiting_thread.tick_target = start + ticks; sema_init (&new_waiting_thread.sema, 0); + // disable interrupts so the timer interrupt handler can't modify the list + enum intr_level old_level = intr_disable (); + struct list_elem *before = list_begin (&waiting_threads); while (before != list_end (&waiting_threads)) { struct list_elem *next = list_next (before); @@ -125,6 +128,8 @@ timer_sleep (int64_t ticks) } list_insert (before, &new_waiting_thread.elem); + intr_set_level (old_level); + sema_down (&new_waiting_thread.sema); } |
