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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Question

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


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.


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.


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



 Use the threading module  for the actors: readers and writers.
The shared resource to be implemented is a text string.

Two different writers are continuously trying to write to the text string.

One writer is writing a date stamp all the way down to seconds.

The other writer writes the same thing, although the string writes backwards.
At least three identical readers simultaneously tries to continuously read the text string and print it to the standard output stream. See also Table for a summary.

Actor Total Task
Reader 3 Reads and prints the text string to the standard stream.
Writer 1 Writes a date stamp, including seconds, to the text string.
Writer 1 Writes a reverse date stamp, including seconds to the text string

it will be a loop while (true) def reader (): and def writer ():

in way when I run the code down will not stop to the user click ctrl +c or to be run to the end 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Avoiding deadlock
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education