ExecuteQueued() публичный Метод

public ExecuteQueued ( CpuThreadState CpuThreadState, bool MustReschedule ) : int
CpuThreadState CSPspEmu.Core.Cpu.CpuThreadState
MustReschedule bool
Результат int
Пример #1
0
        private void ExecuteQueuedCallbacks()
        {
#if !DISABLE_CALLBACKS
            bool HasScheduledCallbacks = HleCallbackManager.HasScheduledCallbacks;
            bool HasQueuedFunctions    = HleInterop.HasQueuedFunctions;

            if (HasScheduledCallbacks || HasQueuedFunctions)
            {
                var Thread = FindCallbackHandlerWithHighestPriority();
                if (Thread != null)
                {
                    if (HasScheduledCallbacks)
                    {
                        HleCallbackManager.ExecuteQueued(Thread.CpuThreadState, true);
                    }
                    if (HasQueuedFunctions)
                    {
                        HleInterop.ExecuteAllQueuedFunctionsNow();
                    }
                }
            }
#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;
        }