Programming Exercise #6
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 national hard drive has been developed with N heads. 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 adjacent heads 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
See grading rubric for grade values associated with specific system requirements. Additional requirements/hints are shown below:
The design must use the provided header verbatim. This will allow automated testing of the design you produce.
You may (should) create derived classes of your choosing
Implementation of functions in the abstract base class is acceptable
Your main should not be in the same implementation file as your other classes
Consider a rigorous main program that adequately tests your deadlock-free algorithm
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of