Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

reportmemory method is not working the right way can you help me fix it and make it work public static void reportMemory() { int start

reportmemory method is not working the right way can you help me fix it and make it work

public static void reportMemory() { int start = -1; int end = -1; int num = -1; int temp = -1;

int i = 0; for (int k = 0; k < MAX; k++) { if (addresses[k] != 0) { while (i < MAX) {

if (addresses[i] != 0) { if (start == -1) { start = i; } } temp = addresses[i]; if (i + 1 < MAX) { num = addresses[i + 1]; } end = i - 1; if (temp != num) { if (temp == 0) { System.out.printf("Addresses [%d, %d]Unused ", start, end); start = i; }else{ System.out.printf("Addresses [%d, %d]Process P%d ", start, end, temp - 1); start = i; } }

i++; } } else { start = -1; end = -1; for (int j = 0; j < MAX; j++) { if (addresses[j] == 0) { if (start == -1) { // Found the start of a free region start = j; } end = j; } } if (start != -1) { // The last free region has not been printed yet System.out.printf("Addresses [%d, %d]Unused ", start, end); break; }

} }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions