// Block while the queue is empty, then return the head of the queue. public ServiceRequest Dequeue() { while (true) { // For now disable interrupts: bool iflag = Processor.DisableInterrupts(); spinLock.Acquire(); try { if (tail != null) { ServiceRequest req = head; if (req != tail) { head = req.next; } else { head = null; tail = null; } return(req); } } finally { spinLock.Release(); // Reenable interrupts Processor.RestoreInterrupts(iflag); } // Wait on event enqueueEvent.InterruptAwareWaitOne(); } }
public static void AddBytesSent(long bytes) { bool iflag = Processor.DisableInterrupts(); bytesSent += bytes; Processor.RestoreInterrupts(iflag); }
public void Enqueue(ServiceRequest req) { // For now disable interrupts: bool iflag = Processor.DisableInterrupts(); spinLock.Acquire(); try { if (head == null) { head = req; tail = req; } else { tail.next = req; tail = req; } } finally { spinLock.Release(); } // Signal an event : for now it is possible that it can be spirous one... enqueueEvent.InterruptAwareSet(); // Reenable interrupts Processor.RestoreInterrupts(iflag); }
private static void FinalizeServices() { ARM_PROGRESS("Kernel!075"); Tracing.Log(Tracing.Audit, "Shutting down AP processors"); Processor.StopApProcessors(); Tracing.Log(Tracing.Audit, "Shutting down I/O system"); Console.WriteLine("Shutting down I/O system"); IoSystem.Finalize(); Tracing.Log(Tracing.Audit, "Interrupts OFF."); Processor.DisableInterrupts(); Tracing.Log(Tracing.Audit, "Shutting down scheduler"); Console.WriteLine("Shutting down scheduler"); for (int i = 0; i < Processor.processorTable.Length; i++) { Processor p = Processor.processorTable[i]; if (p != null) { Console.WriteLine(" cpu {0}: {1} context switches, {2} interrupts", i, p.NumContextSwitches, p.NumInterrupts); } } // Finalize the scheduler scheduler.Finalize(); // We should turn off interrupts here! Platform.ReleaseResources(); PEImage.Finalize(); DebugStub.WriteLine("Kernel Exiting [{0}]", __arglist(bootReturnCode)); }
static internal unsafe void GCSynchronizationInterrupt() { // - member barriers and other issues with spinwaiting on a variable bool en = Processor.DisableInterrupts(); //DebugStub.WriteLine("Processor {0} received GCSynchronizationInterrupt!\n", //__arglist(Processor.GetCurrentProcessorId())); ProcessorContext *current = Processor.GetCurrentProcessorContext(); // Write value for this processor stating we ackknowledge the interrupt current->gcIpiGate = 1; // Question: Are we at a GC safe point? For all GC's? // // Spinwait until the GC processor indicates its done by clearing // this flag. // while (current->gcIpiGate != 0) { // } Processor.RestoreInterrupts(en); //DebugStub.WriteLine("Processor {0} done with GCSynchronizationInterrupt!\n", //__arglist(Processor.GetCurrentProcessorId())); return; }
public void SetNextTimerInterrupt(TimeSpan delta) { // Make sure that interrupts are disabled bool iflag = Processor.DisableInterrupts(); TimeSpan start = delta; if (delta < timer.MinInterruptInterval) { delta = timer.MinInterruptInterval; } if (delta > timer.MaxInterruptInterval) { delta = timer.MaxInterruptInterval; } #if false DebugStub.WriteLine("-- SetNextTimerInterrupt(delta={0}, start={1} [min={2},max={3})", __arglist(delta.Ticks, start.Ticks, timer.MinInterruptInterval.Ticks, timer.MaxInterruptInterval.Ticks)); #endif timer.SetNextInterrupt(delta); // Restore interrupts if necessary Processor.RestoreInterrupts(iflag); }
private static void ApServiceLoop() { DebugStub.WriteLine("ApServiceThread is initialized and sleeping ..."); MpExecution.MpCall mpCall; bool iflag; while (true) { abiEvent.WaitOne(); DebugStub.WriteLine ("HSG: ** cpu.{0} receives AbiCall interrupt", __arglist(Processor.GetCurrentProcessorId())); // Current design: the boot processor will get all // unserved abi call. So we don't need to worry // missing any calls while (true) { iflag = Processor.DisableInterrupts(); mpCall = MpExecution.GetMpCall(Processor.GetCurrentProcessorId()); Processor.RestoreInterrupts(iflag); // There is no unserved abi call, just break if (mpCall == null) { break; } BspAbiStub.ProcessMpCall(Processor.GetCurrentProcessorId(), mpCall); } } }
public static bool DisableInterrupts() { if ((ProcessPrivileges.GetCurrentPrivileges().AllowedOperations & ProcessPrivileges.Operations.DisableInterrupts) != 0) { return(Processor.DisableInterrupts()); } // ISSUE: Assert here until all instances get cleaned up from SIPs // This assertion should be removed / replaced with something that would // flag / halt / break only the bogus SIP, not the entire system VTable.Assert(false, "DisableInterrupts called from unprivileged SIP"); return(false); }
public static void WaypointDump() { bool iflag = Processor.DisableInterrupts(); DebugStub.WriteLine("Interrupts: {0}", __arglist(Processor.CurrentProcessor.NumInterrupts - WaypointInterrupt)); DebugStub.WriteLine("WPT Waypoint Sequence THD Diff"); for (int i = 1; i < WaypointNumber; i++) { DebugStub.WriteLine("{0,3:d} {1,10:d} {2,10:d} {3,3:d} {4,10:d}", __arglist( i, Waypoints[i], WaypointSeq[i], WaypointThd[i].GetHashCode(), Waypoints[i] - Kernel.Waypoints[i - 1])); } Processor.RestoreInterrupts(iflag); }