0

Recently, I've been getting into OS development and have been experimenting with writing my own small kernel. I've just begun to look understand and implement a block-cache, for caching data read from/written to block devices such as hard disks.

From what I understand, the cached blocks are ordered based on the frequency they are requested. Something I'm having trouble understanding is, what keeps a block with a use count of 1 from being immediately evicted from the cache?

Take a file open operation for example; as the kernel walks the various structures of the filesystem, it will read, and re-read blocks numerous times. If cache simply overwrites the last block before it is needed again, then isn't the efficiency of the cache lost entirely?

I ask, because if I'm using pointers elsewhere in the kernel to access data stored by the block-cache, I essentially need to know how long a block will stay cached.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.