blackrobe 0 Junior Poster in Training

Hey there,

I'm having some difficulty understanding how pthreads are used for writing to files and reading from files using a buffer cache.

There are two data structures available:
1- The first data structure is just an array of files each index contain information about the size of the file and a pointer to a linked list of all the blocks of the file in cache.

2- The second is an array of slots in the cache, each slot contains information about the file occupying the slot, block number, and a variable indicating if the block has been written to but the changes were not saved onto disk.

I'm supposed to keep both structures in sync and their data consistent.

Would anyone please explain to me what happens when a read/write operation is taking place, and how will these structures interact? I'm trying to understand the concept before implementing it, so any help would be appreciated.

Thank you.