Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Special Readers/Writers Problem You are to design a concurrent program consisting of two types of threads: SpecialReaders and Spe- cialWriters. A reader (resp. writer)

image text in transcribed

1 Special Readers/Writers Problem You are to design a concurrent program consisting of two types of threads: SpecialReaders and Spe- cialWriters. A reader (resp. writer) thread always executes read (resp. write) function. The following three constraints must be maintained 1. A special reader and a special writer cannot execute their main function (read/write) at the same time. 2. Readers (resp. writers) can execute concurrently. However, there should never be more than three special readers (resp. special writers) executing their main functions 3. Special readers and special writers should not starve. Special readers and writers are modelled as threads. Your program should be parameterized with (1) number of special readers; (2) number of special writers; and (3) an integer n (your program should stop when both readers and writers execute n times) The output of your program should report the state of readers and writers (enter/execute/exit). Benchmarks. In order to study fairness of your implementation you have to count the number of times readers and writers have executed. Run your program for 5 readers and 5 writers and for n equal 10, 20, 50, 100, 500 and 1000 Create a file output.txt that contains the following information # this is a comment #n nb of readers nb of writers 10 20 50 100 500 1000 Draw a graph consisting of two curves. The first (resp. second) curve represents the number of readers (resp. writers) entered the room with respect to n. According to the obtained graph (bench.pdf), make some conclusions (answer.txt) discussing fairness of your implementation. You may update the file plot given in the previous assignment. You are free to use either C+ or Java 1 Special Readers/Writers Problem You are to design a concurrent program consisting of two types of threads: SpecialReaders and Spe- cialWriters. A reader (resp. writer) thread always executes read (resp. write) function. The following three constraints must be maintained 1. A special reader and a special writer cannot execute their main function (read/write) at the same time. 2. Readers (resp. writers) can execute concurrently. However, there should never be more than three special readers (resp. special writers) executing their main functions 3. Special readers and special writers should not starve. Special readers and writers are modelled as threads. Your program should be parameterized with (1) number of special readers; (2) number of special writers; and (3) an integer n (your program should stop when both readers and writers execute n times) The output of your program should report the state of readers and writers (enter/execute/exit). Benchmarks. In order to study fairness of your implementation you have to count the number of times readers and writers have executed. Run your program for 5 readers and 5 writers and for n equal 10, 20, 50, 100, 500 and 1000 Create a file output.txt that contains the following information # this is a comment #n nb of readers nb of writers 10 20 50 100 500 1000 Draw a graph consisting of two curves. The first (resp. second) curve represents the number of readers (resp. writers) entered the room with respect to n. According to the obtained graph (bench.pdf), make some conclusions (answer.txt) discussing fairness of your implementation. You may update the file plot given in the previous assignment. You are free to use either C+ or Java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability & Statistics For Engineers & Scientists

Authors: Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying

7th Edition

9789813131279, 130415294, 9813131276, 978-0130415295

Students also viewed these Databases questions

Question

=+j Explain the litigation risks in international labor relations.

Answered: 1 week ago

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago