Пример #1
0
        static int RunMultiCore()
        {
            // While there are programs in the job queue
            while (Queue.New.First != null)
            {
                // Load to memory from disk - requires the mmu lock to access
                LongTermScheduler.Execute();

                // While the ready queue is not empty thread the CPU threads
                while (Queue.Ready.First != null)
                {
                    // Dispatch to CPUs
                    ShortTermScheduler.Start();

                    foreach (var core in Cores)
                    {
                        if (!core.isWaiting && core.ActiveProgram != null)
                        {
                            // Wait for the core thread to start and the CPU acquires the MMU lock in its critical section
                            System.Console.WriteLine("Running PCB: " + core.ActiveProgram.ProcessID);
                            core.Run();
                        }
                    }
                }
            }

            if (Queue.Terminated.Count != 30 || Queue.New.First != null)
            {
                return(-1);
            }

            return(0);
        }
Пример #2
0
        static int RunSingleCore()
        {
            while (Queue.New.First != null)
            {
                // Acquires the mmu semaphore for reading and writing to memory
                LongTermScheduler.Execute();
                ShortTermScheduler.Start();

                // Waits for the core thread to run
                System.Console.WriteLine("Running PCB: " + Cores[0].ActiveProgram.ProcessID);
                Cores[0].Run();
                // WriteToFile("ramdata", RAMDUMP());
            }

            if (Queue.Terminated.Count != 30 || Queue.New.First != null)
            {
                return(-1);
            }

            return(0);
        }