The Pedigree Project  0.1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SlamCache Class Reference

#include <SlamAllocator.h>

+ Collaboration diagram for SlamCache:

Classes

struct  Node
 

Public Member Functions

struct SlamCache::Node __attribute__ ((aligned(16)))
 
 SlamCache ()
 
virtual ~SlamCache ()
 
void initialise (SlamAllocator *parent, size_t objectSize)
 
uintptr_t allocate ()
 
void free (uintptr_t object)
 
size_t recovery (size_t maxSlabs)
 
bool isPointerValid (uintptr_t object) const
 
size_t objectSize () const
 
size_t slabSize () const
 

Private Types

typedef volatile NodealignedNode
 

Private Member Functions

 SlamCache (const SlamCache &)
 
const SlamCacheoperator= (const SlamCache &)
 
Nodepop (alignedNode *head)
 
void push (alignedNode *head, Node *newTail, Node *newHead=0)
 
uintptr_t getSlab ()
 
void freeSlab (uintptr_t slab)
 
NodeinitialiseSlab (uintptr_t slab)
 

Private Attributes

alignedNode m_PartialLists [NUM_LISTS]
 
size_t m_ObjectSize
 
size_t m_SlabSize
 
uintptr_t m_FirstSlab
 
Spinlock m_RecoveryLock
 
SlamAllocatorm_pParentAllocator
 
struct Node m_EmptyNode
 

Detailed Description

A cache allocates objects of a constant size.

Definition at line 142 of file SlamAllocator.h.

Constructor & Destructor Documentation

SlamCache::SlamCache ( )

Default constructor, does nothing.

Definition at line 215 of file SlamAllocator.cc.

SlamCache::~SlamCache ( )
virtual

Destructor is not designed to be called. There is no cleanup, this is a kernel heap!

Definition at line 224 of file SlamAllocator.cc.

Member Function Documentation

uintptr_t SlamCache::allocate ( )

Allocates an object.

Definition at line 298 of file SlamAllocator.cc.

References assert, Processor::id(), m_pParentAllocator, and UNLIKELY.

void SlamCache::free ( uintptr_t  object)

Frees an object.

Definition at line 342 of file SlamAllocator.cc.

References assert, Hex, Processor::id(), m_pParentAllocator, and WARNING.

Referenced by SlamAllocator::allocate().

+ Here is the caller graph for this function:

void SlamCache::initialise ( SlamAllocator parent,
size_t  objectSize 
)

Main init function.

Definition at line 228 of file SlamAllocator.cc.

References assert, and m_pParentAllocator.

Referenced by SlamAllocator::allocate(), and recovery().

+ Here is the caller graph for this function:

size_t SlamCache::recovery ( size_t  maxSlabs)

Member Data Documentation

SlamAllocator* SlamCache::m_pParentAllocator
private

Pointer back to the associated SlamAllocator.

Definition at line 232 of file SlamAllocator.h.

Referenced by allocate(), free(), and initialise().

Spinlock SlamCache::m_RecoveryLock
private

Recovery cannot be done trivially. Spinlock disables interrupts as part of its operation, so we can use it to ensure recovery isn't interrupted. Note recovery is a per-CPU thing.

Definition at line 228 of file SlamAllocator.h.

Referenced by recovery().


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