My task from the teacher is to create a program that solves the three problems using threads in Python: 2 files: reader.py and writer.py In the readers-writers problem there is a common resource where a group of actors called readers want to read from the resource and another group of actors called writers want to write to the resource. The basic synchronization problem that needs to be solved is: 1.  Mutual exclusion of the resource, where: • only one writer may print at a time, and • no writer may write while a reader is reading. An ordinary mutex lock that is applied equally to all actors can solve this but will lead to only one actor being able to enter its critical section at a time. This is a problem as we normally want several readers to be able to read at the same time.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

My task from the teacher is to create a program that solves the three problems using threads in Python:

2 files: reader.py and writer.py


In the readers-writers problem there is a common resource where a group of actors called readers want to read from the resource and another group of actors called writers want to write to the resource.


The basic synchronization problem that needs to be solved is:
1.  Mutual exclusion of the resource, where:
• only one writer may print at a time, and
• no writer may write while a reader is reading.
An ordinary mutex lock that is applied equally to all actors can solve this but will lead to only one actor being able to enter its critical section at a time. This is a problem as we normally want several readers to be able to read at the same time.


The next problem that needs to be solved is therefore the following:


2. Several readers should be able to read the resource at the same time.
In a solution where several readers can read simultaneously and lock out the writers, there is always a risk of starvation in the writers. The more readers and the more time they spend in their critical section, the more unlikely it is that writers will find an opening where all readers are outside their critical section.


The last problem that needs to be solved is therefore the following:
3. As soon as a writer wants to write, new readers must not enter their critical section.1
In other words, writers have priority over readers. As a rule, this is preferable to the opposite as a resource, such as the value of a variable, is out of date for a reader until the writer has updated it. Readers thus read an outdated value while the writer waits.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY