Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Slab_allocator Class Reference

A Slab_allocator is responsible for managing several slabs that have the same slab object size. More...

#include <slaballoc.h>

Collaboration diagram for Slab_allocator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void init (unsigned size, bool physical_memory=false)
void * alloc ()
void free (void *object)
void clear ()
unsigned flush ()
unsigned get_object_size () const
void touch ()

Protected Member Functions

Slabfind_slab_with_free_object ()
Slaballoc_slab ()

Protected Attributes

unsigned object_size
Slabcurrent_slab
List< Slabfree_slabs
List< Slabused_slabs
bool physical

Detailed Description

A Slab_allocator is responsible for managing several slabs that have the same slab object size.


Member Function Documentation

void * Slab_allocator::alloc  ) 
 

Allocate a chunk of memory from one of the slabs this allocator manages.

Slab * Slab_allocator::alloc_slab  )  [protected]
 

Allocate a new slab and add it to this slab allocator's free_slabs list.

void Slab_allocator::clear  ) 
 

Free and flush all slabs managed by this allocator.

Slab * Slab_allocator::find_slab_with_free_object  )  [protected]
 

Return a slab with at least one free object.

unsigned Slab_allocator::flush  ) 
 

Return any completely free slabs back to the underlying page allocator.

void Slab_allocator::free void *  object  ) 
 

Free the given chunk of memory from one of the slabs of this allocator.

unsigned Slab_allocator::get_object_size  )  const [inline]
 

void Slab_allocator::init unsigned  size,
bool  physical_memory = false
 

Initialize this slab allocator with the given object size, using either virtual or physical memory.

void Slab_allocator::touch  )  [inline]
 


Member Data Documentation

Slab* Slab_allocator::current_slab [protected]
 

current slab where allocs happen

List<Slab> Slab_allocator::free_slabs [protected]
 

empty slabs; may be safely flushed

unsigned Slab_allocator::object_size [protected]
 

size of objects in managed slabs

bool Slab_allocator::physical [protected]
 

whether physical memory is used

List<Slab> Slab_allocator::used_slabs [protected]
 

slabs with objects; do not flush


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

Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman