SimScheduler implementation by Bill McQuain Script file: Script03.txt # SimMemManager Script 3 # # 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 access violation ########################################################################### # # 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 ---------------------------------------------------------- Command: show fmt Frame vPage Owner Allocated 0 0 9999 Y 1 1 9999 Y 2 2 9999 Y 3 3 9999 Y 4 4 9999 Y 5 5 9999 Y 6 6 9999 Y 7 7 9999 Y 8 8 9999 Y 9 9 9999 Y 10 10 9999 Y 11 11 9999 Y 12 12 9999 Y 13 13 9999 Y 14 14 9999 Y 15 15 9999 Y ---------------------------------------------------------- # # Queue up an arrival with an illegal memory read: Command: arrival 1000 1 25 12 Job 1000 added to pending queue ---------------------------------------------------------- Command: MemAccess 1000 1 1625 Added Read request (1, 1625) 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 Scheduler system state: Quantum: 3 System time: 1 Status PID Memory CPU Need CPU Time --------------------------------------------- pending running holding ready PFWait 1000 12 25 0 IOWait finished ---------------------------------------------------------- Command: show 1000 PID: 1000 State: PFWait Memory: 12 V Base: 16 CPU need: 25 CPU time: 0 Page faults: 1 Pending I/O requests: none Pending Read requests: {(1, 1625)} 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: 25 CPU time: 0 Page faults: 1 Pending I/O requests: none Pending Read requests: {(1, 1625)} 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 memory access violation error and the # process should be killed: 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 1625 The process may not access that address Process 1000 has been killed 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 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: Killed Memory: 12 V Base: 16 CPU need: 25 CPU time: 1 Page faults: 1 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 ---------------------------------------------------------- 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 ---------------------------------------------------------- Command: show fmt Frame vPage Owner Allocated 0 0 9999 Y 1 1 9999 Y 2 2 9999 Y 3 3 9999 Y 4 4 9999 Y 5 5 9999 Y 6 6 9999 Y 7 7 9999 Y 8 8 9999 Y 9 9 9999 Y 10 10 9999 Y 11 11 9999 Y 12 12 9999 Y 13 13 9999 Y 14 14 9999 Y 15 15 9999 Y ---------------------------------------------------------- No more commands in script file. Exiting... ---------------------------------------------------------- Statistics for terminated processes: PID CPU Need Arrived Finished Wait time Turnaround Weighted Page Faults ---------------------------------------------------------------------------------- 1000 25 1 4 0 ----------------------------------------------------------