HW-9 CS451 

$25.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (7 votes)

For this assignment you need to write a program that spawns
10 threads, uses command-line arguments, and that reads and
writes files.

The command-line argument will be “mutex” or “nomutex”. When
running in “nomutex” mode the 10 threads will each read 1 word
at a time from a file (hw9.data) and write that word to another
file (hw9.nomutex). I suggest you include a sleep() to slow
things down a bit. After all, you do want the two versions to
produce different results.

When running in “mutex” mode any thread that wants to read a
word must first set a mutex, when the word is written to the
output file the mutex is released. The output filename here
is hw9.mutex.

Output fle format (both files):
word <tab> thread_number_that_wrote_word
word <tab> thread_number_that_wrote_word
word <tab> thread_number_that_wrote_word
.
.
.

Input file format:
word
word
word
.
.
.

In your comment section, provide a brief analysis of the results
(compare the two output files).

REQUIREMENTS:
————-
1. Your program must compile and run on Linux Mint.
2. Your full name must appear as a comment at the beginning of your
program.
3. Your source code must be named hw9-yourname.c or hw9-yourname.cpp
4. Your source MUST compile using “gcc hw9-yourname.c -pthread” or
“g++ hw9-yourname.cpp -lpthread”
5. Failure to follow the above 4 directions will result in
loss of points.