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

Page_allocator Class Reference

Page_allocator is the allocator/deallocator for whole pages or ranges of pages. More...

#include <pagealloc.h>

Collaboration diagram for Page_allocator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void init (void *start, Size memory_size, unsigned max_alignment, void *metadata_end=NULL, bool managed_pages_are_physical=false)
Pagealloc_page_within (unsigned alignment, void *owner, unsigned begin, unsigned end)
Pagealloc_page_above (unsigned alignment, void *owner, unsigned begin)
Pagealloc_page_below (unsigned alignment, void *owner, unsigned end)
Pagealloc_page (unsigned alignment, void *owner)
void free_page (Page *page)
Pageget_page_info (void *memory) const
void * get_metadata_start ()
void * get_max_metadata_start ()
bool manages (void *memory)
void print ()

Protected Member Functions

Pagefind_free_page (unsigned alignment, unsigned begin, unsigned end)
Pagetry_to_split_page (unsigned requested_alignment, unsigned begin, unsigned end)
Pagesplit_page (Page *page, unsigned requested_alignment, unsigned begin, unsigned end)
Pagetry_to_coalesce_page (unsigned requested_alignment, unsigned begin, unsigned end)
Pagecoalesce_page (Page *page, unsigned requested_alignment, unsigned begin, unsigned end)

Protected Attributes

unsigned memory_begin
unsigned memory_end
Pagepages
unsigned page_count
unsigned free_list_count
List< Page > * free_lists

Detailed Description

Page_allocator is the allocator/deallocator for whole pages or ranges of pages.

It can be used to manage either virtual or physical pages.

The original page allocator was generously contributed by Lee Salzman.


Member Function Documentation

Page * Page_allocator::alloc_page unsigned  alignment,
void *  owner
[inline]
 

Allocate a page.

Page * Page_allocator::alloc_page_above unsigned  alignment,
void *  owner,
unsigned  begin
[inline]
 

Allocate a page greater than or equal to an address.

begin is a page address shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::alloc_page_below unsigned  alignment,
void *  owner,
unsigned  end
[inline]
 

Allocate a page less than an address.

end is a page address shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::alloc_page_within unsigned  alignment,
void *  owner,
unsigned  begin,
unsigned  end
 

Allocate a page within an address range.

The range values are page addresses shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::coalesce_page Page page,
unsigned  requested_alignment,
unsigned  begin,
unsigned  end
[protected]
 

Coalesce a page to a desired alignment so that it is within the given begin and end range.

The range values are page addresses shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::find_free_page unsigned  alignment,
unsigned  begin,
unsigned  end
[protected]
 

Attempt to find and allocate a free page in one of the free lists.

The range values are page addresses shifted right by PAGE_ALIGNMENT.

void Page_allocator::free_page Page page  ) 
 

Return a page to the allocator.

void * Page_allocator::get_max_metadata_start  ) 
 

Return the start address of this allocator's metadata as if it managed the maximum number of pages allowed by this architecture.

void* Page_allocator::get_metadata_start  )  [inline]
 

Return the start address of this allocator's metadata.

Page * Page_allocator::get_page_info void *  memory  )  const [inline]
 

Get the page metadata for a given page address.

void Page_allocator::init void *  start,
Size  memory_size,
unsigned  max_alignment,
void *  metadata_end = NULL,
bool  managed_pages_are_physical = false
 

Initialize this allocator to manage pages from the given memory start address to start + memory_size.

Page spans can be at most of max_alignment. Put allocator metadata in a contiguous range of memory ending at metadata_end or at the end of the managed memory range if metadata_end is NULL.

bool Page_allocator::manages void *  memory  )  [inline]
 

Return whether this page allocator manages the given page.

void Page_allocator::print  ) 
 

Print out basic info on this allocator.

Page * Page_allocator::split_page Page page,
unsigned  requested_alignment,
unsigned  begin,
unsigned  end
[protected]
 

Split a page to a desired alignment so that it is within the given begin and end range.

The range values are page addresses shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::try_to_coalesce_page unsigned  requested_alignment,
unsigned  begin,
unsigned  end
[protected]
 

Attempt to find a candidate for coalescing pages and if found, do it within the given begin and end range.

The range values are page addresses shifted right by PAGE_ALIGNMENT.

Page * Page_allocator::try_to_split_page unsigned  requested_alignment,
unsigned  begin,
unsigned  end
[protected]
 

Attempt to find a candidate for splitting pages and if found, do a split within the given begin and end range.

The range values are page addresses shifted right by PAGE_ALIGNMENT.


Member Data Documentation

unsigned Page_allocator::free_list_count [protected]
 

number of free lists maintained

List<Page>* Page_allocator::free_lists [protected]
 

array of free page lists for alignments 0 to free_lists_count - 1

unsigned Page_allocator::memory_begin [protected]
 

address of first managed page, shifted right by PAGE_ALIGNMENT

unsigned Page_allocator::memory_end [protected]
 

address of last managed page, shifted right by PAGE_ALIGNMENT

unsigned Page_allocator::page_count [protected]
 

number of managed pages

Page* Page_allocator::pages [protected]
 

array of Pages this manages


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

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