diff options
author | pacien | 2018-03-28 17:02:43 +0200 |
---|---|---|
committer | pacien | 2018-03-28 17:02:43 +0200 |
commit | 0441d28435e8db1d60c1ae30c81e3a54f12149c8 (patch) | |
tree | 5b9333551725b440acde6d5b16f278e5ffa5bd93 /fifo.py | |
parent | 6a979da2d6c2cf3347c6cad0439518a5f084648e (diff) | |
download | mempager-simulator-0441d28435e8db1d60c1ae30c81e3a54f12149c8.tar.gz |
Adapt for fixed specs
Diffstat (limited to 'fifo.py')
-rw-r--r-- | fifo.py | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -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 | ||