First fit algorithm int n[5]=(4,3,8,2,3); bool full|5] = {false, false, false, false, false); II keep track of hole occupied input data block size; for(all holes) { if(found current hole size >= data size) && not occupied) { if (current hole size > data size && next hole not occupied && not last hole) { next hole += (current hole size - data size); // give extra space to next hole if (not last && next hole not occupied) current hole size = data size; //allocate full[current] = true; else { full[current] = true; break; Sample output Initial space allocation Hole e : e Hole 1: e Hole 2 : e -754973744 35544 41222336 41227488 Hole 3: e Hole 4 : e Enter data block size: 3 Allocated hole e Enter data block size: 4 Allocated hole 1 Enter data block size: 3 Allocated hole 2 Enter data block size: 5 Allocated hole 3 Enter data block size: 3 Allocated hole 4 All holes occupied? -771750959 input sizes {3,4,3,5,3} Test out some other data block sizes: true true true true true {8,3,2,2,1} {5,7,1,2,4} What are the Final space allocation Hole e : e Hole 1: e Hole 2: e Hole 3 : e -771750959 -771750959 35545 outputs? -771750959 -77175e959 35545 -754973744
First fit algorithm int n[5]=(4,3,8,2,3); bool full|5] = {false, false, false, false, false); II keep track of hole occupied input data block size; for(all holes) { if(found current hole size >= data size) && not occupied) { if (current hole size > data size && next hole not occupied && not last hole) { next hole += (current hole size - data size); // give extra space to next hole if (not last && next hole not occupied) current hole size = data size; //allocate full[current] = true; else { full[current] = true; break; Sample output Initial space allocation Hole e : e Hole 1: e Hole 2 : e -754973744 35544 41222336 41227488 Hole 3: e Hole 4 : e Enter data block size: 3 Allocated hole e Enter data block size: 4 Allocated hole 1 Enter data block size: 3 Allocated hole 2 Enter data block size: 5 Allocated hole 3 Enter data block size: 3 Allocated hole 4 All holes occupied? -771750959 input sizes {3,4,3,5,3} Test out some other data block sizes: true true true true true {8,3,2,2,1} {5,7,1,2,4} What are the Final space allocation Hole e : e Hole 1: e Hole 2: e Hole 3 : e -771750959 -771750959 35545 outputs? -771750959 -77175e959 35545 -754973744
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...
Related questions
Question
need in C code
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 with 1 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY