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

Virtual_memory Class Reference

Virtual_memory is the allocator/deallocator for virtual memory. More...

#include <virtmem.h>

Collaboration diagram for Virtual_memory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void init (unsigned &last_available_address)
void * alloc (Size request_size)
void * resize (void *memory, Size new_size)
void free (void *memory)
void enable ()
bool is_enabled ()
bool manages (void *virtual_page)
void print ()

Static Public Member Functions

Virtual_memorycreate (unsigned &last_available_address, bool map_memory=false)

Public Attributes

Page_allocator virtual_pages

Protected Attributes

Slab_allocator allocators [PAGE_ALIGNMENT]
bool enabled

Static Protected Attributes

const unsigned MAX_PAGE_SPAN_ALIGNMENT = 16

Detailed Description

Virtual_memory is the allocator/deallocator for virtual memory.

The original slab allocator code was generously contributed by Lee Salzman. There is one slab allocator for each power-of-two object size up to PAGE_SIZE.


Member Function Documentation

void * Virtual_memory::alloc Size  request_size  ) 
 

Allocate some virtual memory of the given size in bytes and return it.

Virtual_memory * Virtual_memory::create unsigned &  last_available_address,
bool  map_memory = false
[static]
 

Create a Virtual_memory allocator object below the given address and return a pointer to the new object.

If map_memory is true then this new allocator will be mapped into physical memory, and init() should be be called on it before use. If map_memory is false, then this allocator will be brought in from disk and then immediately enabled.

void Virtual_memory::enable  )  [inline]
 

Enable the virtual memory and allow allocation.

void Virtual_memory::free void *  memory  ) 
 

Free some virtual memory previously allocated by alloc().

void Virtual_memory::init unsigned &  last_available_address  ) 
 

Initialize the virtual memory allocator.

bool Virtual_memory::is_enabled  )  [inline]
 

Return whether virtual memory is active.

bool Virtual_memory::manages void *  virtual_page  )  [inline]
 

Return whether this virtual memory allocator manages the given page.

void Virtual_memory::print  ) 
 

Print basic information on the virtual memory allocator.

void * Virtual_memory::resize void *  memory,
Size  new_size
 

Resize some existing allocated memory to a new size.


Member Data Documentation

Slab_allocator Virtual_memory::allocators[PAGE_ALIGNMENT] [protected]
 

managed slab allocators

bool Virtual_memory::enabled [protected]
 

whether virtual memory is active

const unsigned Virtual_memory::MAX_PAGE_SPAN_ALIGNMENT = 16 [static, protected]
 

largest possible page span is PAGE_SIZE * 2^MAX_PAGE_SPAN_ALIGNMENT bytes

Page_allocator Virtual_memory::virtual_pages
 

page allocator for virtual memory


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

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