Race Condition Translation Assignment

From CSE231 Wiki
Jump to navigation Jump to search

Motivation

Race conditions can lead to difficult bugs to find and fix. We gain experience finding them and fixing them.

Background

In this studio, you will translate an array of texts in parallel.

The Core Questions

Really think about these questions in each case. Knowing the answers to these will tell you where the problem is.

  • What are the tasks?
  • What is the data?
  • Is the data mutable?
  • If so, how is it shared?

Code To Investigate

SequentialPigLatinTranslator

package racecondition.translate.antiquated;
public class SequentialPigLatinTranslator extends AbstractPigLatinTranslator {
	@Override
	public String[] translateAllWords(String[] words) {
		String[] translatedWords = new String[words.length];
		for (int i = 0; i < words.length; ++i) {
			translatedWords[i] = translateWord(words[i]);
		}
		return translatedWords;
	}
}


Code To Debug

TranslationUtils

class: ParallelPigLatinTranslator.java Debugging icon.png
methods: translateAllWords
package: racecondition.translate.warmup
source folder: student/src/main/java

method: public String[] translateAllWords(String[] words) Parallel.svg (parallel implementation required)

public class ParallelPigLatinTranslator extends AbstractPigLatinTranslator {
	@Override
	public String[] translateAllWords(String[] words) throws InterruptedException, ExecutionException {

		throw new NotYetImplementedException();

	}
}

Client

class: TranslationClient.java DEMO: Java.png
methods: main
package: racecondition.translate.client
source folder: src//java

The client invokes your method with a Pig Latin tranlator:

String[] translatedWords = TranslationUtils.translate(words, new PigLatinTranslator());

Testing Your Solution

Correctness

class: _TranslateTestSuite.java Junit.png
package: racecondition.translate.warmup
source folder: testing/src/test/java

Pledge, Acknowledgments, Citations

file: race-condition-translate-pledge-acknowledgments-citations.txt

More info about the Honor Pledge