Assignment 8
Understanding Deadlock and Starvation
Assignment
Due at the beginning of class on Wednesday, November 5 and Friday November 7.
Background
As discussed in class, one of the skills you will need to acquire as you head out into your career, if you haven't already, is the ability to learn new concepts on your own. In particular, you will no longer have someone who is teaching you in a formal sense, nor will you be given exercises that will be graded to help you learn. However, just as physical exercise is good for the body, so is mental exercise good for the mind. Learning how to identify what you need to learn and helping that process along by designing your own exercises to help you learn is a very important skill.
Preparation
Understand deadlock and starvation by reading the textbook.
To Do
You are to design and write a program to help you understand deadlock and starvation. The following points are important to remember.
- you are not to write a threaded program that forces deadlock among the threads, but rather to write a program in which the four necessary conditions for deadlock are present so that if thread execution timing happens to be just right (wrong) deadlock will occur.
- you are to create a second version of the program that is the same as the first except that the second version is deadlock safe.
- you are to test both versions of your program to demonstrate that deadlock can occur in the first version of the program and that it will not occur in the second version.
- you are to examine the second version to see whether starvation is possible in that version.
To Turn In on Wednesday, November 5
Turn in this information:
- A clear, typed description of your plan for versions 1 and 2 of the program.
- A discussion of why you think deadlock could occur in version 1
- A discussion of whether or not starvation could occur in your second version
To Turn In on Friday, November 7
Your Java program in a form ready to demonstrate.
Special Note
You may work in teams of two on this program.