Implementing a Buffer Cache | Assignment 2 | Operating System

Brief Information
Trace
  • 2016-04-12 Tue.: Homework 2-1.pptx handed in. The file was explained on this day.
  • 2016-04-14 Thu.: Homework 2-2.pptx handed in.?The file was explained on this day.
  • 2016-04-30 Sat.: Read Homework 2-1.pptx.
  • 2016-04-30 Sat. 4:53PM: Step 1 has been done.
  • 2016-04-30 Sat. 10:37PM: Step 2 has been done.
  • 2016-05-01 Sun. 12:09AM: Read Homework 2-1.pptx.?BufInit() has been implemented. Step 3?has been done.
  • 2016-05-01 Sun. 11:41AM: void AddNewBufIntoLruList(Buf* pBuf)?has been implemented.?Step 4-1 has been done.
  • 2016-05-01 Sun. 12:11PM: Buf* GetBufFromLruList(Buf* pBuf)?has been implemented.?Step 4-2 has been done.
  • 2016-05-01 Sun. 1:39PM: void UpdateBufAsMru(Buf* pBuf)?has been implemented.?Step 4-3 has been done.
  • 2016-05-01 Sun. 3:49PM: void BufRead(int blkno, void* pData) has been implemented. Two suspicious design: [1] if a buffer is got from the free list, is the buffer inserted into the head or tail of a hash? [2] “Copy data in the buffer to pData”, does it mean pData = pBuf->pMem??Step 5 has been done.
  • 2016-05-01 Sun. 9:54PM: void BufWrite(int blkno, void* pData) has been implemented.?Step 6 has been done.
  • 2016-05-01 Sun. 10:23PM: void BufSync(void) has been implemented.?Step 7 has been done.?BufInit() has been updated.
  • 2016-05-02 Mon. 4:06PM: Step 8 has been done.
  • 2016-05-02 Mon. 4:06PM: Step 9, 10 and 11 have been done.?BufWrite and BufRead have been edited.
  • 2016-05-03 Tue. 1:20AM: Step 12?has been done.
  • 2016-05-03 Tue. 5:45PM: Step 14 has been done. But I did not test those functions.
  • 2016-05-03 Tue. 6:21PM: Step 13 has been done.
  • 2016-05-04?Wed.: Debug bugs aroused by testcase.c
  • 2016-05-04 Wed.: Step 16 has been done. I implemented the daemon system using process signals.
  • 2016-05-04 Wed.: Create makefile and organize files to submit.
  • 2016-05-04?Wed. 10:22PM: The assignment has been submitted.
  • Total time = 8(Sat.) + 7(Sun.) + 7.25(Mon.)?+ 5(Tue.) + 7.25(Wed.) =approx. 34.5 hrs
Steps to Conquer the Assignment
  1. Modify the header hw2.h used in Assignment 1 following the instruction. Then, check the whole program works correctly using the test code.
  2. Modify the name of functions and their arguments in the source file hw2.c. Then, Then, check the whole program works correctly using the test code.
  3. Implement void BufInit().
  4. Make a function that renew the LRU list when a new buffer is added or a buffer in the list is used again. (Subtask:
    • [1] Make a function that adds a new buffer in the list.
    • [2] Make a function that return a result whether a buffer exists in the LRU list.
    • [3] Make a function that renew an existing buffer as the MRU.)
  5. Implement?void BufRead(int blkno, void* pData).
  6. Implement?void BufWrite(int blkno, void* pData).
  7. Implement?void BufSync(void).
  8. Make a function that returns the number of buffers in the free list. The function is going to be used with buffer replacement.
  9. Learn how to use clone().
  10. Make a daemon thread just for testing the thread behavior.
  11. Make the real daemon thread.
  12. Implement?void GetBufInfoInLruList(Buf** ppBufInfo, int* pNumBuf).
  13. Implement void GetBufInfoByListNum(BufList listnum, Buf** ppBufInfo, int* pNumBuf).
  14. Use Dev functions.
    • DevCreateDisk, DevOpenDisk?in BufInit.
    • DevWriteBlock in BufSync, BufDaemon.
    • DevReadBlock in BufRead.
  15. Execute testcase.c and solve bugs in my source codes. It requires to edit overall source code I have made.
  16. Implement daemon system.
Given Template C Source Codes

hw2.h

hw2.c

Disk.h

Disk.c

 

A Source Code to Test

 

References

Leave a Reply

Your email address will not be published. Required fields are marked *