[Solved] CSE216-Assignment 5 CREW (concurrent-read exclusive-write)

$25

File Name: CSE216-Assignment_5_CREW_(concurrent-read_exclusive-write).zip
File Size: 546.36 KB

SKU: [Solved] CSE216-Assignment 5 CREW (concurrent-read exclusive-write) Category: Tag:
5/5 - (1 vote)

Concurrent-read exclusive-write (CREW) is a fundamental concurrent programming paradigm. As the name suggests, it is about implementing a system that allows for multiple threadsto read a shared object, but only allows one thread to write to a shared object at any given moment. In this part of the assignment, your task is to write a class called WordCounter,whose work is described below:1. This class will read a list of plain text files, all of which are in a given folder.2. Based on the word counts, it will generate a table that shows which word appears how many times and in which file.Let us look at a worked out example. Suppose there are three text files:text-a.txt: There are so many words in this file. Well, actually not that many if you really start counting them.text-b.txt: The words are scattered everywhere, and in no order whatsoever. What. So. Ever. How will counting them help?text-c.txt: So, what can you do?The output table is shown below.For the purpose of this assignment, you need not worry about hyphenated words (e.g., e-mail), apostrophes (e.g., its or Maam), word-like objects (e.g., a date written as 01-12-2020), acronyms and abbreviations (e.g., Mr., U.S.A.), or quotes.Note the following features of this output:the words in column one are alphabetically orderedthe columns corresponding to the files are alphabetically ordered by file namethe first columns width is the longest words length plus one character (so that theres a single spacebetween the longest word and the first number)all the columns specific to a file have the same width, and counts the number of occurrences of aword in that filethe last column counts the total number of occurrences of a word across all filesall words are lowercasedpunctuation (. , : ; ! ?) has been completely ignoredThe WordCounter file must generate this output for the set of all files in a specific folder. Toaccomplish this, it must read each text file in a separate thread. Of course, all the words and word-countsfrom individual files have to consolidated to write the final table. This is where you must carefully puttogether the results obtained by the different threads.First, you should test this code without multithreading (i.e., the number of threads is just one the mainthread) and then, with multithreading, to see what kind of speed boost (if any) you are getting. This willalso help you identify bugs in your code. If something is going wrong with a single thread, then ofcourse, the multithreaded version will also have bugs (and debugging single-threaded programs aremuch easier).The basic structure of WordCounter is given below. Your class must have the constantsFOLDER_OF_TEXT_FILES, WORD_COUNT_TABLE_FILE, and NUMBER_OF_THREADS. These arethe only values we will change to run your code, so you have to be absolutely sure that your code ismodular and robust enough to not crash if these details are changed when the code is run on anothermachine. For grading, only these constants will be changed, and your code will then be run (the graderswill not modify anything else).text-a text-b text-c totalactually 1 0 0 1and 0 1 0 1are 1 1 0 2can 0 0 1 1counting 1 1 0 2do 0 0 1 1ever 0 1 0 1everywhere 0 1 0 1file 1 0 0 1help 0 1 0 1how 0 1 0 1if 1 0 0 1in 1 1 0 1many 2 0 0 2no 0 1 0 1not 1 0 0 1order 0 1 0 1really 1 0 0 1scattered 0 1 0 1so 1 1 1 3start 1 0 0 1that 1 0 0 1the 0 1 0 1them 1 1 0 2there 1 0 0 1this 1 0 0 1well 1 0 0 1what 0 1 1 2whatsoever 0 1 0 1will 0 1 0 1words 1 1 0 2you 1 0 1 2public class WordCounter {// The following are the ONLY variables we will modify for grading.// The rest of your code must run with no changes.public static final Path FOLDER_OF_TEXT_FILES = Paths.get(); // path to the folder where input text files are locatedpublic static final Path WORD_COUNT_TABLE_FILE = Paths.get(); // path to the output plain-text (.txt) filepublic static final int NUMBER_OF_THREADS = 2; // max. number of threads to spawn

public static void main(String args) {// your implementation of how to run the WordCounter as a stand-alone multi-threaded program}}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE216-Assignment 5 CREW (concurrent-read exclusive-write)
$25