From 582293d02cfc759fc3d7cce6b6ebaf919eb0ea71 Mon Sep 17 00:00:00 2001 From: dpturnbull Date: Fri, 23 Nov 2012 20:05:29 -0500 Subject: [PATCH] Final Working Code --- FirstFit.java | 10 ---------- NextFit.java | 11 ----------- log.txt | 11 +++++++++++ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/FirstFit.java b/FirstFit.java index 59ac5c8..5689bcc 100644 --- a/FirstFit.java +++ b/FirstFit.java @@ -102,7 +102,6 @@ class FirstFit implements baseAlgorithm memTable[s1+1][5] = -1; tableEntries++; jobLoaded=1; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -128,7 +127,6 @@ class FirstFit implements baseAlgorithm memTable[s1+1][5] = -1; tableEntries++; jobLoaded=1; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -145,7 +143,6 @@ class FirstFit implements baseAlgorithm jobArray[jobId - 1] = newJob; newJob.start(); jobLoaded=1; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -170,7 +167,6 @@ class FirstFit implements baseAlgorithm } catch (Exception e) { - System.out.println("Could not allocate job with ID " + jobId); } //} } @@ -187,19 +183,14 @@ class FirstFit implements baseAlgorithm int deallocates1=0; jobSize = jSize; startLoc = beginningLocation; - System.out.println("jSize= "+jobSize+" startLoc= "+startLoc); //s1=0; do { if(memTable[deallocates1][2] == startLoc) { - System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]); - System.out.println(startLoc+" removed job "+memTable[deallocates1][0]); memTable[deallocates1][0] = 0; memTable[deallocates1][1] = 0; memTable[deallocates1][5] = 0; - System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]); - System.out.println(toString()); noJobs--; deallocates1=memSize*2; } @@ -214,7 +205,6 @@ class FirstFit implements baseAlgorithm //this method compacts the memory public void compMem() { - //System.out.println("Compacting Memory"); compMemTest=tableEntries; for(int c=0; c<=compMemTest; c++) { diff --git a/NextFit.java b/NextFit.java index 1adee76..9b7d304 100644 --- a/NextFit.java +++ b/NextFit.java @@ -109,7 +109,6 @@ class NextFit implements baseAlgorithm positionToCompress=currentPosition; tableEntries++; jobLoaded=1; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -137,7 +136,6 @@ class NextFit implements baseAlgorithm currentPosition++; jobLoaded=1; positionToCompress=currentPosition; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -156,7 +154,6 @@ class NextFit implements baseAlgorithm currentPosition++; jobLoaded=1; positionToCompress=currentPosition; - System.out.println("add job "+jobId+toString()); s1=memSize*2; } } @@ -189,7 +186,6 @@ class NextFit implements baseAlgorithm } catch (Exception e) { - System.out.println("Could not allocate job with ID " + jobId); } //} } @@ -202,24 +198,18 @@ class NextFit implements baseAlgorithm //this method removes a job it does not check to see if the job exisits public void deallocate(int jSize, int beginningLocation) { - System.out.println("jSize= "+jSize+" startLoc= "+beginningLocation); synchronized(memTable){ int deallocates1=0; jobSize = jSize; startLoc = beginningLocation; - System.out.println("jSize= "+jobSize+" startLoc= "+startLoc); //s1=0; do { if(memTable[deallocates1][2] == startLoc) { - System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]); - System.out.println(startLoc+" removed job "+memTable[deallocates1][0]); memTable[deallocates1][0] = 0; memTable[deallocates1][1] = 0; memTable[deallocates1][5] = 0; - System.out.println(memTable[deallocates1][0]+" "+memTable[deallocates1][1]+" "+memTable[deallocates1][5]); - System.out.println(toString()); noJobs--; deallocates1=memSize*2; } @@ -234,7 +224,6 @@ class NextFit implements baseAlgorithm //this method compacts the memory public void compMem() { - //System.out.println("Compacting Memory"); compMemTest=tableEntries; for(int c=0; c<=compMemTest; c++) { diff --git a/log.txt b/log.txt index e69de29..ac4d35e 100644 --- a/log.txt +++ b/log.txt @@ -0,0 +1,11 @@ +Memory Management Log +--------------------------- +Job Amount: 200 +Memory Size: 100 +--------------------------- +Final Times (All times in milliseconds) +Threaded time: 0 +Best fit time: 0 +Worst fit time: 0 +First fit time: 28094 +Next fit time: 26375