Question: I literally don't get this and the previous expert's code didn't work. The screenshots contain the instructions and the tests the program must pass (

I literally don't get this and the previous expert's code didn't work. The screenshots contain the instructions and the tests the program must pass (I'll be thrilled if I end up with 60% or more).
I'm not sure if you need the content of the other three Python files to make this work but here's how the Operating system code looks like (the one I actually need to modify):
from typing import Optional
from ram import RAM
from process import Process
from pageregisters import PageRegisters
# ===========================================================================
# Operating System Memory Management
# ===========================================================================
#
# InvalidAddress(Exception)- does nothing, but program will crash with
# an appropriate error
# NotImplemented(Exception)- Catches the error that a function was called that has not been written yet
# page_fault(self,v_addr)- called when the MMU accesses a page register that is set to None
# load_process(self,process)- a process is being loaded
#
#
class InvalidAddress(Exception):
pass
class OS:
# -------------------------------------------------------------
# constructor
# -------------------------------------------------------------
def __init__(self, ram: RAM, page_registers: PageRegisters):
# ---------------------------------------------------------
# put whatever other data you want need here
# ---------------------------------------------------------
# ---------------------------------------------------------
# every OS must have access to the ram
# ---------------------------------------------------------
# to load data into ram...
# 'self.ram.set_data( physical_address, value )'
self.ram: RAM = ram
# ---------------------------------------------------------
# Divide the RAM into frames
# ---------------------------------------------------------
self.ram_frames =[None]*((self.ram.max_addr +1)// page_registers.page_size)
# ---------------------------------------------------------
# every OS must have access to the page_registers
# ---------------------------------------------------------
# to set a specific frame number for a given page
# 'self.page_registers.set_frame_number(page_number,frame_number)'
# to get the frame_number from the page registers for a specific page
# 'frame_number = self.page_registers.get_frame_number(page_number)'
self.page_registers: PageRegisters = page_registers
# page size (or frame size)
self.page_size = page_registers.page_size
# ---------------------------------------------------------
# total number of frames available to the RAM
# ---------------------------------------------------------
self.num_frames_in_ram = len(self.ram_frames)
# ---------------------------------------------------------
# which process is currently running
# ---------------------------------------------------------
self.current_process: Optional[Process]= None
# -------------------------------------------------------------
# os deals with invalid address complaint from mmu
# you must load the appropriate data from the process into
# the ram, and update page registers accordingly
# ... other information may also need to be saved
# -------------------------------------------------------------
def page_fault(self, v_addr):
"""handles the mmu page faults"""
# -------------------------------------------------------------
# new processes is loaded
# NOTE: each process has the properties:
# pid -> uniquely identify each process (integer)
# entry_point -> which address is the location of the first
# size -> the size of the process
# -------------------------------------------------------------
def load_process(self, process_object):
"""load a new process"""
I literally don't get this and the previous

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!