Question
Jack has been working on the shared cell classes for the producer-consumer problem and the readers and writers problem, and he notices some serious redundancy
Jack has been working on the shared cell classes for the producer-consumer problem and the readers and writers problem, and he notices some serious redundancy in the code. The read and write methods are the same in both classes, and both classes include an instance variable for the data. Jill, his team manager, advises him to place this redundant code in a parent class named SharedCell . Then two subclasses, named PCSharedCell and RWSharedCell, can inherit this code and define the methods beginRead, endRead, beginWrite, and endWrite, to enforce their specific synchronization protocols. Also, the __init__ method in each subclass first calls the __init__ method in the SharedCell class to set up the data, and then adds the condition(s) and other instance variables for its specific situation. Jack has called in sick, so you must complete this hierarchy of classes and redo the demo programs so that they use them.
In Python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started