readers and writers problem

Answer Posted / fk

In this lab you will simulate one of the classical synchronization problems in order to see how the (semi) critical section problem could be implemented using binary and counting semaphores.
5 processes are characterized by 3 readers and 2 writers.
Up to two reader processes can be inside their critical section without any writer process. For writer process to go into its critical section, it should check whether there is any reader or writer process is in the critical section.
Critical section in this problem is reading shared data buffer for reader and updating shared data buffer for writer processes. It is up to you to implement any shared data for readers and writers but you have to specify clearly following things in your sample output.
• When reader or writer enters its critical section, it has to report whether there are any reader(s) or writer(s) other than itself.
• You may print out the data you read or write when you implement real buffer. (Optional)
• You have to print out “Panic Messages” when the rules behind this semi critical section problem are not observed.
In your main program, you run the random number generator function to choose process to execute. The chosen process starts (resumes) execution and after one instruction, it will be returned. (You should force each process run exactly one instruction then returns and waiting for its turn.)
You can implement this using switch statement in C++. Each process is one big switch statement and will be returned after each instruction. You need to keep track of program counter of each process to resume at the right place once it will be chosen to run by keeping global counter variable per process.
Subproject 1: You should implement binary and counting semaphores as studied in the class for this project.
Subproject 2: You should implement swap operation as studied in the class for this project.
You should

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

2211


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

7328


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

3264


write a program using virtual function to find the transposing of a square matrix?

2836


develop a program to calculate and print body mass index for 200 employees

2208






How can I Draw an ellipse in 3d space and color it by using graph3d?

2130


What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }

635


We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character

3949


How to Split Strings with Regex in Managed C++ Applications?

3112


how to write a program that opens a file and display in reverse order?

2561


what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

2061


Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.

3387


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

3393


Code for Easily Using Hash Table?

2383


i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.

1963