aboutsummaryrefslogtreecommitdiff
path: root/fifo.py
diff options
context:
space:
mode:
Diffstat (limited to 'fifo.py')
-rw-r--r--fifo.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/fifo.py b/fifo.py
index 7fa55a0..61e70f5 100644
--- a/fifo.py
+++ b/fifo.py
@@ -10,7 +10,6 @@ class FifoPaginator:
10 def __init__(self, mem): 10 def __init__(self, mem):
11 self.mem = mem 11 self.mem = mem
12 self._main_cursor = 0 12 self._main_cursor = 0
13 self._virt_cursor = 0
14 13
15 def _put_main(self, page): 14 def _put_main(self, page):
16 overwritten = self.mem.main[self._main_cursor] 15 overwritten = self.mem.main[self._main_cursor]
@@ -18,13 +17,10 @@ class FifoPaginator:
18 self._main_cursor = (self._main_cursor + 1) % len(self.mem.main) 17 self._main_cursor = (self._main_cursor + 1) % len(self.mem.main)
19 return overwritten 18 return overwritten
20 19
21 def _put_virt(self, page):
22 self.mem.virt[self._virt_cursor] = page
23 self._virt_cursor += 1
24
25 def load(self, page): 20 def load(self, page):
26 if not self.mem.has_page(page): raise IndexError 21 if not self.mem.page_in_range(page): raise IndexError
27 if page in self.mem.main: return 22 if page in self.mem.main: return
23 if page in self.mem.virt: self.mem.remove_virt(page)
28 overwritten = self._put_main(page) 24 overwritten = self._put_main(page)
29 if overwritten not in self.mem.virt: self._put_virt(overwritten) 25 if overwritten is not None: self.mem.put_virt(overwritten)
30 26