Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

189 lines
8.6 KiB

// Ruler
// 1 2 3 4 5 6 7 8
//345678901234567890123456789012345678901234567890123456789012345678901234567890
/********************************************************************/
/* */
/* The standard layout. */
/* */
/* The standard layout for 'cpp' files in this code is as */
/* follows: */
/* */
/* 1. Include files. */
/* 2. Constants local to the class. */
/* 3. Data structures local to the class. */
/* 4. Data initializations. */
/* 5. Static functions. */
/* 6. Class functions. */
/* */
/* The constructor is typically the first function, class */
/* member functions appear in alphabetical order with the */
/* destructor appearing at the end of the file. Any section */
/* or function this is not required is simply omitted. */
/* */
/********************************************************************/
#include "InterfacePCH.hpp"
#include "FastHeap.hpp"
/********************************************************************/
/* */
/* Constants local to the class. */
/* */
/* The constants supplied here try to make the layout of the */
/* the caches easier to understand and update. */
/* */
/********************************************************************/
CONST SBIT32 FindCacheSize = 8192;
CONST SBIT32 FindCacheThreshold = 0;
CONST SBIT32 FindSize = 4096;
CONST SBIT32 Stride1 = 4;
CONST SBIT32 Stride2 = 1024;
/********************************************************************/
/* */
/* The description of the heap. */
/* */
/* A heap is a collection of fixed sized allocation caches. */
/* An allocation cache consists of an allocation size, the */
/* number of pre-built allocations to cache, a chunk size and */
/* a parent page size which is sub-divided to create elements */
/* for this cache. A heap consists of two arrays of caches. */
/* Each of these arrays has a stride (i.e. 'Stride1' and */
/* 'Stride2') which is typically the smallest common factor of */
/* all the allocation sizes in the array. */
/* */
/********************************************************************/
STATIC ROCKALL::CACHE_DETAILS Caches1[] =
{
//
// Bucket Size Of Bucket Parent
// Size Cache Chunks Page Size
//
{ 4, 256, 32, 4096 },
{ 8, 128, 32, 4096 },
{ 12, 128, 64, 4096 },
{ 16, 128, 64, 4096 },
{ 20, 64, 64, 4096 },
{ 24, 64, 96, 4096 },
{ 32, 64, 128, 4096 },
{ 40, 64, 128, 4096 },
{ 48, 64, 256, 4096 },
{ 64, 64, 256, 4096 },
{ 80, 64, 512, 4096 },
{ 96, 64, 512, 4096 },
{ 128, 32, 4096, 4096 },
{ 160, 16, 4096, 4096 },
{ 192, 16, 4096, 4096 },
{ 224, 16, 4096, 4096 },
{ 256, 16, 4096, 4096 },
{ 320, 8, 4096, 4096 },
{ 384, 8, 4096, 4096 },
{ 448, 8, 4096, 4096 },
{ 512, 4, 4096, 4096 },
{ 576, 4, 4096, 4096 },
{ 640, 4, 8192, 8192 },
{ 704, 4, 4096, 4096 },
{ 768, 4, 4096, 4096 },
{ 832, 4, 8192, 8192 },
{ 896, 4, 8192, 8192 },
{ 960, 4, 4096, 4096 },
{ 0,0,0,0 }
};
STATIC ROCKALL::CACHE_DETAILS Caches2[] =
{
//
// Bucket Size Of Bucket Parent
// Size Cache Chunks Page Size
//
{ 1024, 16, 4096, 4096 },
{ 2048, 16, 4096, 4096 },
{ 3072, 4, 65536, 65536 },
{ 4096, 8, 65536, 65536 },
{ 5120, 4, 65536, 65536 },
{ 6144, 4, 65536, 65536 },
{ 7168, 4, 65536, 65536 },
{ 8192, 8, 65536, 65536 },
{ 9216, 0, 65536, 65536 },
{ 10240, 0, 65536, 65536 },
{ 12288, 0, 65536, 65536 },
{ 16384, 2, 65536, 65536 },
{ 21504, 0, 65536, 65536 },
{ 32768, 0, 65536, 65536 },
{ 65536, 0, 65536, 65536 },
{ 65536, 0, 65536, 65536 },
{ 0,0,0,0 }
};
/********************************************************************/
/* */
/* The description bit vectors. */
/* */
/* All heaps keep track of allocations using bit vectors. An */
/* allocation requires 2 bits to keep track of its state. The */
/* following array supplies the size of the available bit */
/* vectors measured in 32 bit words. */
/* */
/********************************************************************/
STATIC int NewPageSizes[] = { 1,4,16,64,0 };
/********************************************************************/
/* */
/* Class constructor. */
/* */
/* The overall structure and layout of the heap is controlled */
/* by the various constants and calls made in this function. */
/* There is a significant amount of flexibility available to */
/* a heap which can lead to them having dramatically different */
/* properties. */
/* */
/********************************************************************/
FAST_HEAP::FAST_HEAP
(
int MaxFreeSpace,
bool Recycle,
bool SingleImage,
bool ThreadSafe
) :
//
// Call the constructors for the contained classes.
//
ROCKALL
(
Caches1,
Caches2,
FindCacheSize,
FindCacheThreshold,
FindSize,
MaxFreeSpace,
NewPageSizes,
Recycle,
SingleImage,
Stride1,
Stride2,
ThreadSafe
)
{ /* void */ }
/********************************************************************/
/* */
/* Class destructor. */
/* */
/* Destory the heap. */
/* */
/********************************************************************/
FAST_HEAP::~FAST_HEAP( VOID )
{ /* void */ }