Class TwoLevelMemory

Class Documentation

class TwoLevelMemory

the parameters B and M of the model, the counters of the I/Os and the occupation of the internal memory

Public Functions

TwoLevelMemory(std::size_t B, std::size_t M)

a memory of M items and blocks of B items

Pre:

B >= 1 and M >= 2 B

TwoLevelMemory(const TwoLevelMemory&) = delete
TwoLevelMemory &operator=(const TwoLevelMemory&) = delete
std::size_t blockSize(void) const

B, the items of a block.

std::size_t memorySize(void) const

M, the items of the internal memory.

std::size_t blocks(std::size_t n) const

ceil( n / B ), the blocks of n items

std::uint64_t reads(void) const
std::uint64_t writes(void) const
std::uint64_t ios(void) const

reads() + writes()

void resetCounters(void)

sets the counters of the I/Os to 0, and the peak to the memory in use

void allocate(std::size_t k)

takes k items of the internal memory

Pre:

used() + k <= M

void release(std::size_t k)

gives back k items of the internal memory

Pre:

k <= used()

std::size_t used(void) const

the items of the internal memory in use

std::size_t peak(void) const

the largest used() since the construction or resetCounters()

void countRead(void)

one more read, or one more write: called by DiskFile only

void countWrite(void)