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 for b0, b1, and c0 as the same as in the previous assignment. The other frame values are:
c1 – device to initialize
c2, d1, d0 – 0
c1 – device initialized
c2 – 0
d0 – the number of sectors in this device
d1 – the number of blocks per/sectopr in this 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.
Operation

Description

Remaining register use

LC_DEVINIT

Initialize interface to a specific device

When sending:

When receiving

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.

Sample Solution

This question has been answered.

Get Answer