NITCbase / nitcbase.github.io

The entire documentation on implementing the NITCbase project.
https://nitcbase.github.io/
MIT License
10 stars 6 forks source link

Unclear algorithm for StaticBuffer::setDirtyBit #18

Closed SaintNerevar closed 2 years ago

SaintNerevar commented 2 years ago

The algorithm doesn't state what happens if the call to StaticBuffer::getBufferNum fails i.e the block in question isn't in the buffer. If this scenario never happens due to design, the docs should make it clear.

gokulsreekumar commented 2 years ago

OLD:

int StaticBuffer::setDirtyBit(int blockNum) {
    // Check if blockNum is valid (non zero and less than number of disk blocks)
    // and return E_OUTOFBOUND if not valid.

    // find the buffer number corresponding to the block using getBufferNum().

    // set the dirty flag of that buffer in metaInfo to true

    // return SUCCESS

}

POSSIBLE NEW CHANGE:

int StaticBuffer::setDirtyBit(int blockNum) {
    // Check if blockNum is valid (non zero and less than number of disk blocks)
    // and return E_OUTOFBOUND if not valid.

    // find the buffer number corresponding to the block using getBufferNum().
          // if it returns FAILURE, then Block is not loaded to any buffer. Hence return FAILURE (or a new ERROR?).

    // set the dirty flag of that buffer in metaInfo to true

    // return SUCCESS

}

Note:

gokulsreekumar commented 2 years ago

@jessiyajoy please verify

gokulsreekumar commented 2 years ago

Do setDirtyBit function has to be public? is it being called anywhere else, other than its friend classes.

jessiyajoy commented 2 years ago

@jessiyajoy please verify

Return E_BLOCKNOTINBUFFER(new constant to be added)

gokulsreekumar commented 2 years ago