Ejemplo n.º 1
0
 private static void FakeMemory(params int[] blockIds)
 {
     for (int i = 0; i < blockIds.Length; i++)
     {
         RealMachine.GetRealMemory().TakeMemoryBlock(blockIds[i]);
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 //PageTable object constructor
 public PageTable(RealMachine realMachine)
 {
     _realMachine = realMachine;
     for (int i = 0; i < Settings.Default.VirtualPagesCount; i++)
     {
         VirtualPages[i] = new VirtualPage(i);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 //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");
     }
 }
Ejemplo n.º 6
0
 public MainWindow()
 {
     RealMachine = new RealMachine(m_virtualMachines);
     InitializeComponent();
 }
Ejemplo n.º 7
0
 private void RunUntilInterup_ButtonClick(object sender, RoutedEventArgs e)
 {
     RealMachine.RunVirtualMachinesUntilTimerInterupt();
 }
Ejemplo n.º 8
0
 private void Run_ButtonClick(object sender, RoutedEventArgs e)
 {
     RealMachine.FullyRunAllPrograms();
 }
Ejemplo n.º 9
0
        static void Main()
        {
            RealMachine rm = new RealMachine();

            rm.runProgram("test.txt", true);
        }
Ejemplo n.º 10
0
    public static void Main(string[] args)
    {
        RealMachine r = new RealMachine();

        r.run();
    }
Ejemplo n.º 11
0
        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);
        }