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:
1. Thenewmanifesthasmorethanonedevice.
2. Thenewworkloadhasmorethanonefile(infactithasmany).
Reads may also span an arbitrary number of blocks, and be
performed anywhere in the file.
3. Thereisanewoperationthatyoumustimplement.Thisopcode
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 for b0, b1, and c0 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
#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.
4. ImplementaLRUcachethatcachesblocksretrievedandwritten 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.
Honors Option
Create an independent LRU cache for each device in the system. You should not change the API, but hide the details of the caches within your implementation. You should provide a nice looking output showing the performance of each cache as well as the total performance when you close the cache.
Instructions
1. Logintoyourvirtualmachine.Fromyourvirtualmachine, 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).
2. Createadirectoryforyourassignmentsandcopythefileintoit. Change into that directory.
% mkdir cmpsc311
% cp assign3-starter.tgz cmpsc311
% cd cmpsc311
% tar xvzf assign3-starter.tgz
% cd assign3
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.
3. Copyyourcodefromthepreviousassignment.Formosttheonly file you will need is the lcloud_filesys.c file. To copy, simply use
the UNIX cp 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.
4. Youaretocompletethelcloud_cache.cfunctionsdefinedabove, as well as extend the functionality in the lcloud_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.
5. Addcommentstoallofyourfilesstatingwhatthecodeisdoing. 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.
6. Totestyourprogramwiththeseprovidedworkloadfiles,runthe 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:
1. Createatarballfilecontainingtheassign3directory,sourcecode
and build files as completed above. Submit the final tar file through canvas by the assignment deadline. The tarball should be named LASTNAME-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 file MCDANIEL-
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.
2. Beforesendingthetarball,testitusingthefollowingcommands (in a temporary directory — NOT the directory you used to develop the code):
% tar xvzf LASTNAME-PSUEMAILID-assign3.tgz
% cd assign3
% make
… (TEST THE PROGRAM ~ see above)
Note: Like all assignments in this class you are prohibited from copying any content from the Internet or discussing, sharing ideas, code, configuration, text or anything else or getting help from anyone in or outside of the class. Consulting online sources is acceptable, but under no circumstances should anything be copied. Failure to abide by this requirement will result dismissal from the class as described in our course syllabus.