The Pedigree Project  0.1
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Spinlock Class Reference
+ Collaboration diagram for Spinlock:

Public Member Functions

 Spinlock (bool bLocked, bool bAvoidTracking=false)
 
bool acquire (bool recurse=false, bool safe=true)
 
void exit ()
 
void release ()
 
bool acquired ()
 
bool interrupts () const
 

Static Public Attributes

static const bool allow_recursion = true
 

Private Member Functions

void unwind ()
 
void trackRelease () const
 

Private Attributes

volatile bool m_bInterrupts = false
 
Atomic< bool > m_Atom = true
 
Atomic< uint64_t > m_CpuState = 0
 
uint64_t m_Sentinel = 0
 
uint32_t m_Magic = 0xdeadbaba
 
uint32_t m_MagicAlign = 0
 
void * m_pOwner = nullptr
 
size_t m_Level = 0
 
size_t m_OwnedProcessor = ~0
 
uintptr_t m_Ra = 0
 
bool m_bAvoidTracking = false
 
bool m_bOwned = false
 

Friends

class PerProcessorScheduler
 
class LocksCommand
 

Detailed Description

Definition at line 27 of file Spinlock.h.

Member Function Documentation

bool Spinlock::acquire ( bool  recurse = false,
bool  safe = true 
)

Enter the critical section.

The 'safe' param disables certain deadlock checks that might fail in some circumstances (especially during multiprocessor startup). It really shouldn't be used for the majority of cases.

Note
When we hit this breakpoint, we're not able to backtrace as backtracing depends on the log spinlock, which may have deadlocked. So we actually force the spinlock to release here, then hit the breakpoint.

Definition at line 43 of file Spinlock.cc.

References LocksCommand::checkState(), Processor::getCount(), Processor::getInterrupts(), Hex, Processor::id(), Processor::information(), panic(), Processor::pause(), LocksCommand::setFatal(), Processor::setInterrupts(), and WARNING.

Referenced by PosixSubsystem::acquire(), MemoryMapManager::acquireLock(), Semaphore::acquireWithResult(), PerProcessorScheduler::addThread(), ArmV7VirtualAddressSpace::allocateStack(), MemoryMapManager::contains(), Ohci::doAsync(), Cache::evict(), Log::flushEntry(), GPTimer::initialise(), CdiIrqHandler::irq(), Thread::join(), Process::kill(), PerProcessorScheduler::killCurrentThread(), KernelElf::lockModules(), InputManager::mainThread(), PerProcessorScheduler::processorAddThread(), SlamCache::recovery(), Semaphore::release(), PosixSubsystem::release(), MemoryMapManager::remove(), Semaphore::removeThread(), PerProcessorScheduler::schedule(), Thread::sendEvent(), MemoryMappedFile::setPermissions(), MemoryMapManager::setPermissions(), Thread::shutdown(), ConditionVariable::signal(), Thread::Thread(), MemoryMapManager::trap(), PosixSubsystem::~PosixSubsystem(), and Thread::~Thread().

+ Here is the caller graph for this function:

void Spinlock::exit ( )

Exit the critical section, without restoring interrupts.

Note
When we hit this breakpoint, we're not able to backtrace as backtracing depends on the log spinlock, which may have deadlocked. So we actually force the spinlock to release here, then hit the breakpoint.

Definition at line 213 of file Spinlock.cc.

References Dec, Processor::getInterrupts(), Hex, panic(), and trackRelease().

Referenced by PerProcessorScheduler::killCurrentThread(), release(), and PerProcessorScheduler::schedule().

+ Here is the caller graph for this function:

void Spinlock::release ( )
void Spinlock::trackRelease ( ) const
private

Track the release of this lock.

Definition at line 194 of file Spinlock.cc.

References Hex, LocksCommand::lockReleased(), and LocksCommand::setFatal().

Referenced by exit().

+ Here is the caller graph for this function:

void Spinlock::unwind ( )
private

Unwind the spinlock because a thread is releasing it.

Definition at line 286 of file Spinlock.cc.

Referenced by PerProcessorScheduler::addThread(), and PerProcessorScheduler::schedule().

+ Here is the caller graph for this function:

Member Data Documentation

Atomic<uint64_t> Spinlock::m_CpuState = 0
private
Todo:
handle more than 64 CPUs.

Definition at line 67 of file Spinlock.h.


The documentation for this class was generated from the following files: