// start changes put your changes here // end changes
For this assignment and all subsequent ones, you may work in groups of max 5 students. Be sure that you read carefully how the lab should be handed in. Make sure the group has all the required material, and each of you hand in what is required individually.
Test your scheduler with three threads,
one at each priority level. Have each thread run in a
loop incrementing a counter. After every 10,000 loops,
have each thread print out its id and the current
value of its counter and then sleep for 5 seconds,
allowing a lower priority thread to run.
Reader <id> reading <character>
where <id> is the unique identifier of the Reader.
The Writer threads want to update (i.e. overwrite) the shared object with a single character which they read, in a sequential order from a text file, a file called writer_input.txt (best is to use a text file where neighboring characters are different). When a writer updates the shared object, it should produce the following output on the screen:
Writer <id> writing <character>
where <id> is the unique identifier of the writer, and <character> is the character just written on to the shared object. Every character read from the text file is written only by one of the Writer threads, i.e., access to the file must be synchronized and the file pointer is incremented after each access. Synchronization thus must be provided for both accessing the shared object and reading the text file.
Test your solution with multiple readers and writers. Of course, with multiple readers and writers, the output will illustrate the concurrency provided by threads. As multiple Readers can access the shared object concurrently before an update occurs, you may see several Readers reading the same character from the shared object.
Your code should prompt for the number of readers and
the number of writers, in that order. You can assume that
a valid integer is provided by the user for each of
these. You should be sure that your code works for
different input files as we may test it with files other
than what you provide (i.e., to check that the synchronization you
What you need to turn in (each person individually):
Turn in a hard copy of your assessment of the division of labor in the group in the format shown below. If you give yourself a 50% and your partner gives you a 50%, you will get the whole credit. If you give your partner a 40% and your partner gives himself or herself a 40%, he or she will get 80% points. And so on...