Hi,
if we load the page frames in sorted by page num the memory looks like this:
process 1: 0,1,2,3
process 2: 4,5,6,7
process 3: 99,99,99,99
process 4: 99,99,99,99
RAM: 0,1,2,3,4,5,6,7
DISK: 99,99,99,99,99,99,99
but if we get the instruction '3' there is no process 3 in main memory to swap to,
instead are we supposed to put in 2 each to avoid this?
e.g.
process 1: 0,1,99,99
process 2: 2,3,99,99
process 3: 4,5,99,99
process 4: 6,7,99,99
RAM: 0,1,2,3,4,5,6,7
DISK: 99,99,99,99,99,99,99,99
so now instruction 3 changes it to
RAM: 0,1,2,99,4,5,6,7
DISK: 99,99,99,99,99,99,3,99
or is there a better way?
> Hi,
> if we load the page frames in sorted by page num the memory looks like this:
>
> process 1: 0,1,2,3
> process 2: 4,5,6,7
> process 3: 99,99,99,99
> process 4: 99,99,99,99
>
>
> RAM: 0,1,2,3,4,5,6,7
> DISK: 99,99,99,99,99,99,99
>
> but if we get the instruction '3' there is no process 3 in main memory to swap to,
>
> instead are we supposed to put in 2 each to avoid this?
>
> e.g.
> process 1: 0,1,99,99
> process 2: 2,3,99,99
> process 3: 4,5,99,99
> process 4: 6,7,99,99
>
> RAM: 0,1,2,3,4,5,6,7
> DISK: 99,99,99,99,99,99,99,99
>
> so now instruction 3 changes it to
>
> RAM: 0,1,2,99,4,5,6,7
> DISK: 99,99,99,99,99,99,3,99
>
> or is there a better way?
I'm not sure what your question is about. Are you asking what happens if RAM is full and we are bringing in another process which isn't in RAM?
In that case you would evict the page of *any process* with the lowest "last_accessed" time.
Also, not sure what your RAM and DISK variable represent. Both RAM and DISK should only contain pointers to structures. You should only put 99 in the page table (to show that a page of a process isn't in RAM), it shouldn't appear in RAM or DISK.
We do not modify virtual memory in any way. We assume all pages are always in virtual memory regardless if they are currently in RAM or not. We only ever change the contents RAM and the page table.
> Hi,
> if we load the page frames in sorted by page num the memory looks like this:
>
> process 1: 0,1,2,3
> process 2: 4,5,6,7
> process 3: 99,99,99,99
> process 4: 99,99,99,99
>
>
> RAM: 0,1,2,3,4,5,6,7
> DISK: 99,99,99,99,99,99,99
>
> but if we get the instruction '3' there is no process 3 in main memory to swap to,
>
> instead are we supposed to put in 2 each to avoid this?
>
> e.g.
> process 1: 0,1,99,99
> process 2: 2,3,99,99
> process 3: 4,5,99,99
> process 4: 6,7,99,99
>
> RAM: 0,1,2,3,4,5,6,7
> DISK: 99,99,99,99,99,99,99,99
>
> so now instruction 3 changes it to
>
> RAM: 0,1,2,99,4,5,6,7
> DISK: 99,99,99,99,99,99,3,99
>
> or is there a better way?
Are you asking if there are any pages in RAM when the simulation starts?
The RAM is empty there are no pages in RAM.
Ok that makes sense,
RAM and DISC are the values of the page table of the currently loaded processes so
RAM: 0,1,2,3,4,5,6,7
DISK: 99,99,99,99,99,99,99,99
instruction 3
RAM: 0->99 (evicting process 1 (value 0) and replacing with process 3 (value 99)),1,2,3,4,5,6,7
DISK: 99->0,99,99,99,99,99,99,99
here initially processes 1 and 2 are in RAM (each with 4 pages for each page table) and a page from process 3 in disc swaps with the first page in ram after getting the '3' instruction.
Is this correct?
> Ok that makes sense,
> RAM and DISC are the values of the page table of the currently loaded processes so
> RAM: 0,1,2,3,4,5,6,7
> DISK: 99,99,99,99,99,99,99,99
> instruction 3
> RAM: 0->99 (evicting process 1 (value 0) and replacing with process 3 (value 99)),1,2,3,4,5,6,7
> DISK: 99->0,99,99,99,99,99,99,99
> here initially processes 1 and 2 are in RAM (each with 4 pages for each page table) and a page from process 3 in disc swaps with the first page in ram after getting the '3' instruction.
> Is this correct?
Isn't this your page table?
process 1: 0,1,2,3
process 2: 4,5,6,7
process 3: 99,99,99,99
process 4: 99,99,99,99
It's hard to follow what you are doing to RAM and disk because it doesn't provide information as to which page of which process is in RAM. RAM: 0, 1, 2, 3, 4, 5, 6, 7 is just the frame numbers or the possible positions in RAM the page of a process could be loaded into.
yes that's the page table, with corrected indexes it looks like this:
process 0: 0,1,2,3
process 1; 4,5,6,7
process 2: 99,99,99,99
process 3: 99,99,99,99
process 0 and 1 are loaded into ram with values 0-7
but now there is a new issue with instruction '0'
'the next page of process 0 has to be brought in from virtual memory to the RAM'
however every page from process 0 is already loaded into RAM
do I just switch the pages like so:
process 0: 0,1,2,3
process 0: 1,0,2,3 (and update the time step for these 2 that change)
or does something else need to happen?
> yes that's the page table, with corrected indexes it looks like this:
> process 0: 0,1,2,3
> process 1; 4,5,6,7
> process 2: 99,99,99,99
> process 3: 99,99,99,99
>
> process 0 and 1 are loaded into ram with values 0-7
> but now there is a new issue with instruction '0'
>
> 'the next page of process 0 has to be brought in from virtual memory to the RAM'
> however every page from process 0 is already loaded into RAM
> do I just switch the pages like so:
> process 0: 0,1,2,3
> process 0: 1,0,2,3 (and update the time step for these 2 that change)
>
> or does something else need to happen?