14.1: The Block Store

Open Data Structures - An Introduction · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    14.1: The Block Store

    The notion of external memory includes a large number of possible different devices, each of which has its own block size and is accessed with its own collection of system calls. To simplify the exposition of this chapter so that we can focus on the common ideas, we encapsulate external memory devices with an object called a BlockStore. A BlockStore stores a collection of memory blocks, each of size \(B\). Each block is uniquely identified by its integer index. A BlockStore supports these operations:

    1. \(\mathtt{readBlock(i)}\): Return the contents of the block whose index is \(\mathtt{i}\).
    2. \(\mathtt{writeBlock(i,b)}\): Write contents of \(\mathtt{b}\) to the block whose index is \(\mathtt{i}\).
    3. \(\mathtt{placeBlock(b)}\): Return a new index and store the contents of \(\mathtt{b}\) at this index.
    4. \(\mathtt{freeBlock(i)}\): Free the block whose index is \(\mathtt{i}\). This indicates that the contents of this block are no longer used so the external memory allocated by this block may be reused.

    The easiest way to imagine a BlockStore is to imagine it as storing a file on disk that is partitioned into blocks, each containing \(B\) bytes. In this way, \(\mathtt{readBlock(i)}\) and \(\mathtt{writeBlock(i,b)}\) simply read and write bytes \(\mathtt{i}B,\ldots,(\mathtt{i}+1)B-1\) of this file. In addition, a simple BlockStore could keep a free list of blocks that are available for use. Blocks freed with \(\mathtt{freeBlock(i)}\) are added to the free list. In this way, \(\mathtt{placeBlock(b)}\) can use a block from the free list or, if none is available, append a new block to the end of the file.


    This page titled 14.1: The Block Store was last modified on Sat, 01 May 2021 15:13:34 GMT and is shared under a CC BY license and was authored, remixed, and/or curated by Pat Morin (Athabasca University Press) .