示例#1
0
 private static void FakeMemory(params int[] blockIds)
 {
     for (int i = 0; i < blockIds.Length; i++)
     {
         RealMachine.GetRealMemory().TakeMemoryBlock(blockIds[i]);
     }
 }
示例#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);
            }
        }
示例#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);
     }
 }
示例#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);
     }
 }
示例#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");
     }
 }
示例#6
0
 public MainWindow()
 {
     RealMachine = new RealMachine(m_virtualMachines);
     InitializeComponent();
 }
示例#7
0
 private void RunUntilInterup_ButtonClick(object sender, RoutedEventArgs e)
 {
     RealMachine.RunVirtualMachinesUntilTimerInterupt();
 }
示例#8
0
 private void Run_ButtonClick(object sender, RoutedEventArgs e)
 {
     RealMachine.FullyRunAllPrograms();
 }
示例#9
0
文件: Program.cs 项目: jokubasb/My-OS
        static void Main()
        {
            RealMachine rm = new RealMachine();

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

        r.run();
    }
示例#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);
        }