private static void FakeMemory(params int[] blockIds) { for (int i = 0; i < blockIds.Length; i++) { RealMachine.GetRealMemory().TakeMemoryBlock(blockIds[i]); } }
static void Main(string[] args) { PrintLogo(); Console.WriteLine("\n----------- Welcome to jCubeOS! -----------\n"); GetFileNames(); bool exit = false; while (!exit) { Console.Write("\nTask program name: "); string filePath = FromFileList(Console.ReadLine()); Input inputHandler = new ConsoleInput(); Output outputHandler = new ConsoleOutput(); RealMachine = new RealMachine(inputHandler, outputHandler); //FAKE MEMORY ALLOCATION FakeMemory(0, 1, 3, 5, 7, 9, 10, 14, 16, 17, 21, 23, 24, 27, 29, 31, 33); if (!RealMachine.LoadVirtualMachine(filePath)) { continue; } exit = Execution(exit); } }
//PageTable object constructor public PageTable(RealMachine realMachine) { _realMachine = realMachine; for (int i = 0; i < Settings.Default.VirtualPagesCount; i++) { VirtualPages[i] = new VirtualPage(i); } }
public PageTable(RealMachine realMachine, int PagesCount) { rm = realMachine; m_virtualPages = new VirtualPage[PagesCount]; for (int i = 0; i < PagesCount; i++) { VirtualPages[i] = new VirtualPage(i); } }
//this should be moved to RealMachine class private void DoNextInstruction(VirtualMachine virtualMachine) { try { RealMachine.ExecuteAction(virtualMachine); } catch (Exception exception) { virtualMachine.ReleaseResources(); VirtualMachines.Remove(virtualMachine); MessageBox.Show(this, "Ooops... your program have crased\n" + exception.Message, "Program " + virtualMachine.Name + "(" + virtualMachine.PID + ") have occured error"); } }
public MainWindow() { RealMachine = new RealMachine(m_virtualMachines); InitializeComponent(); }
private void RunUntilInterup_ButtonClick(object sender, RoutedEventArgs e) { RealMachine.RunVirtualMachinesUntilTimerInterupt(); }
private void Run_ButtonClick(object sender, RoutedEventArgs e) { RealMachine.FullyRunAllPrograms(); }
static void Main() { RealMachine rm = new RealMachine(); rm.runProgram("test.txt", true); }
public static void Main(string[] args) { RealMachine r = new RealMachine(); r.run(); }
private static bool Execution(bool exit) { bool incorrect = false; do { PrintMenu(); Console.Write("EXECUTION MODE: "); string executionMode = Console.ReadLine(); Console.Write("\n"); bool working = true; switch (executionMode) { case "1": working = RealMachine.GetProcessor().Execute(); break; case "2": working = RealMachine.GetProcessor().Step(); bool done = false; while (!done) { PrintStepMenu(); Console.Write("ACTION: "); string action = Console.ReadLine(); Console.Write("\n"); switch (action) { case "1": working = RealMachine.GetProcessor().Step(); break; case "2": working = RealMachine.GetProcessor().Execute(); break; case "3": RealMachine.GetRealMemory().PrintUserMemory(); break; case "4": RealMachine.GetVirtualMemory().PrintVirtualMemory(); break; case "5": RealMachine.GetProcessor().PrintAllRegisters(); break; case "0": done = true; break; case "c": Console.Clear(); break; default: Console.WriteLine("Incorrect action."); break; } if (!working) { done = true; } } break; case "0": exit = true; break; case "c": Console.Clear(); break; default: Console.WriteLine("Incorrect execution mode."); incorrect = true; break; } if (!working) { break; } } while (incorrect); return(exit); }