Example #1
0
        static internal unsafe void StopProcessorsForGC()
        {
            ProcessorContext *current = Processor.GetCurrentProcessorContext();

            // Set gcIpiGate to 0 for all processors
            ProcessorContext *context = current;

            do
            {
                context->gcIpiGate = 0;

                context = context->nextProcessorContext;
            } while (context != current);

            //
            // We don't want to send a broadcast to all but self on a single
            // processor system since the call will fail with no receivers.
            //
            // Note we may have other processors that have not been enabled
            // by the OS and are sitting in SIPI, and won't answer the IPI.
            //
            if (Processor.GetRunningProcessorCount() > 1)
            {
                Platform.BroadcastFixedIPI((byte)Isal.IX.EVectors.GCSynchronization, false);
            }

            // Wait for ackknowledgement from all CPU's but self
            context = current->nextProcessorContext;

            //DebugStub.WriteLine("StopProcessorsForGC: GC CPU (sender) is {0}\n",
            //__arglist(current->cpuId));

            while (context != current)
            {
                //DebugStub.WriteLine("StopProcessorsForGC: Waiting for CPU {0}\n",
                //__arglist(context->cpuId));

                while (context->gcIpiGate == 0)
                {
                    ;
                }

                //DebugStub.WriteLine("StopProcessorsForGC: CPU {0} Acknowledged\n",
                //__arglist(context->cpuId));

                context = context->nextProcessorContext;
            }

            return;
        }
Example #2
0
        public static void StopApProcessors()
        {
            //
            // Note: This should go into a HAL interface and this
            //       code confined to Platform.cs
            //

            // At this point the BSP and APs are running.
            Tracing.Log(Tracing.Debug, "Processor.StopApProcessors()");

            if (Processor.GetRunningProcessorCount() > 1)
            {
                //
                // This stops them in MpExecution in a halt state with
                // interrupts off.
                //
                Platform.BroadcastFixedIPI((byte)Isal.IX.EVectors.HaltApProcessors, true);
            }

            while (GetRunningProcessorCount() != 1)
            {
                // Thread.Sleep(100); Thread.Sleep needs NoHeapAllocation annotation
                Thread.Yield();
            }

            //
            // We must reset the AP Processors since a debug entry
            // will generated a NMI which will wake them up from HALT,
            // and they may start executing code again while the kernel
            // is still shutting down.
            //
            Platform.ResetApProcessors();

            DebugStub.RevertToUniprocessor();
            // At this point only the BSP is running.
        }