Question: 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)

 1 Special Readers/Writers Problem You are to design a concurrent program

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!