Homework: Programming Exercise- Deadlock Prevention
Overview
In this exercise we will study a hypothetical magnetic hard drive, (no real basis in reality), but as close to a real-world problem as I can dream up. Suppose that an engineering firm has created a novel way to increase hard drive read performance by adding additional read/write heads (not far from reality). However, as the system is undergoing tests, it has become clear that when two adjacent heads try to read or write at the same time, the data becomes corrupted. In this exercise, the coder will implement an algorithm to allow the read/write heads to be as busy as possible, but not corrupt the data from the adjacent head.
Multi-Head Hard Drive Architecture
As shown in the figure below, a notional hard drive has been developed with Nheads. However, it is a requirement no two adjacent heads can be reading or writing at the same time due to interference issues. And, as usual, rather than fix the hardware, it has fallen on you as the computer engineer to work around the issue in your embedded code. For this exercise, the student need not worry about read/write ordering nor how the read/write actually happens, (that is all well-developed code). The only thing the coder is concerned with is ensuring that no two adjacentheads are engaged at the same time. Your system must also never deadlock. Don't worry about head starvation or make any other attempt at fairness. That will be handled by the algorithm that calls into your code.
Figure 1. Notional Hard Drive
Programming Concepts
This exercise covers many programming concepts including deadlock, threads, reference counting pointers, templates, STL library, mutexes, abstract classes and inheritance, lambdas, closures, and functors.
System Requirements
Additional requirements/hints are shown below:
I. The design must use the provided header verbatim. This will allow automated testing of the design you produce.
II. You may (should) create derived classes of your choosing
III. Implementation of functions in abstract base class is acceptable
IV. Your main should not be in the same implementation file as your other classes
V. Consider a rigorous main program that adequately tests your deadlock-free algorithm
Format your homework according to the following formatting requirements:
(1) The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.
(2) The response also includes a cover page containing the title of the homework, the student's name, the course title, and the date. The cover page is not included in the required page length.
(3) Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.
Attachment:- Coding-Files.rar