singrdk/base/Kernel/System/Threading/PreemptionLock.cs

43 lines
972 B
C#
Raw Normal View History

2008-11-17 18:29:00 -05:00
////////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
using Microsoft.Singularity;
using System;
using System.Runtime.CompilerServices;
namespace System.Threading
{
///
// Prevents preemption by disabling interrupts.
//
[NoCCtor]
[CLSCompliant(false)]
public struct PreemptionLock
{
[Inline]
[NoHeapAllocation]
public bool Lock()
{
#if TRACE
Tracing.Log(Tracing.Debug, "PreemptionLock.Acquire()");
#endif
return Processor.DisableLocalPreemption();
}
[Inline]
[NoHeapAllocation]
public void Unlock(bool iflag)
{
#if TRACE
Tracing.Log(Tracing.Debug, "PreemptionLock.Release()");
#endif
Processor.RestoreLocalPreemption(iflag);
}
}
}