assignment 3 lioncloud v 1 1
This next assignment will build upon your completed code for the previous assignment. You MUST use the the code turned in for the previous assignment. If you have bugs or incomplete code you have to fix it first. You are to implement new features and integrate code for the new features and workload. Unless stated otherwise, the architecture and behavior of the new system is the same as in the previous assignment.
Note: This assignment description provides an overview of the assignment. The associated slides (and in class presentation) provide more information, hints, and guidance for the project. Please refer to those materials as well in completing this assignment.
Feature Overview
You are to extend your device driver that sits between the virtual application and virtualized hardware devices. As before, the application makes use of the abstraction you provide called the LionCloud driver. In this next assignment, you will make modifications to the code to implement the following features:
- The new manifest has more than one device.
- The new workload has more than one file (in fact it has many). Reads may also span an arbitrary number of blocks, and be performed anywhere in the file.
- There is a new operation that you must implement. This op code initializes the device and gets the number of blocks and sectors (which may be different for each device). The op code is called
LC_DEVINIT
. The frame values forb0
,b1
, andc0
as the same as in the previous assignment. The other frame values are:
Operation Description Remaining register use LC_DEVINIT Initialize interface to a specific device When sending: - c1 – device to initialize
- c2, d1, d0 – 0
When receiving
- c1 – device initialized
- c2 – 0
- d0 – the number of sectors in this device
- d1 – the number of blocks per/sectopr in this device
You cannot depend on the constant size of the device info:
#define LC_DEVICE_NUMBER_SECTORS 10_x000D_ #define LC_DEVICE_NUMBER_BLOCKS 64
These numbers are not even defined any more. The idea is that once you did the LC_PROBE and find that a device exists, you will have to LC_DEVINIT and learn how many sectors and blocks there are for each device. You then have to dynamically allocate memory to hold the information you had for your previous device.
- Implement a LRU cache that caches blocks retrieved and written to the LionCloud devices. The API for the cache is provided in lc_cache.h and the starter code for the implementation is in lc_cache.c. You will need to:
- Implement all of the functions defined in the file.
- Add code to call the functions from your driver implementation. In particular, any place you get a block from the driver, you should check first if it is in the cache.
- You should collect statistics on how many hits and misses you have. Print out the values and your hit ratio when you close the cache.
The cache should be fully associative (any block can go in any cache line). It should be dynamically allocated when
lcloud_initcache
is called. Each line should contain the device/sector/block and data. You can use a hash table or perform a linear search over this data structure to find entries or empty lines. You may also use other data structures as you see fit.It is recommended to implement LRU by tracking when each element was last used, and linearly searching for the oldest element as a candidate for eviction.
Instructions
- Login to your virtual machine. From your virtual machine, download the starter source code provided for this assignment. To do this, go to the canvas website and download the file assign3-starter.tgz (you should be able to click the link here).
- Create a directory for your assignments and copy the file into it. Change into that directory.
% mkdir cmpsc311_x000D_ % cp assign3-starter.tgz cmpsc311_x000D_ % cd cmpsc311_x000D_ % tar xvzf assign3-starter.tgz_x000D_ % cd assign3_x000D_
Once unpacked, you will have the starter files in the assign3, including the source code, libraries, some workload and manifest files and a Makefile. Note that there is a file cmpsc311-assign3-sample-output.txt that contains sample output from my implementation of the assignment.
- Copy your code from the previous assignment. For most the only file you will need is the
lcloud_filesys.c
file. To copy, simply use the UNIXcp
command. For example:cp ../assign2/lcloud_filesys.c .
NOTE: be sure to make a copy of the original file before you start. A good way to do this is to email yourself a copy of the code before you get started. - You are to complete the
lcloud_cache.c
functions defined above, as well as extend the functionality in thelcloud_filesys.c
to meet the requirements above. Note that you may need to create additional supporting functions within the same file. Include functional prototypes for these functions at the top of the file. - Add comments to all of your files stating what the code is doing. Fill out the comment function header for each function you are defining in the code. A sample header you can copy for this purpose is provided for the main function in the code.
- To test your program with these provided workload files, run the code specifying a workload file as follows:
./lcloud_sim -v cmpsc311-assign3-manifest.txt cmpsc311-assign3-workload.txt
Note that you don’t necessarily have to use the -v option, but it provides a lot of debugging information that is helpful. If the program completes successfully, the following should be displayed as the last log entry:LionCloud simulation completed successfully!!!
To turn in:
- Create a tarball file containing the
assign3
directory, source code and build files as completed above. Submit the final tar file through canvas by the assignment deadline. The tarball should be namedLASTNAME-PSUEMAILID-assign3.tgz
, where LASTNAME is your last name in all capital letters and PSUEMAILID is your PSU email address without the “@psu.edu”. For example, the professor was submitting a homework, he would call the fileMCDANIEL-pdm12-assign3.tgz
. Any file that is incorrectly named, has the incorrect directory structure, or has misnamed files, will be assessed a one day late penalty. - Before sending the tarball, test it using the following commands (in a temporary directory — NOT the directory you used to develop the code):
% tar xvzf LASTNAME-PSUEMAILID-assign3.tgz_x000D_ % cd assign3_x000D_ % make_x000D_ ... (TEST THE PROGRAM ~ see above)_x000D_