ExecuteQueued() 공개 메소드

public ExecuteQueued ( CpuThreadState BaseCpuThreadState ) : void
BaseCpuThreadState CSPspEmu.Core.Cpu.CpuThreadState
리턴 void
예제 #1
0
        private void ExecuteQueuedInterrupts()
        {
#if !DISABLE_CALLBACKS
            if (Threads.Count > 0)
            {
                HleInterruptManager.ExecuteQueued(Threads.First().CpuThreadState);
            }
#endif
        }
예제 #2
0
        public void StepNext()
        {
            MustReschedule = false;

            //HleInterruptManager.EnableDisable(() => {
            //});

            if (Threads.Count > 0)
            {
                HleInterruptManager.ExecuteQueued(Threads.First().CpuThreadState);
            }

            // Select the thread with the lowest PriorityValue
            var NextThread = CalculateNext();

            //Console.WriteLine("NextThread: {0} : {1}", NextThread.Id, NextThread.PriorityValue);

            // No thread found.
            if (NextThread == null)
            {
                if (Processor.PspConfig.VerticalSynchronization)
                {
                    Thread.Sleep(1);
                }
                return;
            }

            // Run that thread
            Current = NextThread;
            {
                // Waiting, but listeing to callbacks.
                if (Current.IsWaitingAndHandlingCallbacks)
                {
                    HleCallbackManager.ExecuteQueued(Current.CpuThreadState, MustReschedule);
                }
                // Executing normally.
                else
                {
                    Current.CurrentStatus = HleThread.Status.Running;
                    try
                    {
                        if (Processor.PspConfig.DebugThreadSwitching)
                        {
                            ConsoleUtils.SaveRestoreConsoleState(() =>
                            {
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine("Execute: {0} : PC: 0x{1:X}", Current, Current.CpuThreadState.PC);
                            });
                        }
                        Current.Step();
                    }
                    finally
                    {
                        if (Current.CurrentStatus == HleThread.Status.Running)
                        {
                            Current.CurrentStatus = HleThread.Status.Ready;
                        }
                    }
                }
            }
            Current = null;

            // Decrement all threads by that PriorityValue.
            int DecrementValue = NextThread.PriorityValue;

            foreach (var Thread in Threads)
            {
                //Console.WriteLine(Thread.PriorityValue);
                Thread.PriorityValue -= DecrementValue;
            }

            // Increment.
            NextThread.PriorityValue += NextThread.Info.PriorityCurrent + 1;
        }