Zero  0.1.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
alloc_page Class Reference

Free-page allocation/deallocation page. More...

#include <alloc_page.h>

Inheritance diagram for alloc_page:
generic_page_header

Public Member Functions

uint32_t byte_place (uint32_t index)
 
uint32_t bit_place (uint32_t index)
 
uint32_t bit_mask (uint32_t index)
 
bool get_bit (uint32_t index)
 
void unset_bit (uint32_t index)
 
void set_bit (uint32_t index)
 
uint32_t get_last_set_bit ()
 
void set_bits (uint32_t from, uint32_t to)
 
void format_empty ()
 
char * unused_part (size_t &length)
 
- Public Member Functions inherited from generic_page_header
uint32_t calculate_checksum () const
 Calculate the correct value of checksum for this page. More...
 

Public Attributes

uint8_t bitmap [bitmapsize]
 
char _fill [sizeof(generic_page)/2 - sizeof(generic_page_header)]
 
- Public Attributes inherited from generic_page_header
uint32_t checksum
 Stored checksum of this page. More...
 
PageID pid
 ID of this page. More...
 
lsn_t lsn
 LSN (Log Sequence Number) of the last write to this page. More...
 
StoreID store
 ID of the store to which this page belongs (0 if none) More...
 
uint16_t tag
 Page type (a page_tag_t) More...
 

Static Public Attributes

static constexpr int bitmapsize = sizeof(generic_page) / 2
 
static constexpr int bits_held = bitmapsize * 8
 
- Static Public Attributes inherited from generic_page_header
static const size_t page_sz = SM_PAGESIZE
 Size of all Zero pages. More...
 

Additional Inherited Members

- Protected Attributes inherited from generic_page_header
uint16_t page_flags
 Page flags (an OR of page_flag_t's) More...
 
uint64_t reserved
 Reserved for subclass usage. More...
 

Detailed Description

Free-page allocation/deallocation page.

These pages contain bitmaps that encode which pages are already allocated. In particular an alloc_page p encodes allocation information for pages with pids in [p.pid_offset..p.pid_offset+p.bits_held).

The implementation is spread between this class and its handle class, alloc_page_h. This class contains the basic fields and accessors for the bitmap's bits. The linkage between these and their interpretation is contained in the handle class.

Member Function Documentation

§ bit_mask()

uint32_t alloc_page::bit_mask ( uint32_t  index)
inline

§ bit_place()

uint32_t alloc_page::bit_place ( uint32_t  index)
inline

§ byte_place()

uint32_t alloc_page::byte_place ( uint32_t  index)
inline

§ format_empty()

void alloc_page::format_empty ( )

§ get_bit()

bool alloc_page::get_bit ( uint32_t  index)
inline

§ get_last_set_bit()

uint32_t alloc_page::get_last_set_bit ( )

§ set_bit()

void alloc_page::set_bit ( uint32_t  index)
inline

§ set_bits()

void alloc_page::set_bits ( uint32_t  from,
uint32_t  to 
)

§ unset_bit()

void alloc_page::unset_bit ( uint32_t  index)
inline

§ unused_part()

char* alloc_page::unused_part ( size_t &  length)
inline

Member Data Documentation

§ _fill

char alloc_page::_fill[sizeof(generic_page)/2 - sizeof(generic_page_header)]

§ bitmap

uint8_t alloc_page::bitmap[bitmapsize]

§ bitmapsize

constexpr int alloc_page::bitmapsize = sizeof(generic_page) / 2
static

Holds the allocation status for pid's in [pid_offset..pid_offset+bits_held); for those pids, a pid p is allocated iff bitmap[bit_place(p-pid_offset)]&bit_mask(p-pid_offset) != 0

Bitmap holds a fixed amount of 32768 (32k) bits. This means that one extent consists of this many pages plus one allocation page responsible for it, yielding exactly 32k pages, or 256MB. The first bit is redundant, as it refers to the alloc page itself. It is always set to one.

§ bits_held

constexpr int alloc_page::bits_held = bitmapsize * 8
static

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