SimScheduler implementation by Bill McQuain Script file: Script00.txt # SimMemManager Script 0 # # Scheduling with one user process # - initial loading of OS # - load of user process into VM # - load of 0-th page of user process into RM # - servicing page faults # - memory read commands # - memory write commands ########################################################################### # # Set up system: # page size: 100 # # frames: 100 # # vpages: 200 # frame factor: 50% # quantum: 3 # Memory manager is trying to load process 9999 into VM process allocated 16 pages starting at VM page 0 9999 has requested process page 0 which is virtual page 0 giving this process a new frame will be loaded into real memory frame 0 9999 has requested process page 1 which is virtual page 1 giving this process a new frame will be loaded into real memory frame 1 9999 has requested process page 2 which is virtual page 2 giving this process a new frame will be loaded into real memory frame 2 9999 has requested process page 3 which is virtual page 3 giving this process a new frame will be loaded into real memory frame 3 9999 has requested process page 4 which is virtual page 4 giving this process a new frame will be loaded into real memory frame 4 9999 has requested process page 5 which is virtual page 5 giving this process a new frame will be loaded into real memory frame 5 9999 has requested process page 6 which is virtual page 6 giving this process a new frame will be loaded into real memory frame 6 9999 has requested process page 7 which is virtual page 7 giving this process a new frame will be loaded into real memory frame 7 9999 has requested process page 8 which is virtual page 8 giving this process a new frame will be loaded into real memory frame 8 9999 has requested process page 9 which is virtual page 9 giving this process a new frame will be loaded into real memory frame 9 9999 has requested process page 10 which is virtual page 10 giving this process a new frame will be loaded into real memory frame 10 9999 has requested process page 11 which is virtual page 11 giving this process a new frame will be loaded into real memory frame 11 9999 has requested process page 12 which is virtual page 12 giving this process a new frame will be loaded into real memory frame 12 9999 has requested process page 13 which is virtual page 13 giving this process a new frame will be loaded into real memory frame 13 9999 has requested process page 14 which is virtual page 14 giving this process a new frame will be loaded into real memory frame 14 9999 has requested process page 15 which is virtual page 15 giving this process a new frame will be loaded into real memory frame 15 Memory manager loaded OS: VM base page is: 0 VM size: 16 pages OS image loaded into real memory ---------------------------------------------------------- System initialized Real memory: 10000 bytes Virtual memory: 20000 bytes Page size: 100 bytes Quantum: 3 ---------------------------------------------------------- # # The OS should be allocated the first 16 pages of virtual memory and # the first 16 frames of physical memory. Let's see: Command: show pmt Page Frame Resident 0 0 Y 1 1 Y 2 2 Y 3 3 Y 4 4 Y 5 5 Y 6 6 Y 7 7 Y 8 8 Y 9 9 Y 10 10 Y 11 11 Y 12 12 Y 13 13 Y 14 14 Y 15 15 Y ---------------------------------------------------------- # # Queue up an arrival with some memory reads to successive process pages: Command: arrival 1000 1 20 12 Job 1000 added to pending queue ---------------------------------------------------------- Command: MemAccess 1000 1 125 Added Read request (1, 125) for 1000 ---------------------------------------------------------- Command: MemAccess 1000 3 225 Added Read request (3, 225) for 1000 ---------------------------------------------------------- Command: MemAccess 1000 5 325 Added Read request (5, 325) for 1000 ---------------------------------------------------------- Command: MemAccess 1000 7 425 Added Read request (7, 425) for 1000 ---------------------------------------------------------- Command: MemAccess 1000 9 525 Added Read request (9, 525) for 1000 ---------------------------------------------------------- # # It should take 1 tick to make the process arrive. Its 12 pages should # be loaded into virtual memory immediately after the 16 pages allocated # to the OS. Let's see if that works: Command: simto 1 Advancing system time to 1 Notifying relevant processes of system tick Checking for new arrivals to hold queue Process 1000 entering hold state Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Memory manager is trying to load process 1000 into VM process allocated 12 pages starting at VM page 16 Moving process 1000 to wait state 1000 has requested process page 0 which is virtual page 16 giving this process a new frame will be loaded into real memory frame 16 Selecting next process to run No eligible processes in system at this time ---------------------------------------------------------- Command: show 1000 PID: 1000 State: PFWait Memory: 12 V Base: 16 CPU need: 20 CPU time: 0 Page faults: 1 Pending I/O requests: none Pending Read requests: {(1, 125)(3, 225)(5, 325)(7, 425)(9, 525)} Pending Write requests: none Page map: Page Frame Resident 0 16 16 Y 1 17 N 2 18 N 3 19 N 4 20 N 5 21 N 6 22 N 7 23 N 8 24 N 9 25 N 10 26 N 11 27 N ---------------------------------------------------------- Command: show pmt Page Frame Resident 0 0 Y 1 1 Y 2 2 Y 3 3 Y 4 4 Y 5 5 Y 6 6 Y 7 7 Y 8 8 Y 9 9 Y 10 10 Y 11 11 Y 12 12 Y 13 13 Y 14 14 Y 15 15 Y 16 16 Y ---------------------------------------------------------- # After two more ticks its 0-th page to be loaded into frame 16 and the # process should be in the run state: Command: simto 3 Advancing system time to 2 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 3 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state ---------------------------------------------------------- Command: show 1000 PID: 1000 State: Running Memory: 12 V Base: 16 CPU need: 20 CPU time: 0 Page faults: 1 Pending I/O requests: none Pending Read requests: {(1, 125)(3, 225)(5, 325)(7, 425)(9, 525)} Pending Write requests: none Page map: Page Frame Resident 0 16 16 Y 1 17 N 2 18 N 3 19 N 4 20 N 5 21 N 6 22 N 7 23 N 8 24 N 9 25 N 10 26 N 11 27 N ---------------------------------------------------------- # # The next tick should cause a page fault for page 1 of the process, and # two more ticks should result in a page load to frame 17 of RM and the # process being back in the run state: Command: simto 6 Advancing system time to 4 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 125 resolves to virtual page 17 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 1 which is virtual page 17 giving this process a new frame will be loaded into real memory frame 17 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 5 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 6 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state ---------------------------------------------------------- Command: show 1000 PID: 1000 State: Running Memory: 12 V Base: 16 CPU need: 20 CPU time: 1 Page faults: 2 Pending I/O requests: none Pending Read requests: {(3, 225)(5, 325)(7, 425)(9, 525)} Pending Write requests: none Page map: Page Frame Resident 0 16 16 Y 1 17 17 Y 2 18 N 3 19 N 4 20 N 5 21 N 6 22 N 7 23 N 8 24 N 9 25 N 10 26 N 11 27 N ---------------------------------------------------------- Command: show pmt Page Frame Resident 0 0 Y 1 1 Y 2 2 Y 3 3 Y 4 4 Y 5 5 Y 6 6 Y 7 7 Y 8 8 Y 9 9 Y 10 10 Y 11 11 Y 12 12 Y 13 13 Y 14 14 Y 15 15 Y 16 16 Y 17 17 Y ---------------------------------------------------------- # # The pattern should repeat itself for every three ticks until the process # has got 6 pages loaded: Command: simto 21 Advancing system time to 7 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 17 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 8 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 225 resolves to virtual page 18 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 2 which is virtual page 18 giving this process a new frame will be loaded into real memory frame 18 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 9 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 10 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 11 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 18 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 12 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 325 resolves to virtual page 19 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 3 which is virtual page 19 giving this process a new frame will be loaded into real memory frame 19 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 13 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 14 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 15 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 19 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 16 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 425 resolves to virtual page 20 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 4 which is virtual page 20 giving this process a new frame will be loaded into real memory frame 20 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 17 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 18 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 19 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 20 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 20 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 525 resolves to virtual page 21 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 5 which is virtual page 21 giving this process a new frame will be loaded into real memory frame 21 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 21 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time ---------------------------------------------------------- Command: show 1000 PID: 1000 State: PFWait Memory: 12 V Base: 16 CPU need: 20 CPU time: 9 Page faults: 6 Pending I/O requests: none Pending Read requests: none Pending Write requests: none Page map: Page Frame Resident 0 16 16 Y 1 17 17 Y 2 18 18 Y 3 19 19 Y 4 20 20 Y 5 21 21 Y 6 22 N 7 23 N 8 24 N 9 25 N 10 26 N 11 27 N ---------------------------------------------------------- Command: show pmt Page Frame Resident 0 0 Y 1 1 Y 2 2 Y 3 3 Y 4 4 Y 5 5 Y 6 6 Y 7 7 Y 8 8 Y 9 9 Y 10 10 Y 11 11 Y 12 12 Y 13 13 Y 14 14 Y 15 15 Y 16 16 Y 17 17 Y 18 18 Y 19 19 Y 20 20 Y 21 21 Y ---------------------------------------------------------- # # The process's frame limit should be 6, so the next read should trigger # a page replacement, recycling the first page that was loaded for the # process: Command: MemAccess 1000 11 625 Added Read request (11, 625) for 1000 ---------------------------------------------------------- Command: simto 24 Advancing system time to 22 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 23 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 21 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 24 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process wants to access relative address 625 resolves to virtual page 22 and offset 25 page is not resident... initiating page fault Moving process 1000 to PFWait state 1000 has requested process page 6 which is virtual page 22 re-using a frame already allocated to this process choosing frame 16 unloading page 16 will be loaded into real memory frame 16 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time ---------------------------------------------------------- Command: show 1000 PID: 1000 State: PFWait Memory: 12 V Base: 16 CPU need: 20 CPU time: 11 Page faults: 7 Pending I/O requests: none Pending Read requests: none Pending Write requests: none Page map: Page Frame Resident 0 16 N 1 17 17 Y 2 18 18 Y 3 19 19 Y 4 20 20 Y 5 21 21 Y 6 22 16 Y 7 23 N 8 24 N 9 25 N 10 26 N 11 27 N ---------------------------------------------------------- # # Run the process to completion: Command: simto 35 Advancing system time to 25 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time Advancing system time to 26 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking wait state for serviced page faults Moving process 1000 to ready state Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 27 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process accessing frame 16 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 28 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 29 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Quantum has expired for process 1000 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 30 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 31 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 32 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Quantum has expired for process 1000 Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run Moving process 1000 to running state Advancing system time to 33 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 34 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Advancing system time to 35 Notifying relevant processes of system tick Checking for new arrivals to hold queue Checking status of running process Process 1000 has terminated Checking wait state for serviced page faults Checking blocked state for newly-satisfied processes Checking hold state for startable processes Selecting next process to run No eligible processes in system at this time ---------------------------------------------------------- Command: show 1000 PID: 1000 State: Term Memory: 12 V Base: 16 CPU need: 20 CPU time: 20 Page faults: 7 Pending I/O requests: none Pending Read requests: none Pending Write requests: none Page map: Page Frame Resident 0 none N 1 none N 2 none N 3 none N 4 none N 5 none N 6 none N 7 none N 8 none N 9 none N 10 none N 11 none N ---------------------------------------------------------- No more commands in script file. Exiting... ---------------------------------------------------------- Statistics for terminated processes: PID CPU Need Arrived Finished Wait time Turnaround Weighted Page Faults ---------------------------------------------------------------------------------- 1000 20 1 35 0 32 1.6 7/6(1.17) Overall statistics: Average wait time: 0.0 Average turnaround time: 32.0 Average weighted turnaround: 1.6 Page faults: 7/6(1.2) ----------------------------------------------------------