OS Course Ex 3 Programming

Operating Systems, Spring 2003

Exercise 3 Programming: Buffer Cache

Subject: User-Level Buffer Cache Library

Due Date: 12.06.2003 NOTE: there will be NO EXTENSIONS to this deadline

This exercise is DIFFICULT. Start early.

Introduction


Files containing databases and programs are becoming larger and larger. Efficient management of multiple file access becomes an imperative issue of operating systems. Most of the time the problem is solved using a buffering/caching technique.In this exercise you will practice the paging concepts you've learned in class and produce an efficient file access manager.

You are required to implement a basic functionality of Buffer Cache (see Bach, The Design of the UNIX Operating System, Chapter 3) for multi-thread processes. This will be done in a form of a library, that will provide basic file access functions as an interface, while behind it a buffering scheme will be implemented.

You will implement a Buffer Cache consisting of a set of blocks. The number of blocks and the size of each block is determined at the time of Buffer Cache initialization.

Buffer Cache logically divides an accessed file into blocks starting from the beginning of the file. Assume that size of the block is S then starting from the first byte of the file the blocks will be formed by the byte intervals: [0,...,S-1],[S,...,2S-1],... Notice that the last block may be not completely filled by the file, since file size may be not a multiplicative of the block size. Buffer Cache will still allocate a complete block, however it will keep the notion in its internal structures that only a fraction of the block contains valid data.

When a user accesses data from a file, the Buffer Cache first checks if a copy of the appropriate data exists in blocks held in the main memory. Otherwise it copies the blocks (perhaps several of them if such need arises) from the disk. Least Recently Used policy is applied if another block needs to be evicted from the pool in the main memory.

Notice that eviction of a block that contains data different from the originally copied from the disk, has to be written back to the disk

Library (libbufc.a) interface

Buffer Cache Semantics

In this exercise the following semantics will apply to buffer cache:

Background reading


Submission

Submit tar file named ex3.tar containing:

Guidelines:



GOOD LUCK !!
To the course home page