Hello, can I get some guidance on how this simulator could be implemented in Python? Background A
Fantastic news! We've Found the answer you've been seeking!
Question:
Hello, can I get some guidance on how this simulator could be implemented in Python?
Transcribed Image Text:
Background A database buffer is an area of memory that is used to store databases pages (another name for disk blocks). When the database engine requests a block (either to read or to write data) the buffer is first checked to see if the requested page is loaded in memory. If the page is already in memory then the operation is carried out on the data that is in memory. If the page is not in memory then the storage manager causes the disk block to be brought in from disk and stored in memory. The operation is then completed on the page in memory. Thus the storage manager interacts with the buffer manager and the physical storage as the database executes queries. The set of pages that are in memory is referred to as the buffer pool. Each buffer page stores just one block of data that has been loaded from disk. The size of the buffer pool refers to the maximum number of pages that can be stored in memory. If all the buffer pages in the buffer pool are occupied and there is need to bring a new block from disk then one page that is in the buffer must be replaced by the incoming block. The page that is evicted depends on the buffer replacement strategy that is being used. The Least Recently Used (LRU) policy is one in which the page that has not been referenced the longest is replaced. The cost involved in evicting a page is also considered. A page that has been written to is referred to as a dirty page. If a dirty page is to be evicted it must be written out to disk before being replaced. By this token, a dirty page is only evicted if there is no other page that was last accessed earlier. Other considerations include pinned pages and locked pages. A page can be marked to indicate that it should not be removed from the buffer by locking it. Similarly, a page can have a count (a pin count) of transactions that are currently using its data. This simulation will not consider pinned pages nor locked pages. The entries that might be kept in a simple page table that facilitates LRU policy are sketched below: Buffer # Page # Last Access Dirty Other data....... 0 43 10 1 1 438 3 1 2 8 8 0 3 -1 Buffer # is a number for buffer page Page # - holds the page (block #) that is stored in the buffer. In the case where a buffer does not store a page this value is -1 Last Access - stores the time when the page was last accessed. A simplification is to store the value of a counter here. A real buffer manager will use more sophisticated methods but a counter will do for this exercise. Dirty - is set to the value 1 if data has been written to the page since it was loaded into memory otherwise this field has the value 0. Other data (e.g. whether or not a block is pinned) might also be stored in the page table. We will ignore these data for the time being. The Simulator You are required to write a computer program to simulate the operations of a Buffer Manager under a set of simulated database operations. The data for the exercise is given as the file bufferSimulator.csv. Input Data Line 1 contains comma separated values for: Buffer pool size (number of pages/blocks) in the database buffer. Disk size (number of blocks on the disk Lines 2-n shall contain simulated operations that make page references. Again, each line should be comma separated (see sample input) and shall contain: An operation (READ, or WRITE) A page # (should not exceed disk size) A sample input file is illustrated below: Output Line 1: 10, 3000 Line 2: READ, 200 Line 3: WRITE, 158 Line 4: READ, 200 The simulator shall read the input and shall produce output after each operation is carried out. The output shall be a line of comma separated values being: Counter. This starts at 1 for the first operation The operation that was requested Background A database buffer is an area of memory that is used to store databases pages (another name for disk blocks). When the database engine requests a block (either to read or to write data) the buffer is first checked to see if the requested page is loaded in memory. If the page is already in memory then the operation is carried out on the data that is in memory. If the page is not in memory then the storage manager causes the disk block to be brought in from disk and stored in memory. The operation is then completed on the page in memory. Thus the storage manager interacts with the buffer manager and the physical storage as the database executes queries. The set of pages that are in memory is referred to as the buffer pool. Each buffer page stores just one block of data that has been loaded from disk. The size of the buffer pool refers to the maximum number of pages that can be stored in memory. If all the buffer pages in the buffer pool are occupied and there is need to bring a new block from disk then one page that is in the buffer must be replaced by the incoming block. The page that is evicted depends on the buffer replacement strategy that is being used. The Least Recently Used (LRU) policy is one in which the page that has not been referenced the longest is replaced. The cost involved in evicting a page is also considered. A page that has been written to is referred to as a dirty page. If a dirty page is to be evicted it must be written out to disk before being replaced. By this token, a dirty page is only evicted if there is no other page that was last accessed earlier. Other considerations include pinned pages and locked pages. A page can be marked to indicate that it should not be removed from the buffer by locking it. Similarly, a page can have a count (a pin count) of transactions that are currently using its data. This simulation will not consider pinned pages nor locked pages. The entries that might be kept in a simple page table that facilitates LRU policy are sketched below: Buffer # Page # Last Access Dirty Other data....... 0 43 10 1 1 438 3 1 2 8 8 0 3 -1 Buffer # is a number for buffer page Page # - holds the page (block #) that is stored in the buffer. In the case where a buffer does not store a page this value is -1 Last Access - stores the time when the page was last accessed. A simplification is to store the value of a counter here. A real buffer manager will use more sophisticated methods but a counter will do for this exercise. Dirty - is set to the value 1 if data has been written to the page since it was loaded into memory otherwise this field has the value 0. Other data (e.g. whether or not a block is pinned) might also be stored in the page table. We will ignore these data for the time being. The Simulator You are required to write a computer program to simulate the operations of a Buffer Manager under a set of simulated database operations. The data for the exercise is given as the file bufferSimulator.csv. Input Data Line 1 contains comma separated values for: Buffer pool size (number of pages/blocks) in the database buffer. Disk size (number of blocks on the disk Lines 2-n shall contain simulated operations that make page references. Again, each line should be comma separated (see sample input) and shall contain: An operation (READ, or WRITE) A page # (should not exceed disk size) A sample input file is illustrated below: Output Line 1: 10, 3000 Line 2: READ, 200 Line 3: WRITE, 158 Line 4: READ, 200 The simulator shall read the input and shall produce output after each operation is carried out. The output shall be a line of comma separated values being: Counter. This starts at 1 for the first operation The operation that was requested
Expert Answer:
Related Book For
Essentials Of Organizational Behavior Bridging Science And Practice
ISBN: 9781453339244
1st Edition
Authors: Talya Bauer, Berrin Erdogan
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Find a minimum spanning tree for the following graph using all 3 algorithms 13 17 22- 20 15, a. Adding the shortest edge first b. Deleting the longest edge first c. Growing a tree from the node D
-
What are some of the global IS management challenges facing many IS leaders today?
-
A chemical company has a batch process that takes 1,000 litres of a raw material and transforms it into 80 kilograms of X1 and 400 kilograms of X2. Although the joint costs of their production are...
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. Determine the ERR for this project. b. Is this project economically attractive? EOY 0 2 3 4 5 6 NCF -$100 $15 $15 $15...
-
An automobile manufacturer is considering mechanical design changes in one of its top-selling cars to reduce the weight of the car by at least 400 pounds to improve its fuel efficiency. Design...
-
Consider the given vector field. F(x, y, z) = (x + yz)i + (y + xz)j + (z + xy)k (a) Find the curl of the vector field. curl F = (b) Find the divergence of the vector field. div F =
-
Assume that $100 drops from the beak of a seagull. You pick it up and immediately deposit it in your checking account. If the bank keeps 5% of deposits in required reserves: How much money can this...
-
Calculate the center frequency of the band pass filter in Figure 11. 2. Calculate the band width of the band pass filter when the 10kQ variable resistor is 0. 3. Calculate the band width of the band...
-
you will develop a concept map depicting the 3 phases of change in an organization. Be sure to include the following: Examples of each phase. You may want to find a case study where an organization...
-
Unfortunately, there is no shortage of examples of unethical situations and ethics violations within corporations. Some cases produce wide - ranging and devastating effects on all parties involved....
-
The African Economic Outlook (2021) outlines Africa's growth performance and outlook amid the Covid-19 pandemic. Discuss the macroeconomic performance and prospects; macroeconomic environment and...
-
The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the exponential three-month moving average for both stocks where two-thirds of the average weight is placed on the...
-
Suppose three competing airlines each schedule their own flight to Waco which arrives there between 2:00 and 3:00 pm according to a continuous uniform distribution. All three flights are mutually...
-
The Strahler Stream Order System ranks streams based on the number of tributaries that have merged. It is a top-down system where rivers of the first order are the headwaters (aka outermost...
-
A colleague of yours is being sent to India as a manager for a call center. She just told you that she feels very strongly about the following issues: Democratic leaders are the best leaders because...
-
Kronos was founded to help organizations manage employees' time on the job with time clocks. Thus, it is ironic that it would later become a leader in the movement toward offering employees unlimited...
-
The San Francisco, California based Gap Inc. is a clothing giant, with over 3,500 locations in 90 countries, supported by 129,000 employees. The company owns well-known brands such as Banana...
-
One of the newest thrill rides to open in the Walt Disney World Resort may just be the most impressive. As Disney approached its 50th anniversary, the company wanted to celebrate in a truly special...
-
Consider the case on the BBCs Digital Initiative Media in this chapter. What do you think were the main problems associated with the BBCs approach to project management? What challenges did the...
-
The largest professional project management organization in the world is the Project Management Institute (PMI). Go to its Web site, www.pmi.org, and examine the links you find. Which links suggest...
Study smarter with the SolutionInn App