def main(): verbose = verbose_mode(sys.argv) input_handler = InputHandler() output_handler = OutputHandler("results.txt") [memory_blocks, references] = input_handler.parse_file(sys.argv[1]) fifo = FIFO(copy.deepcopy(memory_blocks), copy.deepcopy(references)) fifo_stats = fifo.run() fifo_stats_str = get_stats_str("FIFO", fifo_stats) otm = OTM(copy.deepcopy(memory_blocks), copy.deepcopy(references)) otm_stats = otm.run() otm_stats_str = get_stats_str("OTM", otm_stats) lru = LRU(copy.deepcopy(memory_blocks), copy.deepcopy(references)) lru_stats = lru.run() lru_stats_str = get_stats_str("LRU", lru_stats) output_handler.write_to_file(fifo_stats_str, otm_stats_str, lru_stats_str) if verbose: print(fifo_stats_str, end="") print(otm_stats_str, end="") print(lru_stats_str)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from Utils import Utils #Import Utils module. from FIFO import FIFO #Import FIFO module. from LRU import LRU #Import LRU module. from OTM import OTM #Import OTM module. if __name__ == "__main__": #Runs only if main was not imported as a module. input = Utils.getData() #Get data from the user. fifo = FIFO(input) #Create a FIFO objet. lru = LRU(input) #Create a LRU objet. otm = OTM(input) #Create an OTM objet. fifo.run() #Run the algorithm. lru.run() #Run the algorithm. otm.run() #Run the algorithm. print(fifo) #Show the object information(missing pages). print(otm) #Show the object information(missing pages). print(lru) #Show the object information(missing pages).