Difference between revisions of "Race Conditions Studio"

From CSE231 Wiki
Jump to navigation Jump to search
Line 12: Line 12:
 
*If so, how is it shared?
 
*If so, how is it shared?
  
#=Code To Use=
+
<!--
#[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html ConcurrentHashMap]
+
=Code To Use=
#: [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#compute-K-java.util.function.BiFunction- compute(key, remappingFunction)]
+
[https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html ConcurrentHashMap]
#
+
: [https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#compute-K-java.util.function.BiFunction- compute(key, remappingFunction)]
#Check out the [[Reference_Page#Compute|compute section of the reference page]] for some insight on this feature of maps
 
  
 +
Check out the [[Reference_Page#Compute|compute section of the reference page]] for some insight on this feature of maps
 +
-->
 
=Code To Debug=
 
=Code To Debug=
 
==Word Score==
 
==Word Score==

Revision as of 17:43, 5 February 2019

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 take in a collection of strings, clean up each string, and add it into another collection of strings concurrently. You will also take in a collection of words, assign a point value to each word, and then put it into a map. Although not terribly exciting, the point of this studio is to teach you how to avoid data races when performing concurrent tasks. In order to accomplish these tasks, you will use the ConcurrentLinkedQueue, array, and ConcurrentHashMap classes.

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 Debug

Word Score

class: SuspectWordScore.java Debugging icon.png
methods: toCleanedWordsViaArray
package: racecondition.studio.wordscore
source folder: student/src/main/java

method: public static List<String> toCleanedWordsViaArray(Collection<String> sourceLines) Parallel.svg (parallel implementation required)

Merge Sort

class: SuspectMergeSort.java Debugging icon.png
methods: parallelMergeSortKernel
package: racecondition.studio.mergesort
source folder: student/src/main/java

method: private static void parallelMergeSortKernel(int[] data, int lowInclusive, int highExclusive, int threshold, Combiner combiner) Parallel.svg (parallel implementation required)

Testing Your Solution

Correctness

class: RaceConditionTestSuite.java Junit.png
package: racecondition.studio
source folder: testing/src/test/java