Exercise 1 The HeapManager in this chapter implements a first-fit mechanism. It uses the first block on the free list that is at least as large as the requested size. Another fairly simple mechanism is called best-fit. As you might guess, the idea is to search the free list for a sufficiently large block that is as close to the requested size as possible. If there is an exact fit on the free list, the best-fit mechanism can stop the search early. Otherwise, it has to search all the way to the end of the free list. This has the advantage that it does not break up large blocks unnecessarily. For example, if there is an exact fit somewhere on the list, the best-fit mechanism will find one, so it will not have to split a block at all. Implement a version of HeapManager with a best-fit mechanism. Start with a renamed copy of the HeapManager class, and then modify the allocate method to implement a best-fit search. (The code for HeapManager is available on the Web site for this book. It includes the coalescing version of deallocate, which is the one you should use.) After this has been tested and works, find a simple sequence of operations for which your best-fit manager succeeds while the first-fit one fails, Hint: There is a sequence that begins like this: mm = new HeapManager (new int [7]); int a mm.allocate (2); int b mm. allocate (1); inte mm. allocate (1); mm.deallocate (a); mm.deallocate (c); By extending this sequence with just two more calls to mm. allocate, you can get something that will succeed for best-fit and fail for first-fit. Although best-fit is often a better placement strategy than first-fit, there are examples for which it is worse. Find a simple sequence of operations for which the first-fit manager succeeds while your best-fit one fails. Hint: There is a sequence that begins like this: mim = new HeapManager (new int [11]); a mm. allocate (4); b = mm. allocate (1); c mm. allocate (3); mm.deallocate (a); mm.deallocate (c); By extending this sequence with just three more calls to mm. allocate, you can get
Exercise 1 The HeapManager in this chapter implements a first-fit mechanism. It uses the first block on the free list that is at least as large as the requested size. Another fairly simple mechanism is called best-fit. As you might guess, the idea is to search the free list for a sufficiently large block that is as close to the requested size as possible. If there is an exact fit on the free list, the best-fit mechanism can stop the search early. Otherwise, it has to search all the way to the end of the free list. This has the advantage that it does not break up large blocks unnecessarily. For example, if there is an exact fit somewhere on the list, the best-fit mechanism will find one, so it will not have to split a block at all. Implement a version of HeapManager with a best-fit mechanism. Start with a renamed copy of the HeapManager class, and then modify the allocate method to implement a best-fit search. (The code for HeapManager is available on the Web site for this book. It includes the coalescing version of deallocate, which is the one you should use.) After this has been tested and works, find a simple sequence of operations for which your best-fit manager succeeds while the first-fit one fails, Hint: There is a sequence that begins like this: mm = new HeapManager (new int [7]); int a mm.allocate (2); int b mm. allocate (1); inte mm. allocate (1); mm.deallocate (a); mm.deallocate (c); By extending this sequence with just two more calls to mm. allocate, you can get something that will succeed for best-fit and fail for first-fit. Although best-fit is often a better placement strategy than first-fit, there are examples for which it is worse. Find a simple sequence of operations for which the first-fit manager succeeds while your best-fit one fails. Hint: There is a sequence that begins like this: mim = new HeapManager (new int [11]); a mm. allocate (4); b = mm. allocate (1); c mm. allocate (3); mm.deallocate (a); mm.deallocate (c); By extending this sequence with just three more calls to mm. allocate, you can get
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
Knowledge Booster
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
Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education